Skip to content

Commit 7c71086

Browse files
refactormanJeff Kirsher
authored andcommitted
ice: Add handlers for VF netdevice operations
This patch implements handlers for the following NDO operations: .ndo_set_vf_spoofchk .ndo_set_vf_mac .ndo_get_vf_config .ndo_set_vf_trust .ndo_set_vf_vlan .ndo_set_vf_link_state Signed-off-by: Anirudh Venkataramanan <[email protected]> Tested-by: Andrew Bowers <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent 007676b commit 7c71086

File tree

6 files changed

+629
-1
lines changed

6 files changed

+629
-1
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,4 +474,16 @@ static inline struct ice_rx_ptype_decoded ice_decode_rx_desc_ptype(u16 ptype)
474474
{
475475
return ice_ptype_lkup[ptype];
476476
}
477+
478+
#define ICE_LINK_SPEED_UNKNOWN 0
479+
#define ICE_LINK_SPEED_10MBPS 10
480+
#define ICE_LINK_SPEED_100MBPS 100
481+
#define ICE_LINK_SPEED_1000MBPS 1000
482+
#define ICE_LINK_SPEED_2500MBPS 2500
483+
#define ICE_LINK_SPEED_5000MBPS 5000
484+
#define ICE_LINK_SPEED_10000MBPS 10000
485+
#define ICE_LINK_SPEED_20000MBPS 20000
486+
#define ICE_LINK_SPEED_25000MBPS 25000
487+
#define ICE_LINK_SPEED_40000MBPS 40000
488+
477489
#endif /* _ICE_LAN_TX_RX_H_ */

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3884,6 +3884,12 @@ static const struct net_device_ops ice_netdev_ops = {
38843884
.ndo_validate_addr = eth_validate_addr,
38853885
.ndo_change_mtu = ice_change_mtu,
38863886
.ndo_get_stats64 = ice_get_stats64,
3887+
.ndo_set_vf_spoofchk = ice_set_vf_spoofchk,
3888+
.ndo_set_vf_mac = ice_set_vf_mac,
3889+
.ndo_get_vf_config = ice_get_vf_cfg,
3890+
.ndo_set_vf_trust = ice_set_vf_trust,
3891+
.ndo_set_vf_vlan = ice_set_vf_port_vlan,
3892+
.ndo_set_vf_link_state = ice_set_vf_link_state,
38873893
.ndo_vlan_rx_add_vid = ice_vlan_rx_add_vid,
38883894
.ndo_vlan_rx_kill_vid = ice_vlan_rx_kill_vid,
38893895
.ndo_set_features = ice_set_features,

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

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,89 @@ ice_aq_send_msg_to_vf(struct ice_hw *hw, u16 vfid, u32 v_opcode, u32 v_retval,
3939

4040
return ice_sq_send_cmd(hw, &hw->mailboxq, &desc, msg, msglen, cd);
4141
}
42+
43+
/**
44+
* ice_conv_link_speed_to_virtchnl
45+
* @adv_link_support: determines the format of the returned link speed
46+
* @link_speed: variable containing the link_speed to be converted
47+
*
48+
* Convert link speed supported by HW to link speed supported by virtchnl.
49+
* If adv_link_support is true, then return link speed in Mbps. Else return
50+
* link speed as a VIRTCHNL_LINK_SPEED_* casted to a u32. Note that the caller
51+
* needs to cast back to an enum virtchnl_link_speed in the case where
52+
* adv_link_support is false, but when adv_link_support is true the caller can
53+
* expect the speed in Mbps.
54+
*/
55+
u32 ice_conv_link_speed_to_virtchnl(bool adv_link_support, u16 link_speed)
56+
{
57+
u32 speed;
58+
59+
if (adv_link_support)
60+
switch (link_speed) {
61+
case ICE_AQ_LINK_SPEED_10MB:
62+
speed = ICE_LINK_SPEED_10MBPS;
63+
break;
64+
case ICE_AQ_LINK_SPEED_100MB:
65+
speed = ICE_LINK_SPEED_100MBPS;
66+
break;
67+
case ICE_AQ_LINK_SPEED_1000MB:
68+
speed = ICE_LINK_SPEED_1000MBPS;
69+
break;
70+
case ICE_AQ_LINK_SPEED_2500MB:
71+
speed = ICE_LINK_SPEED_2500MBPS;
72+
break;
73+
case ICE_AQ_LINK_SPEED_5GB:
74+
speed = ICE_LINK_SPEED_5000MBPS;
75+
break;
76+
case ICE_AQ_LINK_SPEED_10GB:
77+
speed = ICE_LINK_SPEED_10000MBPS;
78+
break;
79+
case ICE_AQ_LINK_SPEED_20GB:
80+
speed = ICE_LINK_SPEED_20000MBPS;
81+
break;
82+
case ICE_AQ_LINK_SPEED_25GB:
83+
speed = ICE_LINK_SPEED_25000MBPS;
84+
break;
85+
case ICE_AQ_LINK_SPEED_40GB:
86+
speed = ICE_LINK_SPEED_40000MBPS;
87+
break;
88+
default:
89+
speed = ICE_LINK_SPEED_UNKNOWN;
90+
break;
91+
}
92+
else
93+
/* Virtchnl speeds are not defined for every speed supported in
94+
* the hardware. To maintain compatibility with older AVF
95+
* drivers, while reporting the speed the new speed values are
96+
* resolved to the closest known virtchnl speeds
97+
*/
98+
switch (link_speed) {
99+
case ICE_AQ_LINK_SPEED_10MB:
100+
case ICE_AQ_LINK_SPEED_100MB:
101+
speed = (u32)VIRTCHNL_LINK_SPEED_100MB;
102+
break;
103+
case ICE_AQ_LINK_SPEED_1000MB:
104+
case ICE_AQ_LINK_SPEED_2500MB:
105+
case ICE_AQ_LINK_SPEED_5GB:
106+
speed = (u32)VIRTCHNL_LINK_SPEED_1GB;
107+
break;
108+
case ICE_AQ_LINK_SPEED_10GB:
109+
speed = (u32)VIRTCHNL_LINK_SPEED_10GB;
110+
break;
111+
case ICE_AQ_LINK_SPEED_20GB:
112+
speed = (u32)VIRTCHNL_LINK_SPEED_20GB;
113+
break;
114+
case ICE_AQ_LINK_SPEED_25GB:
115+
speed = (u32)VIRTCHNL_LINK_SPEED_25GB;
116+
break;
117+
case ICE_AQ_LINK_SPEED_40GB:
118+
/* fall through */
119+
speed = (u32)VIRTCHNL_LINK_SPEED_40GB;
120+
break;
121+
default:
122+
speed = (u32)VIRTCHNL_LINK_SPEED_UNKNOWN;
123+
break;
124+
}
125+
126+
return speed;
127+
}

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ enum ice_status
1111
ice_aq_send_msg_to_vf(struct ice_hw *hw, u16 vfid, u32 v_opcode, u32 v_retval,
1212
u8 *msg, u16 msglen, struct ice_sq_cd *cd);
1313

14+
u32 ice_conv_link_speed_to_virtchnl(bool adv_link_support, u16 link_speed);
1415
#else /* CONFIG_PCI_IOV */
1516
static inline enum ice_status
1617
ice_aq_send_msg_to_vf(struct ice_hw __always_unused *hw,
@@ -21,5 +22,13 @@ ice_aq_send_msg_to_vf(struct ice_hw __always_unused *hw,
2122
{
2223
return 0;
2324
}
25+
26+
static inline u32
27+
ice_conv_link_speed_to_virtchnl(bool __always_unused adv_link_support,
28+
u16 __always_unused link_speed)
29+
{
30+
return 0;
31+
}
32+
2433
#endif /* CONFIG_PCI_IOV */
2534
#endif /* _ICE_SRIOV_H_ */

0 commit comments

Comments
 (0)