Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 266188
b: refs/heads/master
c: 889d13f
h: refs/heads/master
v: v3
  • Loading branch information
Roopa Prabhu authored and David S. Miller committed Sep 27, 2011
1 parent a3856c2 commit ccde2cb
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 6 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: 8749b427f213e14303dfef4c1b9770f05f67916d
refs/heads/master: 889d13f53cf9d741398637b6e8e578c65bb792e8
1 change: 1 addition & 0 deletions trunk/drivers/net/ethernet/cisco/enic/enic.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,5 +129,6 @@ static inline struct device *enic_get_dev(struct enic *enic)

void enic_reset_addr_lists(struct enic *enic);
int enic_sriov_enabled(struct enic *enic);
int enic_is_valid_vf(struct enic *enic, int vf);

#endif /* _ENIC_H_ */
19 changes: 19 additions & 0 deletions trunk/drivers/net/ethernet/cisco/enic/enic_dev.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,25 @@
#ifndef _ENIC_DEV_H_
#define _ENIC_DEV_H_

#include "vnic_dev.h"

/*
* Calls the devcmd function given by argument vnicdevcmdfn.
* If vf argument is valid, it proxies the devcmd
*/
#define ENIC_DEVCMD_PROXY_BY_INDEX(vf, err, enic, vnicdevcmdfn, ...) \
do { \
spin_lock(&enic->devcmd_lock); \
if (enic_is_valid_vf(enic, vf)) { \
vnic_dev_cmd_proxy_by_index_start(enic->vdev, vf); \
err = vnicdevcmdfn(enic->vdev, ##__VA_ARGS__); \
vnic_dev_cmd_proxy_end(enic->vdev); \
} else { \
err = vnicdevcmdfn(enic->vdev, ##__VA_ARGS__); \
} \
spin_unlock(&enic->devcmd_lock); \
} while (0)

int enic_dev_fw_info(struct enic *enic, struct vnic_devcmd_fw_info **fw_info);
int enic_dev_stats_dump(struct enic *enic, struct vnic_stats **vstats);
int enic_dev_add_station_addr(struct enic *enic);
Expand Down
9 changes: 9 additions & 0 deletions trunk/drivers/net/ethernet/cisco/enic/enic_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,15 @@ int enic_sriov_enabled(struct enic *enic)
return (enic->priv_flags & ENIC_SRIOV_ENABLED) ? 1 : 0;
}

int enic_is_valid_vf(struct enic *enic, int vf)
{
#ifdef CONFIG_PCI_IOV
return vf >= 0 && vf < enic->num_vfs;
#else
return 0;
#endif
}

static inline unsigned int enic_cq_rq(struct enic *enic, unsigned int rq)
{
return rq;
Expand Down
28 changes: 23 additions & 5 deletions trunk/drivers/net/ethernet/cisco/enic/vnic_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
enum vnic_proxy_type {
PROXY_NONE,
PROXY_BY_BDF,
PROXY_BY_INDEX,
};

struct vnic_res {
Expand Down Expand Up @@ -328,20 +329,21 @@ static int _vnic_dev_cmd(struct vnic_dev *vdev, enum vnic_devcmd_cmd cmd,
return -ETIMEDOUT;
}

static int vnic_dev_cmd_proxy_by_bdf(struct vnic_dev *vdev,
enum vnic_devcmd_cmd cmd, u64 *a0, u64 *a1, int wait)
static int vnic_dev_cmd_proxy(struct vnic_dev *vdev,
enum vnic_devcmd_cmd proxy_cmd, enum vnic_devcmd_cmd cmd,
u64 *a0, u64 *a1, int wait)
{
u32 status;
int err;

memset(vdev->args, 0, sizeof(vdev->args));

vdev->args[0] = vdev->proxy_index; /* bdf */
vdev->args[0] = vdev->proxy_index;
vdev->args[1] = cmd;
vdev->args[2] = *a0;
vdev->args[3] = *a1;

err = _vnic_dev_cmd(vdev, CMD_PROXY_BY_BDF, wait);
err = _vnic_dev_cmd(vdev, proxy_cmd, wait);
if (err)
return err;

Expand Down Expand Up @@ -376,14 +378,30 @@ static int vnic_dev_cmd_no_proxy(struct vnic_dev *vdev,
return err;
}

void vnic_dev_cmd_proxy_by_index_start(struct vnic_dev *vdev, u16 index)
{
vdev->proxy = PROXY_BY_INDEX;
vdev->proxy_index = index;
}

void vnic_dev_cmd_proxy_end(struct vnic_dev *vdev)
{
vdev->proxy = PROXY_NONE;
vdev->proxy_index = 0;
}

int vnic_dev_cmd(struct vnic_dev *vdev, enum vnic_devcmd_cmd cmd,
u64 *a0, u64 *a1, int wait)
{
memset(vdev->args, 0, sizeof(vdev->args));

switch (vdev->proxy) {
case PROXY_BY_INDEX:
return vnic_dev_cmd_proxy(vdev, CMD_PROXY_BY_INDEX, cmd,
a0, a1, wait);
case PROXY_BY_BDF:
return vnic_dev_cmd_proxy_by_bdf(vdev, cmd, a0, a1, wait);
return vnic_dev_cmd_proxy(vdev, CMD_PROXY_BY_BDF, cmd,
a0, a1, wait);
case PROXY_NONE:
default:
return vnic_dev_cmd_no_proxy(vdev, cmd, a0, a1, wait);
Expand Down
2 changes: 2 additions & 0 deletions trunk/drivers/net/ethernet/cisco/enic/vnic_dev.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ void vnic_dev_free_desc_ring(struct vnic_dev *vdev,
struct vnic_dev_ring *ring);
int vnic_dev_cmd(struct vnic_dev *vdev, enum vnic_devcmd_cmd cmd,
u64 *a0, u64 *a1, int wait);
void vnic_dev_cmd_proxy_by_index_start(struct vnic_dev *vdev, u16 index);
void vnic_dev_cmd_proxy_end(struct vnic_dev *vdev);
int vnic_dev_fw_info(struct vnic_dev *vdev,
struct vnic_devcmd_fw_info **fw_info);
int vnic_dev_spec(struct vnic_dev *vdev, unsigned int offset, unsigned int size,
Expand Down

0 comments on commit ccde2cb

Please sign in to comment.