Skip to content

Commit 5bd36a6

Browse files
committed
Merge branch 'sfc-physical-port-ids'
Edward Cree says: ==================== sfc: physical port ids This series brings our handling of ndo_get_phys_port_id and related interfaces into line with the behaviour of other drivers. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 79f664e + 0d71a84 commit 5bd36a6

File tree

7 files changed

+42
-37
lines changed

7 files changed

+42
-37
lines changed

drivers/net/ethernet/sfc/ef10.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,6 @@ static DEVICE_ATTR(primary_flag, 0444, efx_ef10_show_primary_flag, NULL);
547547
static int efx_ef10_probe(struct efx_nic *efx)
548548
{
549549
struct efx_ef10_nic_data *nic_data;
550-
struct net_device *net_dev = efx->net_dev;
551550
int i, rc;
552551

553552
/* We can have one VI for each 8K region. However, until we
@@ -637,7 +636,6 @@ static int efx_ef10_probe(struct efx_nic *efx)
637636
if (rc < 0)
638637
goto fail5;
639638
efx->port_num = rc;
640-
net_dev->dev_port = rc;
641639

642640
rc = efx->type->get_mac_address(efx, efx->net_dev->perm_addr);
643641
if (rc)
@@ -5540,6 +5538,20 @@ static int efx_ef10_ptp_set_ts_config(struct efx_nic *efx,
55405538
}
55415539
}
55425540

5541+
static int efx_ef10_get_phys_port_id(struct efx_nic *efx,
5542+
struct netdev_phys_item_id *ppid)
5543+
{
5544+
struct efx_ef10_nic_data *nic_data = efx->nic_data;
5545+
5546+
if (!is_valid_ether_addr(nic_data->port_id))
5547+
return -EOPNOTSUPP;
5548+
5549+
ppid->id_len = ETH_ALEN;
5550+
memcpy(ppid->id, nic_data->port_id, ppid->id_len);
5551+
5552+
return 0;
5553+
}
5554+
55435555
static int efx_ef10_vlan_rx_add_vid(struct efx_nic *efx, __be16 proto, u16 vid)
55445556
{
55455557
if (proto != htons(ETH_P_8021Q))
@@ -5647,11 +5659,11 @@ const struct efx_nic_type efx_hunt_a0_vf_nic_type = {
56475659
.vswitching_probe = efx_ef10_vswitching_probe_vf,
56485660
.vswitching_restore = efx_ef10_vswitching_restore_vf,
56495661
.vswitching_remove = efx_ef10_vswitching_remove_vf,
5650-
.sriov_get_phys_port_id = efx_ef10_sriov_get_phys_port_id,
56515662
#endif
56525663
.get_mac_address = efx_ef10_get_mac_address_vf,
56535664
.set_mac_address = efx_ef10_set_mac_address,
56545665

5666+
.get_phys_port_id = efx_ef10_get_phys_port_id,
56555667
.revision = EFX_REV_HUNT_A0,
56565668
.max_dma_mask = DMA_BIT_MASK(ESF_DZ_TX_KER_BUF_ADDR_WIDTH),
56575669
.rx_prefix_size = ES_DZ_RX_PREFIX_SIZE,
@@ -5776,6 +5788,7 @@ const struct efx_nic_type efx_hunt_a0_nic_type = {
57765788
.set_mac_address = efx_ef10_set_mac_address,
57775789
.tso_versions = efx_ef10_tso_versions,
57785790

5791+
.get_phys_port_id = efx_ef10_get_phys_port_id,
57795792
.revision = EFX_REV_HUNT_A0,
57805793
.max_dma_mask = DMA_BIT_MASK(ESF_DZ_TX_KER_BUF_ADDR_WIDTH),
57815794
.rx_prefix_size = ES_DZ_RX_PREFIX_SIZE,

drivers/net/ethernet/sfc/ef10_sriov.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -760,17 +760,3 @@ int efx_ef10_sriov_get_vf_config(struct efx_nic *efx, int vf_i,
760760

761761
return 0;
762762
}
763-
764-
int efx_ef10_sriov_get_phys_port_id(struct efx_nic *efx,
765-
struct netdev_phys_item_id *ppid)
766-
{
767-
struct efx_ef10_nic_data *nic_data = efx->nic_data;
768-
769-
if (!is_valid_ether_addr(nic_data->port_id))
770-
return -EOPNOTSUPP;
771-
772-
ppid->id_len = ETH_ALEN;
773-
memcpy(ppid->id, nic_data->port_id, ppid->id_len);
774-
775-
return 0;
776-
}

drivers/net/ethernet/sfc/ef10_sriov.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@ int efx_ef10_sriov_get_vf_config(struct efx_nic *efx, int vf_i,
5656
int efx_ef10_sriov_set_vf_link_state(struct efx_nic *efx, int vf_i,
5757
int link_state);
5858

59-
int efx_ef10_sriov_get_phys_port_id(struct efx_nic *efx,
60-
struct netdev_phys_item_id *ppid);
61-
6259
int efx_ef10_vswitching_probe_pf(struct efx_nic *efx);
6360
int efx_ef10_vswitching_probe_vf(struct efx_nic *efx);
6461
int efx_ef10_vswitching_restore_pf(struct efx_nic *efx);

drivers/net/ethernet/sfc/efx.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2334,6 +2334,27 @@ static int efx_set_features(struct net_device *net_dev, netdev_features_t data)
23342334
return 0;
23352335
}
23362336

2337+
int efx_get_phys_port_id(struct net_device *net_dev,
2338+
struct netdev_phys_item_id *ppid)
2339+
{
2340+
struct efx_nic *efx = netdev_priv(net_dev);
2341+
2342+
if (efx->type->get_phys_port_id)
2343+
return efx->type->get_phys_port_id(efx, ppid);
2344+
else
2345+
return -EOPNOTSUPP;
2346+
}
2347+
2348+
static int efx_get_phys_port_name(struct net_device *net_dev,
2349+
char *name, size_t len)
2350+
{
2351+
struct efx_nic *efx = netdev_priv(net_dev);
2352+
2353+
if (snprintf(name, len, "p%u", efx->port_num) >= len)
2354+
return -EINVAL;
2355+
return 0;
2356+
}
2357+
23372358
static int efx_vlan_rx_add_vid(struct net_device *net_dev, __be16 proto, u16 vid)
23382359
{
23392360
struct efx_nic *efx = netdev_priv(net_dev);
@@ -2374,8 +2395,9 @@ static const struct net_device_ops efx_netdev_ops = {
23742395
.ndo_set_vf_spoofchk = efx_sriov_set_vf_spoofchk,
23752396
.ndo_get_vf_config = efx_sriov_get_vf_config,
23762397
.ndo_set_vf_link_state = efx_sriov_set_vf_link_state,
2377-
.ndo_get_phys_port_id = efx_sriov_get_phys_port_id,
23782398
#endif
2399+
.ndo_get_phys_port_id = efx_get_phys_port_id,
2400+
.ndo_get_phys_port_name = efx_get_phys_port_name,
23792401
#ifdef CONFIG_NET_POLL_CONTROLLER
23802402
.ndo_poll_controller = efx_netpoll,
23812403
#endif

drivers/net/ethernet/sfc/net_driver.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,6 +1220,7 @@ struct efx_mtd_partition {
12201220
* @ptp_set_ts_config: Set hardware timestamp configuration. The flags
12211221
* and tx_type will already have been validated but this operation
12221222
* must validate and update rx_filter.
1223+
* @get_phys_port_id: Get the underlying physical port id.
12231224
* @set_mac_address: Set the MAC address of the device
12241225
* @tso_versions: Returns mask of firmware-assisted TSO versions supported.
12251226
* If %NULL, then device does not support any TSO version.
@@ -1358,6 +1359,8 @@ struct efx_nic_type {
13581359
int (*sriov_configure)(struct efx_nic *efx, int num_vfs);
13591360
int (*vlan_rx_add_vid)(struct efx_nic *efx, __be16 proto, u16 vid);
13601361
int (*vlan_rx_kill_vid)(struct efx_nic *efx, __be16 proto, u16 vid);
1362+
int (*get_phys_port_id)(struct efx_nic *efx,
1363+
struct netdev_phys_item_id *ppid);
13611364
int (*sriov_init)(struct efx_nic *efx);
13621365
void (*sriov_fini)(struct efx_nic *efx);
13631366
bool (*sriov_wanted)(struct efx_nic *efx);
@@ -1372,8 +1375,6 @@ struct efx_nic_type {
13721375
struct ifla_vf_info *ivi);
13731376
int (*sriov_set_vf_link_state)(struct efx_nic *efx, int vf_i,
13741377
int link_state);
1375-
int (*sriov_get_phys_port_id)(struct efx_nic *efx,
1376-
struct netdev_phys_item_id *ppid);
13771378
int (*vswitching_probe)(struct efx_nic *efx);
13781379
int (*vswitching_restore)(struct efx_nic *efx);
13791380
void (*vswitching_remove)(struct efx_nic *efx);

drivers/net/ethernet/sfc/sriov.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,3 @@ int efx_sriov_set_vf_link_state(struct net_device *net_dev, int vf_i,
7373
else
7474
return -EOPNOTSUPP;
7575
}
76-
77-
int efx_sriov_get_phys_port_id(struct net_device *net_dev,
78-
struct netdev_phys_item_id *ppid)
79-
{
80-
struct efx_nic *efx = netdev_priv(net_dev);
81-
82-
if (efx->type->sriov_get_phys_port_id)
83-
return efx->type->sriov_get_phys_port_id(efx, ppid);
84-
else
85-
return -EOPNOTSUPP;
86-
}

drivers/net/ethernet/sfc/sriov.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ int efx_sriov_get_vf_config(struct net_device *net_dev, int vf_i,
2323
struct ifla_vf_info *ivi);
2424
int efx_sriov_set_vf_link_state(struct net_device *net_dev, int vf_i,
2525
int link_state);
26-
int efx_sriov_get_phys_port_id(struct net_device *net_dev,
27-
struct netdev_phys_item_id *ppid);
28-
2926
#endif /* CONFIG_SFC_SRIOV */
3027

3128
#endif /* EFX_SRIOV_H */

0 commit comments

Comments
 (0)