Skip to content

Commit e0cdac6

Browse files
Nirranjan Kirubaharandavem330
authored andcommitted
cxgb4vf: configure ports accessible by the VF
Find ports accessible by the VF, based on the index of the mac address stored for the VF in the adapter. If no mac address is stored for the VF, use the port mask provided by firmware. Signed-off-by: Nirranjan Kirubaharan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent b007def commit e0cdac6

File tree

3 files changed

+43
-12
lines changed

3 files changed

+43
-12
lines changed

drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2916,6 +2916,39 @@ static const struct net_device_ops cxgb4vf_netdev_ops = {
29162916
#endif
29172917
};
29182918

2919+
/**
2920+
* cxgb4vf_get_port_mask - Get port mask for the VF based on mac
2921+
* address stored on the adapter
2922+
* @adapter: The adapter
2923+
*
2924+
* Find the the port mask for the VF based on the index of mac
2925+
* address stored in the adapter. If no mac address is stored on
2926+
* the adapter for the VF, use the port mask received from the
2927+
* firmware.
2928+
*/
2929+
static unsigned int cxgb4vf_get_port_mask(struct adapter *adapter)
2930+
{
2931+
unsigned int naddr = 1, pidx = 0;
2932+
unsigned int pmask, rmask = 0;
2933+
u8 mac[ETH_ALEN];
2934+
int err;
2935+
2936+
pmask = adapter->params.vfres.pmask;
2937+
while (pmask) {
2938+
if (pmask & 1) {
2939+
err = t4vf_get_vf_mac_acl(adapter, pidx, &naddr, mac);
2940+
if (!err && !is_zero_ether_addr(mac))
2941+
rmask |= (1 << pidx);
2942+
}
2943+
pmask >>= 1;
2944+
pidx++;
2945+
}
2946+
if (!rmask)
2947+
rmask = adapter->params.vfres.pmask;
2948+
2949+
return rmask;
2950+
}
2951+
29192952
/*
29202953
* "Probe" a device: initialize a device and construct all kernel and driver
29212954
* state needed to manage the device. This routine is called "init_one" in
@@ -2924,13 +2957,12 @@ static const struct net_device_ops cxgb4vf_netdev_ops = {
29242957
static int cxgb4vf_pci_probe(struct pci_dev *pdev,
29252958
const struct pci_device_id *ent)
29262959
{
2927-
int pci_using_dac;
2928-
int err, pidx;
2929-
unsigned int pmask;
29302960
struct adapter *adapter;
2931-
struct port_info *pi;
29322961
struct net_device *netdev;
2933-
unsigned int pf;
2962+
struct port_info *pi;
2963+
unsigned int pmask;
2964+
int pci_using_dac;
2965+
int err, pidx;
29342966

29352967
/*
29362968
* Initialize generic PCI device state.
@@ -3073,8 +3105,7 @@ static int cxgb4vf_pci_probe(struct pci_dev *pdev,
30733105
/*
30743106
* Allocate our "adapter ports" and stitch everything together.
30753107
*/
3076-
pmask = adapter->params.vfres.pmask;
3077-
pf = t4vf_get_pf_from_vf(adapter);
3108+
pmask = cxgb4vf_get_port_mask(adapter);
30783109
for_each_port(adapter, pidx) {
30793110
int port_id, viid;
30803111
u8 mac[ETH_ALEN];
@@ -3157,7 +3188,7 @@ static int cxgb4vf_pci_probe(struct pci_dev *pdev,
31573188
goto err_free_dev;
31583189
}
31593190

3160-
err = t4vf_get_vf_mac_acl(adapter, pf, &naddr, mac);
3191+
err = t4vf_get_vf_mac_acl(adapter, port_id, &naddr, mac);
31613192
if (err) {
31623193
dev_err(&pdev->dev,
31633194
"unable to determine MAC ACL address, "

drivers/net/ethernet/chelsio/cxgb4vf/t4vf_common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ int t4vf_eth_eq_free(struct adapter *, unsigned int);
415415
int t4vf_update_port_info(struct port_info *pi);
416416
int t4vf_handle_fw_rpl(struct adapter *, const __be64 *);
417417
int t4vf_prep_adapter(struct adapter *);
418-
int t4vf_get_vf_mac_acl(struct adapter *adapter, unsigned int pf,
418+
int t4vf_get_vf_mac_acl(struct adapter *adapter, unsigned int port,
419419
unsigned int *naddr, u8 *addr);
420420
int t4vf_get_vf_vlan_acl(struct adapter *adapter);
421421

drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2187,14 +2187,14 @@ int t4vf_prep_adapter(struct adapter *adapter)
21872187
* t4vf_get_vf_mac_acl - Get the MAC address to be set to
21882188
* the VI of this VF.
21892189
* @adapter: The adapter
2190-
* @pf: The pf associated with vf
2190+
* @port: The port associated with vf
21912191
* @naddr: the number of ACL MAC addresses returned in addr
21922192
* @addr: Placeholder for MAC addresses
21932193
*
21942194
* Find the MAC address to be set to the VF's VI. The requested MAC address
21952195
* is from the host OS via callback in the PF driver.
21962196
*/
2197-
int t4vf_get_vf_mac_acl(struct adapter *adapter, unsigned int pf,
2197+
int t4vf_get_vf_mac_acl(struct adapter *adapter, unsigned int port,
21982198
unsigned int *naddr, u8 *addr)
21992199
{
22002200
struct fw_acl_mac_cmd cmd;
@@ -2212,7 +2212,7 @@ int t4vf_get_vf_mac_acl(struct adapter *adapter, unsigned int pf,
22122212
if (cmd.nmac < *naddr)
22132213
*naddr = cmd.nmac;
22142214

2215-
switch (pf) {
2215+
switch (port) {
22162216
case 3:
22172217
memcpy(addr, cmd.macaddr3, sizeof(cmd.macaddr3));
22182218
break;

0 commit comments

Comments
 (0)