Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 217736
b: refs/heads/master
c: 33c87f0
h: refs/heads/master
v: v3
  • Loading branch information
Eli Cohen authored and Roland Dreier committed Oct 25, 2010
1 parent be2191c commit 9577a68
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2420b60b1dc4ed98cb1788e928bc57ff2efa1a8d
refs/heads/master: 33c87f0af60146b375220809c1cb745ac1a86edf
15 changes: 12 additions & 3 deletions trunk/drivers/net/mlx4/en_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@ static int mlx4_en_get_profile(struct mlx4_en_dev *mdev)
return 0;
}

static void *mlx4_en_get_netdev(struct mlx4_dev *dev, void *ctx, u8 port)
{
struct mlx4_en_dev *endev = ctx;

return endev->pndev[port];
}

static void mlx4_en_event(struct mlx4_dev *dev, void *endev_ptr,
enum mlx4_dev_event event, int port)
{
Expand Down Expand Up @@ -282,9 +289,11 @@ static void *mlx4_en_add(struct mlx4_dev *dev)
}

static struct mlx4_interface mlx4_en_interface = {
.add = mlx4_en_add,
.remove = mlx4_en_remove,
.event = mlx4_en_event,
.add = mlx4_en_add,
.remove = mlx4_en_remove,
.event = mlx4_en_event,
.get_dev = mlx4_en_get_netdev,
.protocol = MLX4_PROTOCOL_EN,
};

static int __init mlx4_en_init(void)
Expand Down
21 changes: 21 additions & 0 deletions trunk/drivers/net/mlx4/intf.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,24 @@ void mlx4_unregister_device(struct mlx4_dev *dev)

mutex_unlock(&intf_mutex);
}

void *mlx4_get_protocol_dev(struct mlx4_dev *dev, enum mlx4_protocol proto, int port)
{
struct mlx4_priv *priv = mlx4_priv(dev);
struct mlx4_device_context *dev_ctx;
unsigned long flags;
void *result = NULL;

spin_lock_irqsave(&priv->ctx_lock, flags);

list_for_each_entry(dev_ctx, &priv->ctx_list, list)
if (dev_ctx->intf->protocol == proto && dev_ctx->intf->get_dev) {
result = dev_ctx->intf->get_dev(dev, dev_ctx->context, port);
break;
}

spin_unlock_irqrestore(&priv->ctx_lock, flags);

return result;
}
EXPORT_SYMBOL_GPL(mlx4_get_protocol_dev);
9 changes: 9 additions & 0 deletions trunk/include/linux/mlx4/driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,24 @@ enum mlx4_dev_event {
MLX4_DEV_EVENT_PORT_REINIT,
};

enum mlx4_protocol {
MLX4_PROTOCOL_IB,
MLX4_PROTOCOL_EN,
};

struct mlx4_interface {
void * (*add) (struct mlx4_dev *dev);
void (*remove)(struct mlx4_dev *dev, void *context);
void (*event) (struct mlx4_dev *dev, void *context,
enum mlx4_dev_event event, int port);
void * (*get_dev)(struct mlx4_dev *dev, void *context, u8 port);
struct list_head list;
enum mlx4_protocol protocol;
};

int mlx4_register_interface(struct mlx4_interface *intf);
void mlx4_unregister_interface(struct mlx4_interface *intf);

void *mlx4_get_protocol_dev(struct mlx4_dev *dev, enum mlx4_protocol proto, int port);

#endif /* MLX4_DRIVER_H */

0 comments on commit 9577a68

Please sign in to comment.