Skip to content

Commit a7075f5

Browse files
jjagielskkuba-moo
authored andcommitted
ixgbevf: fix mailbox API compatibility by negotiating supported features
There was backward compatibility in the terms of mailbox API. Various drivers from various OSes supporting 10G adapters from Intel portfolio could easily negotiate mailbox API. This convention has been broken since introducing API 1.4. Commit 0062e7c ("ixgbevf: add VF IPsec offload code") added support for IPSec which is specific only for the kernel ixgbe driver. None of the rest of the Intel 10G PF/VF drivers supports it. And actually lack of support was not included in the IPSec implementation - there were no such code paths. No possibility to negotiate support for the feature was introduced along with introduction of the feature itself. Commit 339f289 ("ixgbevf: Add support for new mailbox communication between PF and VF") increasing API version to 1.5 did the same - it introduced code supported specifically by the PF ESX driver. It altered API version for the VF driver in the same time not touching the version defined for the PF ixgbe driver. It led to additional discrepancies, as the code provided within API 1.6 cannot be supported for Linux ixgbe driver as it causes crashes. The issue was noticed some time ago and mitigated by Jake within the commit d072531 ("ixgbevf: stop attempting IPSEC offload on Mailbox API 1.5"). As a result we have regression for IPsec support and after increasing API to version 1.6 ixgbevf driver stopped to support ESX MBX. To fix this mess add new mailbox op asking PF driver about supported features. Basing on a response determine whether to set support for IPSec and ESX-specific enhanced mailbox. New mailbox op, for compatibility purposes, must be added within new API revision, as API version of OOT PF & VF drivers is already increased to 1.6 and doesn't incorporate features negotiate op. Features negotiation mechanism gives possibility to be extended with new features when needed in the future. Reported-by: Jacob Keller <jacob.e.keller@intel.com> Closes: https://lore.kernel.org/intel-wired-lan/20241101-jk-ixgbevf-mailbox-v1-5-fixes-v1-0-f556dc9a66ed@intel.com/ Fixes: 0062e7c ("ixgbevf: add VF IPsec offload code") Fixes: 339f289 ("ixgbevf: Add support for new mailbox communication between PF and VF") Reviewed-by: Jacob Keller <jacob.e.keller@intel.com> Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com> Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com> Cc: stable@vger.kernel.org Signed-off-by: Jedrzej Jagielski <jedrzej.jagielski@intel.com> Tested-by: Rafal Romanowski <rafal.romanowski@intel.com> Signed-off-by: Jacob Keller <jacob.e.keller@intel.com> Link: https://patch.msgid.link/20251009-jk-iwl-net-2025-10-01-v3-4-ef32a425b92a@intel.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent f7f97cb commit a7075f5

File tree

6 files changed

+96
-3
lines changed

6 files changed

+96
-3
lines changed

drivers/net/ethernet/intel/ixgbevf/ipsec.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,9 @@ static int ixgbevf_ipsec_add_sa(struct net_device *dev,
273273
adapter = netdev_priv(dev);
274274
ipsec = adapter->ipsec;
275275

276+
if (!(adapter->pf_features & IXGBEVF_PF_SUP_IPSEC))
277+
return -EOPNOTSUPP;
278+
276279
if (xs->id.proto != IPPROTO_ESP && xs->id.proto != IPPROTO_AH) {
277280
NL_SET_ERR_MSG_MOD(extack, "Unsupported protocol for IPsec offload");
278281
return -EINVAL;
@@ -405,6 +408,9 @@ static void ixgbevf_ipsec_del_sa(struct net_device *dev,
405408
adapter = netdev_priv(dev);
406409
ipsec = adapter->ipsec;
407410

411+
if (!(adapter->pf_features & IXGBEVF_PF_SUP_IPSEC))
412+
return;
413+
408414
if (xs->xso.dir == XFRM_DEV_OFFLOAD_IN) {
409415
sa_idx = xs->xso.offload_handle - IXGBE_IPSEC_BASE_RX_INDEX;
410416

@@ -612,6 +618,10 @@ void ixgbevf_init_ipsec_offload(struct ixgbevf_adapter *adapter)
612618
size_t size;
613619

614620
switch (adapter->hw.api_version) {
621+
case ixgbe_mbox_api_17:
622+
if (!(adapter->pf_features & IXGBEVF_PF_SUP_IPSEC))
623+
return;
624+
break;
615625
case ixgbe_mbox_api_14:
616626
break;
617627
default:

drivers/net/ethernet/intel/ixgbevf/ixgbevf.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,13 @@ struct ixgbevf_adapter {
363363
struct ixgbe_hw hw;
364364
u16 msg_enable;
365365

366+
u32 pf_features;
367+
#define IXGBEVF_PF_SUP_IPSEC BIT(0)
368+
#define IXGBEVF_PF_SUP_ESX_MBX BIT(1)
369+
370+
#define IXGBEVF_SUPPORTED_FEATURES (IXGBEVF_PF_SUP_IPSEC | \
371+
IXGBEVF_PF_SUP_ESX_MBX)
372+
366373
struct ixgbevf_hw_stats stats;
367374

368375
unsigned long state;

drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2271,10 +2271,35 @@ static void ixgbevf_init_last_counter_stats(struct ixgbevf_adapter *adapter)
22712271
adapter->stats.base_vfmprc = adapter->stats.last_vfmprc;
22722272
}
22732273

2274+
/**
2275+
* ixgbevf_set_features - Set features supported by PF
2276+
* @adapter: pointer to the adapter struct
2277+
*
2278+
* Negotiate with PF supported features and then set pf_features accordingly.
2279+
*/
2280+
static void ixgbevf_set_features(struct ixgbevf_adapter *adapter)
2281+
{
2282+
u32 *pf_features = &adapter->pf_features;
2283+
struct ixgbe_hw *hw = &adapter->hw;
2284+
int err;
2285+
2286+
err = hw->mac.ops.negotiate_features(hw, pf_features);
2287+
if (err && err != -EOPNOTSUPP)
2288+
netdev_dbg(adapter->netdev,
2289+
"PF feature negotiation failed.\n");
2290+
2291+
/* Address also pre API 1.7 cases */
2292+
if (hw->api_version == ixgbe_mbox_api_14)
2293+
*pf_features |= IXGBEVF_PF_SUP_IPSEC;
2294+
else if (hw->api_version == ixgbe_mbox_api_15)
2295+
*pf_features |= IXGBEVF_PF_SUP_ESX_MBX;
2296+
}
2297+
22742298
static void ixgbevf_negotiate_api(struct ixgbevf_adapter *adapter)
22752299
{
22762300
struct ixgbe_hw *hw = &adapter->hw;
22772301
static const int api[] = {
2302+
ixgbe_mbox_api_17,
22782303
ixgbe_mbox_api_16,
22792304
ixgbe_mbox_api_15,
22802305
ixgbe_mbox_api_14,
@@ -2295,8 +2320,9 @@ static void ixgbevf_negotiate_api(struct ixgbevf_adapter *adapter)
22952320
idx++;
22962321
}
22972322

2298-
/* Following is not supported by API 1.6, it is specific for 1.5 */
2299-
if (hw->api_version == ixgbe_mbox_api_15) {
2323+
ixgbevf_set_features(adapter);
2324+
2325+
if (adapter->pf_features & IXGBEVF_PF_SUP_ESX_MBX) {
23002326
hw->mbx.ops.init_params(hw);
23012327
memcpy(&hw->mbx.ops, &ixgbevf_mbx_ops,
23022328
sizeof(struct ixgbe_mbx_operations));
@@ -2654,6 +2680,7 @@ static void ixgbevf_set_num_queues(struct ixgbevf_adapter *adapter)
26542680
case ixgbe_mbox_api_14:
26552681
case ixgbe_mbox_api_15:
26562682
case ixgbe_mbox_api_16:
2683+
case ixgbe_mbox_api_17:
26572684
if (adapter->xdp_prog &&
26582685
hw->mac.max_tx_queues == rss)
26592686
rss = rss > 3 ? 2 : 1;
@@ -4649,6 +4676,7 @@ static int ixgbevf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
46494676
case ixgbe_mbox_api_14:
46504677
case ixgbe_mbox_api_15:
46514678
case ixgbe_mbox_api_16:
4679+
case ixgbe_mbox_api_17:
46524680
netdev->max_mtu = IXGBE_MAX_JUMBO_FRAME_SIZE -
46534681
(ETH_HLEN + ETH_FCS_LEN);
46544682
break;

drivers/net/ethernet/intel/ixgbevf/mbx.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ enum ixgbe_pfvf_api_rev {
6767
ixgbe_mbox_api_14, /* API version 1.4, linux/freebsd VF driver */
6868
ixgbe_mbox_api_15, /* API version 1.5, linux/freebsd VF driver */
6969
ixgbe_mbox_api_16, /* API version 1.6, linux/freebsd VF driver */
70+
ixgbe_mbox_api_17, /* API version 1.7, linux/freebsd VF driver */
7071
/* This value should always be last */
7172
ixgbe_mbox_api_unknown, /* indicates that API version is not known */
7273
};
@@ -106,6 +107,9 @@ enum ixgbe_pfvf_api_rev {
106107
/* mailbox API, version 1.6 VF requests */
107108
#define IXGBE_VF_GET_PF_LINK_STATE 0x11 /* request PF to send link info */
108109

110+
/* mailbox API, version 1.7 VF requests */
111+
#define IXGBE_VF_FEATURES_NEGOTIATE 0x12 /* get features supported by PF*/
112+
109113
/* length of permanent address message returned from PF */
110114
#define IXGBE_VF_PERMADDR_MSG_LEN 4
111115
/* word in permanent address message with the current multicast type */

drivers/net/ethernet/intel/ixgbevf/vf.c

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ int ixgbevf_get_reta_locked(struct ixgbe_hw *hw, u32 *reta, int num_rx_queues)
313313
* is not supported for this device type.
314314
*/
315315
switch (hw->api_version) {
316+
case ixgbe_mbox_api_17:
316317
case ixgbe_mbox_api_16:
317318
case ixgbe_mbox_api_15:
318319
case ixgbe_mbox_api_14:
@@ -383,6 +384,7 @@ int ixgbevf_get_rss_key_locked(struct ixgbe_hw *hw, u8 *rss_key)
383384
* or if the operation is not supported for this device type.
384385
*/
385386
switch (hw->api_version) {
387+
case ixgbe_mbox_api_17:
386388
case ixgbe_mbox_api_16:
387389
case ixgbe_mbox_api_15:
388390
case ixgbe_mbox_api_14:
@@ -555,6 +557,7 @@ static s32 ixgbevf_update_xcast_mode(struct ixgbe_hw *hw, int xcast_mode)
555557
case ixgbe_mbox_api_14:
556558
case ixgbe_mbox_api_15:
557559
case ixgbe_mbox_api_16:
560+
case ixgbe_mbox_api_17:
558561
break;
559562
default:
560563
return -EOPNOTSUPP;
@@ -646,6 +649,7 @@ static int ixgbevf_get_pf_link_state(struct ixgbe_hw *hw, ixgbe_link_speed *spee
646649

647650
switch (hw->api_version) {
648651
case ixgbe_mbox_api_16:
652+
case ixgbe_mbox_api_17:
649653
break;
650654
default:
651655
return -EOPNOTSUPP;
@@ -669,6 +673,42 @@ static int ixgbevf_get_pf_link_state(struct ixgbe_hw *hw, ixgbe_link_speed *spee
669673
return err;
670674
}
671675

676+
/**
677+
* ixgbevf_negotiate_features_vf - negotiate supported features with PF driver
678+
* @hw: pointer to the HW structure
679+
* @pf_features: bitmask of features supported by PF
680+
*
681+
* Return: IXGBE_ERR_MBX in the case of mailbox error,
682+
* -EOPNOTSUPP if the op is not supported or 0 on success.
683+
*/
684+
static int ixgbevf_negotiate_features_vf(struct ixgbe_hw *hw, u32 *pf_features)
685+
{
686+
u32 msgbuf[2] = {};
687+
int err;
688+
689+
switch (hw->api_version) {
690+
case ixgbe_mbox_api_17:
691+
break;
692+
default:
693+
return -EOPNOTSUPP;
694+
}
695+
696+
msgbuf[0] = IXGBE_VF_FEATURES_NEGOTIATE;
697+
msgbuf[1] = IXGBEVF_SUPPORTED_FEATURES;
698+
699+
err = ixgbevf_write_msg_read_ack(hw, msgbuf, msgbuf,
700+
ARRAY_SIZE(msgbuf));
701+
702+
if (err || (msgbuf[0] & IXGBE_VT_MSGTYPE_FAILURE)) {
703+
err = IXGBE_ERR_MBX;
704+
*pf_features = 0x0;
705+
} else {
706+
*pf_features = msgbuf[1];
707+
}
708+
709+
return err;
710+
}
711+
672712
/**
673713
* ixgbevf_set_vfta_vf - Set/Unset VLAN filter table address
674714
* @hw: pointer to the HW structure
@@ -799,6 +839,7 @@ static s32 ixgbevf_check_mac_link_vf(struct ixgbe_hw *hw,
799839
bool *link_up,
800840
bool autoneg_wait_to_complete)
801841
{
842+
struct ixgbevf_adapter *adapter = hw->back;
802843
struct ixgbe_mbx_info *mbx = &hw->mbx;
803844
struct ixgbe_mac_info *mac = &hw->mac;
804845
s32 ret_val = 0;
@@ -825,7 +866,7 @@ static s32 ixgbevf_check_mac_link_vf(struct ixgbe_hw *hw,
825866
* until we are called again and don't report an error
826867
*/
827868
if (mbx->ops.read(hw, &in_msg, 1)) {
828-
if (hw->api_version >= ixgbe_mbox_api_15)
869+
if (adapter->pf_features & IXGBEVF_PF_SUP_ESX_MBX)
829870
mac->get_link_status = false;
830871
goto out;
831872
}
@@ -1026,6 +1067,7 @@ int ixgbevf_get_queues(struct ixgbe_hw *hw, unsigned int *num_tcs,
10261067
case ixgbe_mbox_api_14:
10271068
case ixgbe_mbox_api_15:
10281069
case ixgbe_mbox_api_16:
1070+
case ixgbe_mbox_api_17:
10291071
break;
10301072
default:
10311073
return 0;
@@ -1080,6 +1122,7 @@ static const struct ixgbe_mac_operations ixgbevf_mac_ops = {
10801122
.setup_link = ixgbevf_setup_mac_link_vf,
10811123
.check_link = ixgbevf_check_mac_link_vf,
10821124
.negotiate_api_version = ixgbevf_negotiate_api_version_vf,
1125+
.negotiate_features = ixgbevf_negotiate_features_vf,
10831126
.set_rar = ixgbevf_set_rar_vf,
10841127
.update_mc_addr_list = ixgbevf_update_mc_addr_list_vf,
10851128
.update_xcast_mode = ixgbevf_update_xcast_mode,

drivers/net/ethernet/intel/ixgbevf/vf.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ struct ixgbe_mac_operations {
2626
s32 (*stop_adapter)(struct ixgbe_hw *);
2727
s32 (*get_bus_info)(struct ixgbe_hw *);
2828
s32 (*negotiate_api_version)(struct ixgbe_hw *hw, int api);
29+
int (*negotiate_features)(struct ixgbe_hw *hw, u32 *pf_features);
2930

3031
/* Link */
3132
s32 (*setup_link)(struct ixgbe_hw *, ixgbe_link_speed, bool, bool);

0 commit comments

Comments
 (0)