Skip to content

Commit

Permalink
bnx2x: Add iproute2 support for vfs
Browse files Browse the repository at this point in the history
This patch adds support for iproute2 callbacks allowing querying a physical
function as to its child virtual functions, and setting the macs and vlans
of said virtual functions.

Signed-off-by: Ariel Elior <ariele@broadcom.com>
Signed-off-by: Yuval Mintz <yuvalmin@broadcom.com>
Signed-off-by: Eilon Greenstein <eilong@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Ariel Elior authored and David S. Miller committed Mar 12, 2013
1 parent 3786b94 commit 3ec9f9c
Show file tree
Hide file tree
Showing 8 changed files with 277 additions and 46 deletions.
1 change: 1 addition & 0 deletions drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
Original file line number Diff line number Diff line change
Expand Up @@ -1214,6 +1214,7 @@ enum {
BNX2X_SP_RTNL_ENABLE_SRIOV,
BNX2X_SP_RTNL_VFPF_MCAST,
BNX2X_SP_RTNL_VFPF_STORM_RX_MODE,
BNX2X_SP_RTNL_HYPERVISOR_VLAN,
};


Expand Down
3 changes: 3 additions & 0 deletions drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,10 @@ netdev_tx_t bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev);
/* setup_tc callback */
int bnx2x_setup_tc(struct net_device *dev, u8 num_tc);

int bnx2x_get_vf_config(struct net_device *dev, int vf,
struct ifla_vf_info *ivi);
int bnx2x_set_vf_mac(struct net_device *dev, int queue, u8 *mac);
int bnx2x_set_vf_vlan(struct net_device *netdev, int vf, u16 vlan, u8 qos);

/* select_queue callback */
u16 bnx2x_select_queue(struct net_device *dev, struct sk_buff *skb);
Expand Down
38 changes: 27 additions & 11 deletions drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@
#define FW_FILE_NAME_E1H "bnx2x/bnx2x-e1h-" FW_FILE_VERSION ".fw"
#define FW_FILE_NAME_E2 "bnx2x/bnx2x-e2-" FW_FILE_VERSION ".fw"

#define MAC_LEADING_ZERO_CNT (ALIGN(ETH_ALEN, sizeof(u32)) - ETH_ALEN)

/* Time in jiffies before concluding the transmitter is hung */
#define TX_TIMEOUT (5*HZ)

Expand Down Expand Up @@ -3227,16 +3225,29 @@ static void bnx2x_drv_info_ether_stat(struct bnx2x *bp)
{
struct eth_stats_info *ether_stat =
&bp->slowpath->drv_info_to_mcp.ether_stat;
struct bnx2x_vlan_mac_obj *mac_obj =
&bp->sp_objs->mac_obj;
int i;

strlcpy(ether_stat->version, DRV_MODULE_VERSION,
ETH_STAT_INFO_VERSION_LEN);

bp->sp_objs[0].mac_obj.get_n_elements(bp, &bp->sp_objs[0].mac_obj,
DRV_INFO_ETH_STAT_NUM_MACS_REQUIRED,
ether_stat->mac_local);

/* get DRV_INFO_ETH_STAT_NUM_MACS_REQUIRED macs, placing them in the
* mac_local field in ether_stat struct. The base address is offset by 2
* bytes to account for the field being 8 bytes but a mac address is
* only 6 bytes. Likewise, the stride for the get_n_elements function is
* 2 bytes to compensate from the 6 bytes of a mac to the 8 bytes
* allocated by the ether_stat struct, so the macs will land in their
* proper positions.
*/
for (i = 0; i < DRV_INFO_ETH_STAT_NUM_MACS_REQUIRED; i++)
memset(ether_stat->mac_local + i, 0,
sizeof(ether_stat->mac_local[0]));
mac_obj->get_n_elements(bp, &bp->sp_objs[0].mac_obj,
DRV_INFO_ETH_STAT_NUM_MACS_REQUIRED,
ether_stat->mac_local + MAC_PAD, MAC_PAD,
ETH_ALEN);
ether_stat->mtu_size = bp->dev->mtu;

if (bp->dev->features & NETIF_F_RXCSUM)
ether_stat->feature_flags |= FEATURE_ETH_CHKSUM_OFFLOAD_MASK;
if (bp->dev->features & NETIF_F_TSO)
Expand All @@ -3258,8 +3269,7 @@ static void bnx2x_drv_info_fcoe_stat(struct bnx2x *bp)
if (!CNIC_LOADED(bp))
return;

memcpy(fcoe_stat->mac_local + MAC_LEADING_ZERO_CNT,
bp->fip_mac, ETH_ALEN);
memcpy(fcoe_stat->mac_local + MAC_PAD, bp->fip_mac, ETH_ALEN);

fcoe_stat->qos_priority =
app->traffic_type_priority[LLFC_TRAFFIC_TYPE_FCOE];
Expand Down Expand Up @@ -3361,8 +3371,8 @@ static void bnx2x_drv_info_iscsi_stat(struct bnx2x *bp)
if (!CNIC_LOADED(bp))
return;

memcpy(iscsi_stat->mac_local + MAC_LEADING_ZERO_CNT,
bp->cnic_eth_dev.iscsi_mac, ETH_ALEN);
memcpy(iscsi_stat->mac_local + MAC_PAD, bp->cnic_eth_dev.iscsi_mac,
ETH_ALEN);

iscsi_stat->qos_priority =
app->traffic_type_priority[LLFC_TRAFFIC_TYPE_ISCSI];
Expand Down Expand Up @@ -9525,6 +9535,10 @@ static void bnx2x_sp_rtnl_task(struct work_struct *work)
bnx2x_vfpf_storm_rx_mode(bp);
}

if (test_and_clear_bit(BNX2X_SP_RTNL_HYPERVISOR_VLAN,
&bp->sp_rtnl_state))
bnx2x_pf_set_vfs_vlan(bp);

/* work which needs rtnl lock not-taken (as it takes the lock itself and
* can be called from other contexts as well)
*/
Expand Down Expand Up @@ -11798,6 +11812,8 @@ static const struct net_device_ops bnx2x_netdev_ops = {
.ndo_setup_tc = bnx2x_setup_tc,
#ifdef CONFIG_BNX2X_SRIOV
.ndo_set_vf_mac = bnx2x_set_vf_mac,
.ndo_set_vf_vlan = bnx2x_set_vf_vlan,
.ndo_get_vf_config = bnx2x_get_vf_config,
#endif
#ifdef NETDEV_FCOE_WWNN
.ndo_fcoe_get_wwn = bnx2x_fcoe_get_wwn,
Expand Down
24 changes: 7 additions & 17 deletions drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@

#define BNX2X_MAX_EMUL_MULTI 16

#define MAC_LEADING_ZERO_CNT (ALIGN(ETH_ALEN, sizeof(u32)) - ETH_ALEN)

/**** Exe Queue interfaces ****/

/**
Expand Down Expand Up @@ -444,30 +442,21 @@ static bool bnx2x_put_credit_vlan_mac(struct bnx2x_vlan_mac_obj *o)
}

static int bnx2x_get_n_elements(struct bnx2x *bp, struct bnx2x_vlan_mac_obj *o,
int n, u8 *buf)
int n, u8 *base, u8 stride, u8 size)
{
struct bnx2x_vlan_mac_registry_elem *pos;
u8 *next = buf;
u8 *next = base;
int counter = 0;

/* traverse list */
list_for_each_entry(pos, &o->head, link) {
if (counter < n) {
/* place leading zeroes in buffer */
memset(next, 0, MAC_LEADING_ZERO_CNT);

/* place mac after leading zeroes*/
memcpy(next + MAC_LEADING_ZERO_CNT, pos->u.mac.mac,
ETH_ALEN);

/* calculate address of next element and
* advance counter
*/
memcpy(next, &pos->u, size);
counter++;
next = buf + counter * ALIGN(ETH_ALEN, sizeof(u32));
DP(BNX2X_MSG_SP, "copied element number %d to address %p element was:\n",
counter, next);
next += stride + size;

DP(BNX2X_MSG_SP, "copied element number %d to address %p element was %pM\n",
counter, next, pos->u.mac.mac);
}
}
return counter * ETH_ALEN;
Expand Down Expand Up @@ -2013,6 +2002,7 @@ void bnx2x_init_vlan_obj(struct bnx2x *bp,
vlan_obj->check_move = bnx2x_check_move;
vlan_obj->ramrod_cmd =
RAMROD_CMD_ID_ETH_CLASSIFICATION_RULES;
vlan_obj->get_n_elements = bnx2x_get_n_elements;

/* Exe Queue */
bnx2x_exe_queue_init(bp,
Expand Down
6 changes: 4 additions & 2 deletions drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,9 @@ struct bnx2x_vlan_mac_obj {
*
* @return number of copied bytes
*/
int (*get_n_elements)(struct bnx2x *bp, struct bnx2x_vlan_mac_obj *o,
int n, u8 *buf);
int (*get_n_elements)(struct bnx2x *bp,
struct bnx2x_vlan_mac_obj *o, int n, u8 *base,
u8 stride, u8 size);

/**
* Checks if ADD-ramrod with the given params may be performed.
Expand Down Expand Up @@ -842,6 +843,7 @@ enum bnx2x_q_type {
#define BNX2X_MULTI_TX_COS_E3B0 3
#define BNX2X_MULTI_TX_COS 3 /* Maximum possible */

#define MAC_PAD (ALIGN(ETH_ALEN, sizeof(u32)) - ETH_ALEN)

struct bnx2x_queue_init_params {
struct {
Expand Down
Loading

0 comments on commit 3ec9f9c

Please sign in to comment.