Skip to content

Commit fc1fa5a

Browse files
committed
Merge branch '40GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/next-queue
Tony Nguyen says: ==================== i40e: cleanups & refactors Ivan Vecera says: This series do following: Patch 1 - Removes write-only flags field from i40e_veb structure and from i40e_veb_setup() parameters Patch 2 - Refactors parameter of i40e_notify_client_of_l2_param_changes() and i40e_notify_client_of_netdev_close() Patch 3 - Refactors parameter of i40e_detect_recover_hung() Patch 4 - Adds helper i40e_pf_get_main_vsi() to get main VSI and uses it in existing code Patch 5 - Consolidates checks whether given VSI is the main one Patch 6 - Adds helper i40e_pf_get_main_veb() to get main VEB and uses it in existing code Patch 7 - Adds helper i40e_vsi_reconfig_tc() to reconfigure TC for particular and uses it to replace existing open-coded pieces * '40GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/next-queue: i40e: Add and use helper to reconfigure TC for given VSI i40e: Add helper to access main VEB i40e: Consolidate checks whether given VSI is main i40e: Add helper to access main VSI i40e: Refactor argument of i40e_detect_recover_hung() i40e: Refactor argument of several client notification functions i40e: Remove flags field from i40e_veb ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 86735b5 + 29385de commit fc1fa5a

File tree

10 files changed

+211
-152
lines changed

10 files changed

+211
-152
lines changed

drivers/net/ethernet/intel/i40e/i40e.h

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,6 @@ struct i40e_veb {
788788
u16 stats_idx; /* index of VEB parent */
789789
u8 enabled_tc;
790790
u16 bridge_mode; /* Bridge Mode (VEB/VEPA) */
791-
u16 flags;
792791
u16 bw_limit;
793792
u8 bw_max_quanta;
794793
bool is_abs_credits;
@@ -1213,7 +1212,7 @@ void i40e_vsi_stop_rings(struct i40e_vsi *vsi);
12131212
void i40e_vsi_stop_rings_no_wait(struct i40e_vsi *vsi);
12141213
int i40e_vsi_wait_queues_disabled(struct i40e_vsi *vsi);
12151214
int i40e_reconfig_rss_queues(struct i40e_pf *pf, int queue_count);
1216-
struct i40e_veb *i40e_veb_setup(struct i40e_pf *pf, u16 flags, u16 uplink_seid,
1215+
struct i40e_veb *i40e_veb_setup(struct i40e_pf *pf, u16 uplink_seid,
12171216
u16 downlink_seid, u8 enabled_tc);
12181217
void i40e_veb_release(struct i40e_veb *veb);
12191218

@@ -1237,8 +1236,8 @@ static inline void i40e_dbg_exit(void) {}
12371236
int i40e_lan_add_device(struct i40e_pf *pf);
12381237
int i40e_lan_del_device(struct i40e_pf *pf);
12391238
void i40e_client_subtask(struct i40e_pf *pf);
1240-
void i40e_notify_client_of_l2_param_changes(struct i40e_vsi *vsi);
1241-
void i40e_notify_client_of_netdev_close(struct i40e_vsi *vsi, bool reset);
1239+
void i40e_notify_client_of_l2_param_changes(struct i40e_pf *pf);
1240+
void i40e_notify_client_of_netdev_close(struct i40e_pf *pf, bool reset);
12421241
void i40e_notify_client_of_vf_enable(struct i40e_pf *pf, u32 num_vfs);
12431242
void i40e_notify_client_of_vf_reset(struct i40e_pf *pf, u32 vf_id);
12441243
void i40e_client_update_msix_info(struct i40e_pf *pf);
@@ -1373,6 +1372,17 @@ i40e_pf_get_vsi_by_seid(struct i40e_pf *pf, u16 seid)
13731372
return NULL;
13741373
}
13751374

1375+
/**
1376+
* i40e_pf_get_main_vsi - get pointer to main VSI
1377+
* @pf: pointer to a PF
1378+
*
1379+
* Return: pointer to main VSI or NULL if it does not exist
1380+
**/
1381+
static inline struct i40e_vsi *i40e_pf_get_main_vsi(struct i40e_pf *pf)
1382+
{
1383+
return (pf->lan_vsi != I40E_NO_VSI) ? pf->vsi[pf->lan_vsi] : NULL;
1384+
}
1385+
13761386
/**
13771387
* i40e_pf_get_veb_by_seid - find VEB by SEID
13781388
* @pf: pointer to a PF
@@ -1391,4 +1401,15 @@ i40e_pf_get_veb_by_seid(struct i40e_pf *pf, u16 seid)
13911401
return NULL;
13921402
}
13931403

1404+
/**
1405+
* i40e_pf_get_main_veb - get pointer to main VEB
1406+
* @pf: pointer to a PF
1407+
*
1408+
* Return: pointer to main VEB or NULL if it does not exist
1409+
**/
1410+
static inline struct i40e_veb *i40e_pf_get_main_veb(struct i40e_pf *pf)
1411+
{
1412+
return (pf->lan_veb != I40E_NO_VEB) ? pf->veb[pf->lan_veb] : NULL;
1413+
}
1414+
13941415
#endif /* _I40E_H_ */

drivers/net/ethernet/intel/i40e/i40e_client.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -101,25 +101,26 @@ i40e_notify_client_of_vf_msg(struct i40e_vsi *vsi, u32 vf_id, u8 *msg, u16 len)
101101

102102
/**
103103
* i40e_notify_client_of_l2_param_changes - call the client notify callback
104-
* @vsi: the VSI with l2 param changes
104+
* @pf: PF device pointer
105105
*
106-
* If there is a client to this VSI, call the client
106+
* If there is a client, call its callback
107107
**/
108-
void i40e_notify_client_of_l2_param_changes(struct i40e_vsi *vsi)
108+
void i40e_notify_client_of_l2_param_changes(struct i40e_pf *pf)
109109
{
110-
struct i40e_pf *pf = vsi->back;
110+
struct i40e_vsi *vsi = i40e_pf_get_main_vsi(pf);
111111
struct i40e_client_instance *cdev = pf->cinst;
112112
struct i40e_params params;
113113

114114
if (!cdev || !cdev->client)
115115
return;
116116
if (!cdev->client->ops || !cdev->client->ops->l2_param_change) {
117-
dev_dbg(&vsi->back->pdev->dev,
117+
dev_dbg(&pf->pdev->dev,
118118
"Cannot locate client instance l2_param_change routine\n");
119119
return;
120120
}
121121
if (!test_bit(__I40E_CLIENT_INSTANCE_OPENED, &cdev->state)) {
122-
dev_dbg(&vsi->back->pdev->dev, "Client is not open, abort l2 param change\n");
122+
dev_dbg(&pf->pdev->dev,
123+
"Client is not open, abort l2 param change\n");
123124
return;
124125
}
125126
memset(&params, 0, sizeof(params));
@@ -157,20 +158,19 @@ static void i40e_client_release_qvlist(struct i40e_info *ldev)
157158

158159
/**
159160
* i40e_notify_client_of_netdev_close - call the client close callback
160-
* @vsi: the VSI with netdev closed
161+
* @pf: PF device pointer
161162
* @reset: true when close called due to a reset pending
162163
*
163164
* If there is a client to this netdev, call the client with close
164165
**/
165-
void i40e_notify_client_of_netdev_close(struct i40e_vsi *vsi, bool reset)
166+
void i40e_notify_client_of_netdev_close(struct i40e_pf *pf, bool reset)
166167
{
167-
struct i40e_pf *pf = vsi->back;
168168
struct i40e_client_instance *cdev = pf->cinst;
169169

170170
if (!cdev || !cdev->client)
171171
return;
172172
if (!cdev->client->ops || !cdev->client->ops->close) {
173-
dev_dbg(&vsi->back->pdev->dev,
173+
dev_dbg(&pf->pdev->dev,
174174
"Cannot locate client instance close routine\n");
175175
return;
176176
}
@@ -333,9 +333,9 @@ static int i40e_register_auxiliary_dev(struct i40e_info *ldev, const char *name)
333333
**/
334334
static void i40e_client_add_instance(struct i40e_pf *pf)
335335
{
336+
struct i40e_vsi *vsi = i40e_pf_get_main_vsi(pf);
336337
struct i40e_client_instance *cdev = NULL;
337338
struct netdev_hw_addr *mac = NULL;
338-
struct i40e_vsi *vsi = pf->vsi[pf->lan_vsi];
339339

340340
cdev = kzalloc(sizeof(*cdev), GFP_KERNEL);
341341
if (!cdev)
@@ -399,9 +399,9 @@ void i40e_client_del_instance(struct i40e_pf *pf)
399399
**/
400400
void i40e_client_subtask(struct i40e_pf *pf)
401401
{
402-
struct i40e_client *client;
402+
struct i40e_vsi *vsi = i40e_pf_get_main_vsi(pf);
403403
struct i40e_client_instance *cdev;
404-
struct i40e_vsi *vsi = pf->vsi[pf->lan_vsi];
404+
struct i40e_client *client;
405405
int ret = 0;
406406

407407
if (!test_and_clear_bit(__I40E_CLIENT_SERVICE_REQUESTED, pf->state))
@@ -665,8 +665,8 @@ static int i40e_client_update_vsi_ctxt(struct i40e_info *ldev,
665665
bool is_vf, u32 vf_id,
666666
u32 flag, u32 valid_flag)
667667
{
668+
struct i40e_vsi *vsi = i40e_pf_get_main_vsi(ldev->pf);
668669
struct i40e_pf *pf = ldev->pf;
669-
struct i40e_vsi *vsi = pf->vsi[pf->lan_vsi];
670670
struct i40e_vsi_context ctxt;
671671
bool update = true;
672672
int err;

drivers/net/ethernet/intel/i40e/i40e_ddp.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,8 +407,9 @@ static int i40e_ddp_load(struct net_device *netdev, const u8 *data, size_t size,
407407
**/
408408
static int i40e_ddp_restore(struct i40e_pf *pf)
409409
{
410+
struct i40e_vsi *vsi = i40e_pf_get_main_vsi(pf);
411+
struct net_device *netdev = vsi->netdev;
410412
struct i40e_ddp_old_profile_list *entry;
411-
struct net_device *netdev = pf->vsi[pf->lan_vsi]->netdev;
412413
int status = 0;
413414

414415
if (!list_empty(&pf->ddp_old_prof)) {

drivers/net/ethernet/intel/i40e/i40e_debugfs.c

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ static ssize_t i40e_dbg_command_read(struct file *filp, char __user *buffer,
5353
size_t count, loff_t *ppos)
5454
{
5555
struct i40e_pf *pf = filp->private_data;
56+
struct i40e_vsi *main_vsi;
5657
int bytes_not_copied;
5758
int buf_size = 256;
5859
char *buf;
@@ -68,8 +69,8 @@ static ssize_t i40e_dbg_command_read(struct file *filp, char __user *buffer,
6869
if (!buf)
6970
return -ENOSPC;
7071

71-
len = snprintf(buf, buf_size, "%s: %s\n",
72-
pf->vsi[pf->lan_vsi]->netdev->name,
72+
main_vsi = i40e_pf_get_main_vsi(pf);
73+
len = snprintf(buf, buf_size, "%s: %s\n", main_vsi->netdev->name,
7374
i40e_dbg_command_buf);
7475

7576
bytes_not_copied = copy_to_user(buffer, buf, len);
@@ -128,7 +129,7 @@ static void i40e_dbg_dump_vsi_seid(struct i40e_pf *pf, int seid)
128129
dev_info(&pf->pdev->dev,
129130
" state[%d] = %08lx\n",
130131
i, vsi->state[i]);
131-
if (vsi == pf->vsi[pf->lan_vsi])
132+
if (vsi->type == I40E_VSI_MAIN)
132133
dev_info(&pf->pdev->dev, " MAC address: %pM Port MAC: %pM\n",
133134
pf->hw.mac.addr,
134135
pf->hw.mac.port_addr);
@@ -786,7 +787,8 @@ static ssize_t i40e_dbg_command_write(struct file *filp,
786787
cnt = sscanf(&cmd_buf[7], "%i", &vsi_seid);
787788
if (cnt == 0) {
788789
/* default to PF VSI */
789-
vsi_seid = pf->vsi[pf->lan_vsi]->seid;
790+
vsi = i40e_pf_get_main_vsi(pf);
791+
vsi_seid = vsi->seid;
790792
} else if (vsi_seid < 0) {
791793
dev_info(&pf->pdev->dev, "add VSI %d: bad vsi seid\n",
792794
vsi_seid);
@@ -867,7 +869,7 @@ static ssize_t i40e_dbg_command_write(struct file *filp,
867869
goto command_write_done;
868870
}
869871

870-
veb = i40e_veb_setup(pf, 0, uplink_seid, vsi_seid, enabled_tc);
872+
veb = i40e_veb_setup(pf, uplink_seid, vsi_seid, enabled_tc);
871873
if (veb)
872874
dev_info(&pf->pdev->dev, "added relay %d\n", veb->seid);
873875
else
@@ -1030,7 +1032,7 @@ static ssize_t i40e_dbg_command_write(struct file *filp,
10301032
goto command_write_done;
10311033
}
10321034

1033-
vsi = pf->vsi[pf->lan_vsi];
1035+
vsi = i40e_pf_get_main_vsi(pf);
10341036
switch_id =
10351037
le16_to_cpu(vsi->info.switch_id) &
10361038
I40E_AQ_VSI_SW_ID_MASK;
@@ -1380,6 +1382,9 @@ static ssize_t i40e_dbg_command_write(struct file *filp,
13801382
dev_info(&pf->pdev->dev, "FD current total filter count for this interface: %d\n",
13811383
i40e_get_current_fd_count(pf));
13821384
} else if (strncmp(cmd_buf, "lldp", 4) == 0) {
1385+
/* Get main VSI */
1386+
struct i40e_vsi *main_vsi = i40e_pf_get_main_vsi(pf);
1387+
13831388
if (strncmp(&cmd_buf[5], "stop", 4) == 0) {
13841389
int ret;
13851390

@@ -1391,10 +1396,9 @@ static ssize_t i40e_dbg_command_write(struct file *filp,
13911396
goto command_write_done;
13921397
}
13931398
ret = i40e_aq_add_rem_control_packet_filter(&pf->hw,
1394-
pf->hw.mac.addr,
1395-
ETH_P_LLDP, 0,
1396-
pf->vsi[pf->lan_vsi]->seid,
1397-
0, true, NULL, NULL);
1399+
pf->hw.mac.addr, ETH_P_LLDP, 0,
1400+
main_vsi->seid, 0, true, NULL,
1401+
NULL);
13981402
if (ret) {
13991403
dev_info(&pf->pdev->dev,
14001404
"%s: Add Control Packet Filter AQ command failed =0x%x\n",
@@ -1409,10 +1413,9 @@ static ssize_t i40e_dbg_command_write(struct file *filp,
14091413
int ret;
14101414

14111415
ret = i40e_aq_add_rem_control_packet_filter(&pf->hw,
1412-
pf->hw.mac.addr,
1413-
ETH_P_LLDP, 0,
1414-
pf->vsi[pf->lan_vsi]->seid,
1415-
0, false, NULL, NULL);
1416+
pf->hw.mac.addr, ETH_P_LLDP, 0,
1417+
main_vsi->seid, 0, false, NULL,
1418+
NULL);
14161419
if (ret) {
14171420
dev_info(&pf->pdev->dev,
14181421
"%s: Remove Control Packet Filter AQ command failed =0x%x\n",
@@ -1639,6 +1642,7 @@ static ssize_t i40e_dbg_netdev_ops_read(struct file *filp, char __user *buffer,
16391642
size_t count, loff_t *ppos)
16401643
{
16411644
struct i40e_pf *pf = filp->private_data;
1645+
struct i40e_vsi *main_vsi;
16421646
int bytes_not_copied;
16431647
int buf_size = 256;
16441648
char *buf;
@@ -1654,8 +1658,8 @@ static ssize_t i40e_dbg_netdev_ops_read(struct file *filp, char __user *buffer,
16541658
if (!buf)
16551659
return -ENOSPC;
16561660

1657-
len = snprintf(buf, buf_size, "%s: %s\n",
1658-
pf->vsi[pf->lan_vsi]->netdev->name,
1661+
main_vsi = i40e_pf_get_main_vsi(pf);
1662+
len = snprintf(buf, buf_size, "%s: %s\n", main_vsi->netdev->name,
16591663
i40e_dbg_netdev_ops_buf);
16601664

16611665
bytes_not_copied = copy_to_user(buffer, buf, len);

drivers/net/ethernet/intel/i40e/i40e_ethtool.c

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,7 +1241,7 @@ static int i40e_set_link_ksettings(struct net_device *netdev,
12411241
i40e_partition_setting_complaint(pf);
12421242
return -EOPNOTSUPP;
12431243
}
1244-
if (vsi != pf->vsi[pf->lan_vsi])
1244+
if (vsi->type != I40E_VSI_MAIN)
12451245
return -EOPNOTSUPP;
12461246
if (hw->phy.media_type != I40E_MEDIA_TYPE_BASET &&
12471247
hw->phy.media_type != I40E_MEDIA_TYPE_FIBER &&
@@ -1710,7 +1710,7 @@ static int i40e_set_pauseparam(struct net_device *netdev,
17101710
return -EOPNOTSUPP;
17111711
}
17121712

1713-
if (vsi != pf->vsi[pf->lan_vsi])
1713+
if (vsi->type != I40E_VSI_MAIN)
17141714
return -EOPNOTSUPP;
17151715

17161716
is_an = hw_link_info->an_info & I40E_AQ_AN_COMPLETED;
@@ -2029,7 +2029,7 @@ static void i40e_get_ringparam(struct net_device *netdev,
20292029
{
20302030
struct i40e_netdev_priv *np = netdev_priv(netdev);
20312031
struct i40e_pf *pf = np->vsi->back;
2032-
struct i40e_vsi *vsi = pf->vsi[pf->lan_vsi];
2032+
struct i40e_vsi *vsi = i40e_pf_get_main_vsi(pf);
20332033

20342034
ring->rx_max_pending = i40e_get_max_num_descriptors(pf);
20352035
ring->tx_max_pending = i40e_get_max_num_descriptors(pf);
@@ -2292,7 +2292,7 @@ static int i40e_get_stats_count(struct net_device *netdev)
22922292
struct i40e_pf *pf = vsi->back;
22932293
int stats_len;
22942294

2295-
if (vsi == pf->vsi[pf->lan_vsi] && pf->hw.partition_id == 1)
2295+
if (vsi->type == I40E_VSI_MAIN && pf->hw.partition_id == 1)
22962296
stats_len = I40E_PF_STATS_LEN;
22972297
else
22982298
stats_len = I40E_VSI_STATS_LEN;
@@ -2422,17 +2422,14 @@ static void i40e_get_ethtool_stats(struct net_device *netdev,
24222422
}
24232423
rcu_read_unlock();
24242424

2425-
if (vsi != pf->vsi[pf->lan_vsi] || pf->hw.partition_id != 1)
2425+
if (vsi->type != I40E_VSI_MAIN || pf->hw.partition_id != 1)
24262426
goto check_data_pointer;
24272427

2428-
veb_stats = ((pf->lan_veb != I40E_NO_VEB) &&
2429-
(pf->lan_veb < I40E_MAX_VEB) &&
2430-
test_bit(I40E_FLAG_VEB_STATS_ENA, pf->flags));
2428+
veb = i40e_pf_get_main_veb(pf);
2429+
veb_stats = veb && test_bit(I40E_FLAG_VEB_STATS_ENA, pf->flags);
24312430

2432-
if (veb_stats) {
2433-
veb = pf->veb[pf->lan_veb];
2431+
if (veb_stats)
24342432
i40e_update_veb_stats(veb);
2435-
}
24362433

24372434
/* If veb stats aren't enabled, pass NULL instead of the veb so that
24382435
* we initialize stats to zero and update the data pointer
@@ -2495,7 +2492,7 @@ static void i40e_get_stat_strings(struct net_device *netdev, u8 *data)
24952492
"rx", i);
24962493
}
24972494

2498-
if (vsi != pf->vsi[pf->lan_vsi] || pf->hw.partition_id != 1)
2495+
if (vsi->type != I40E_VSI_MAIN || pf->hw.partition_id != 1)
24992496
goto check_data_pointer;
25002497

25012498
i40e_add_stat_strings(&data, i40e_gstrings_veb_stats);
@@ -2792,7 +2789,7 @@ static int i40e_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
27922789
return -EOPNOTSUPP;
27932790
}
27942791

2795-
if (vsi != pf->vsi[pf->lan_vsi])
2792+
if (vsi->type != I40E_VSI_MAIN)
27962793
return -EOPNOTSUPP;
27972794

27982795
/* NVM bit on means WoL disabled for the port */
@@ -3370,6 +3367,7 @@ static int i40e_get_ethtool_fdir_entry(struct i40e_pf *pf,
33703367
struct i40e_rx_flow_userdef userdef = {0};
33713368
struct i40e_fdir_filter *rule = NULL;
33723369
struct hlist_node *node2;
3370+
struct i40e_vsi *vsi;
33733371
u64 input_set;
33743372
u16 index;
33753373

@@ -3493,9 +3491,8 @@ static int i40e_get_ethtool_fdir_entry(struct i40e_pf *pf,
34933491
fsp->flow_type |= FLOW_EXT;
34943492
}
34953493

3496-
if (rule->dest_vsi != pf->vsi[pf->lan_vsi]->id) {
3497-
struct i40e_vsi *vsi;
3498-
3494+
vsi = i40e_pf_get_main_vsi(pf);
3495+
if (rule->dest_vsi != vsi->id) {
34993496
vsi = i40e_find_vsi_from_id(pf, rule->dest_vsi);
35003497
if (vsi && vsi->type == I40E_VSI_SRIOV) {
35013498
/* VFs are zero-indexed by the driver, but ethtool

0 commit comments

Comments
 (0)