Skip to content

Commit bb52f42

Browse files
dmertmananguy11
authored andcommitted
ice: Add driver support for firmware changes for LAG
Add the defines, fields, and detection code for FW support of LAG for SRIOV. Also exposes some previously static functions to allow access in the lag code. Clean up code that is unused or not needed for LAG support. Also add an ordered workqueue for processing LAG events. Reviewed-by: Daniel Machon <[email protected]> Signed-off-by: Dave Ertman <[email protected]> Tested-by: Sujai Buvaneswaran <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent f3fbda3 commit bb52f42

File tree

8 files changed

+66
-30
lines changed

8 files changed

+66
-30
lines changed

drivers/net/ethernet/intel/ice/ice.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,8 @@ enum ice_feature {
200200
ICE_F_PTP_EXTTS,
201201
ICE_F_SMA_CTRL,
202202
ICE_F_GNSS,
203+
ICE_F_ROCE_LAG,
204+
ICE_F_SRIOV_LAG,
203205
ICE_F_MAX
204206
};
205207

@@ -569,6 +571,7 @@ struct ice_pf {
569571
struct mutex sw_mutex; /* lock for protecting VSI alloc flow */
570572
struct mutex tc_mutex; /* lock to protect TC changes */
571573
struct mutex adev_mutex; /* lock to protect aux device access */
574+
struct mutex lag_mutex; /* protect ice_lag struct in PF */
572575
u32 msg_enable;
573576
struct ice_ptp ptp;
574577
struct gnss_serial *gnss_serial;
@@ -639,6 +642,8 @@ struct ice_pf {
639642
struct ice_agg_node vf_agg_node[ICE_MAX_VF_AGG_NODES];
640643
};
641644

645+
extern struct workqueue_struct *ice_lag_wq;
646+
642647
struct ice_netdev_priv {
643648
struct ice_vsi *vsi;
644649
struct ice_repr *repr;

drivers/net/ethernet/intel/ice/ice_adminq_cmd.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ struct ice_aqc_list_caps_elem {
120120
#define ICE_AQC_CAPS_PCIE_RESET_AVOIDANCE 0x0076
121121
#define ICE_AQC_CAPS_POST_UPDATE_RESET_RESTRICT 0x0077
122122
#define ICE_AQC_CAPS_NVM_MGMT 0x0080
123+
#define ICE_AQC_CAPS_FW_LAG_SUPPORT 0x0092
124+
#define ICE_AQC_BIT_ROCEV2_LAG 0x01
125+
#define ICE_AQC_BIT_SRIOV_LAG 0x02
123126

124127
u8 major_ver;
125128
u8 minor_ver;

drivers/net/ethernet/intel/ice/ice_common.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2241,6 +2241,14 @@ ice_parse_common_caps(struct ice_hw *hw, struct ice_hw_common_caps *caps,
22412241
"%s: reset_restrict_support = %d\n", prefix,
22422242
caps->reset_restrict_support);
22432243
break;
2244+
case ICE_AQC_CAPS_FW_LAG_SUPPORT:
2245+
caps->roce_lag = !!(number & ICE_AQC_BIT_ROCEV2_LAG);
2246+
ice_debug(hw, ICE_DBG_INIT, "%s: roce_lag = %u\n",
2247+
prefix, caps->roce_lag);
2248+
caps->sriov_lag = !!(number & ICE_AQC_BIT_SRIOV_LAG);
2249+
ice_debug(hw, ICE_DBG_INIT, "%s: sriov_lag = %u\n",
2250+
prefix, caps->sriov_lag);
2251+
break;
22442252
default:
22452253
/* Not one of the recognized common capabilities */
22462254
found = false;

drivers/net/ethernet/intel/ice/ice_lag.c

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@
44
/* Link Aggregation code */
55

66
#include "ice.h"
7+
#include "ice_lib.h"
78
#include "ice_lag.h"
89

10+
#define ICE_LAG_RES_SHARED BIT(14)
11+
#define ICE_LAG_RES_VALID BIT(15)
12+
913
/**
1014
* ice_lag_set_primary - set PF LAG state as Primary
1115
* @lag: LAG info struct
@@ -225,6 +229,26 @@ static void ice_lag_unregister(struct ice_lag *lag, struct net_device *netdev)
225229
lag->role = ICE_LAG_NONE;
226230
}
227231

232+
/**
233+
* ice_lag_init_feature_support_flag - Check for NVM support for LAG
234+
* @pf: PF struct
235+
*/
236+
static void ice_lag_init_feature_support_flag(struct ice_pf *pf)
237+
{
238+
struct ice_hw_common_caps *caps;
239+
240+
caps = &pf->hw.dev_caps.common_cap;
241+
if (caps->roce_lag)
242+
ice_set_feature_support(pf, ICE_F_ROCE_LAG);
243+
else
244+
ice_clear_feature_support(pf, ICE_F_ROCE_LAG);
245+
246+
if (caps->sriov_lag)
247+
ice_set_feature_support(pf, ICE_F_SRIOV_LAG);
248+
else
249+
ice_clear_feature_support(pf, ICE_F_SRIOV_LAG);
250+
}
251+
228252
/**
229253
* ice_lag_changeupper_event - handle LAG changeupper event
230254
* @lag: LAG info struct
@@ -264,26 +288,6 @@ static void ice_lag_changeupper_event(struct ice_lag *lag, void *ptr)
264288
ice_display_lag_info(lag);
265289
}
266290

267-
/**
268-
* ice_lag_changelower_event - handle LAG changelower event
269-
* @lag: LAG info struct
270-
* @ptr: opaque data pointer
271-
*
272-
* ptr to be cast to netdev_notifier_changelowerstate_info
273-
*/
274-
static void ice_lag_changelower_event(struct ice_lag *lag, void *ptr)
275-
{
276-
struct net_device *netdev = netdev_notifier_info_to_dev(ptr);
277-
278-
if (netdev != lag->netdev)
279-
return;
280-
281-
netdev_dbg(netdev, "bonding info\n");
282-
283-
if (!netif_is_lag_port(netdev))
284-
netdev_dbg(netdev, "CHANGELOWER rcvd, but netdev not in LAG. Bail\n");
285-
}
286-
287291
/**
288292
* ice_lag_event_handler - handle LAG events from netdev
289293
* @notif_blk: notifier block registered by this netdev
@@ -310,9 +314,6 @@ ice_lag_event_handler(struct notifier_block *notif_blk, unsigned long event,
310314
case NETDEV_CHANGEUPPER:
311315
ice_lag_changeupper_event(lag, ptr);
312316
break;
313-
case NETDEV_CHANGELOWERSTATE:
314-
ice_lag_changelower_event(lag, ptr);
315-
break;
316317
case NETDEV_BONDING_INFO:
317318
ice_lag_info_event(lag, ptr);
318319
break;
@@ -379,6 +380,8 @@ int ice_init_lag(struct ice_pf *pf)
379380
struct ice_vsi *vsi;
380381
int err;
381382

383+
ice_lag_init_feature_support_flag(pf);
384+
382385
pf->lag = kzalloc(sizeof(*lag), GFP_KERNEL);
383386
if (!pf->lag)
384387
return -ENOMEM;
@@ -435,9 +438,7 @@ void ice_deinit_lag(struct ice_pf *pf)
435438
if (lag->pf)
436439
ice_unregister_lag_handler(lag);
437440

438-
dev_put(lag->upper_netdev);
439-
440-
dev_put(lag->peer_netdev);
441+
flush_workqueue(ice_lag_wq);
441442

442443
kfree(lag);
443444

drivers/net/ethernet/intel/ice/ice_lib.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3970,7 +3970,7 @@ bool ice_is_feature_supported(struct ice_pf *pf, enum ice_feature f)
39703970
* @pf: pointer to the struct ice_pf instance
39713971
* @f: feature enum to set
39723972
*/
3973-
static void ice_set_feature_support(struct ice_pf *pf, enum ice_feature f)
3973+
void ice_set_feature_support(struct ice_pf *pf, enum ice_feature f)
39743974
{
39753975
if (f < 0 || f >= ICE_F_MAX)
39763976
return;

drivers/net/ethernet/intel/ice/ice_lib.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ int ice_vsi_del_vlan_zero(struct ice_vsi *vsi);
163163
bool ice_vsi_has_non_zero_vlans(struct ice_vsi *vsi);
164164
u16 ice_vsi_num_non_zero_vlans(struct ice_vsi *vsi);
165165
bool ice_is_feature_supported(struct ice_pf *pf, enum ice_feature f);
166+
void ice_set_feature_support(struct ice_pf *pf, enum ice_feature f);
166167
void ice_clear_feature_support(struct ice_pf *pf, enum ice_feature f);
167168
void ice_init_feature_support(struct ice_pf *pf);
168169
bool ice_vsi_is_rx_queue_active(struct ice_vsi *vsi);

drivers/net/ethernet/intel/ice/ice_main.c

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ struct device *ice_hw_to_dev(struct ice_hw *hw)
6464
}
6565

6666
static struct workqueue_struct *ice_wq;
67+
struct workqueue_struct *ice_lag_wq;
6768
static const struct net_device_ops ice_netdev_safe_mode_ops;
6869
static const struct net_device_ops ice_netdev_ops;
6970

@@ -3795,6 +3796,7 @@ u16 ice_get_avail_rxq_count(struct ice_pf *pf)
37953796
static void ice_deinit_pf(struct ice_pf *pf)
37963797
{
37973798
ice_service_task_stop(pf);
3799+
mutex_destroy(&pf->lag_mutex);
37983800
mutex_destroy(&pf->adev_mutex);
37993801
mutex_destroy(&pf->sw_mutex);
38003802
mutex_destroy(&pf->tc_mutex);
@@ -3875,6 +3877,7 @@ static int ice_init_pf(struct ice_pf *pf)
38753877
mutex_init(&pf->sw_mutex);
38763878
mutex_init(&pf->tc_mutex);
38773879
mutex_init(&pf->adev_mutex);
3880+
mutex_init(&pf->lag_mutex);
38783881

38793882
INIT_HLIST_HEAD(&pf->aq_wait_list);
38803883
spin_lock_init(&pf->aq_wait_lock);
@@ -5571,23 +5574,35 @@ static struct pci_driver ice_driver = {
55715574
*/
55725575
static int __init ice_module_init(void)
55735576
{
5574-
int status;
5577+
int status = -ENOMEM;
55755578

55765579
pr_info("%s\n", ice_driver_string);
55775580
pr_info("%s\n", ice_copyright);
55785581

55795582
ice_wq = alloc_workqueue("%s", 0, 0, KBUILD_MODNAME);
55805583
if (!ice_wq) {
55815584
pr_err("Failed to create workqueue\n");
5582-
return -ENOMEM;
5585+
return status;
5586+
}
5587+
5588+
ice_lag_wq = alloc_ordered_workqueue("ice_lag_wq", 0);
5589+
if (!ice_lag_wq) {
5590+
pr_err("Failed to create LAG workqueue\n");
5591+
goto err_dest_wq;
55835592
}
55845593

55855594
status = pci_register_driver(&ice_driver);
55865595
if (status) {
55875596
pr_err("failed to register PCI driver, err %d\n", status);
5588-
destroy_workqueue(ice_wq);
5597+
goto err_dest_lag_wq;
55895598
}
55905599

5600+
return 0;
5601+
5602+
err_dest_lag_wq:
5603+
destroy_workqueue(ice_lag_wq);
5604+
err_dest_wq:
5605+
destroy_workqueue(ice_wq);
55915606
return status;
55925607
}
55935608
module_init(ice_module_init);
@@ -5602,6 +5617,7 @@ static void __exit ice_module_exit(void)
56025617
{
56035618
pci_unregister_driver(&ice_driver);
56045619
destroy_workqueue(ice_wq);
5620+
destroy_workqueue(ice_lag_wq);
56055621
pr_info("module unloaded\n");
56065622
}
56075623
module_exit(ice_module_exit);

drivers/net/ethernet/intel/ice/ice_type.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,8 @@ struct ice_hw_common_caps {
277277
u8 dcb;
278278
u8 ieee_1588;
279279
u8 rdma;
280+
u8 roce_lag;
281+
u8 sriov_lag;
280282

281283
bool nvm_update_pending_nvm;
282284
bool nvm_update_pending_orom;

0 commit comments

Comments
 (0)