ethernet: intel: Support Hyper-V hosts
Subsystems (3)
v4 cover ethernet: intel: Support Hyper-V hosts
Make adjustments to the Intel 10G VF driver to support running on Hyper-V hosts.
K. Y. Srinivasan (2):
ethernet: intel: Add the device ID's presented while running on
Hyper-V
intel: ixgbevf: Support Windows hosts (Hyper-V)
drivers/net/ethernet/intel/ixgbevf/defines.h | 5 + drivers/net/ethernet/intel/ixgbevf/ixgbevf.h | 12 ++ drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c | 31 +++- drivers/net/ethernet/intel/ixgbevf/mbx.c | 12 ++ drivers/net/ethernet/intel/ixgbevf/vf.c | 216 +++++++++++++++++++++ drivers/net/ethernet/intel/ixgbevf/vf.h | 2 + 6 files changed, 271 insertions(+), 7 deletions(-)
Signature · 1 line
1.7.4.1
PATCH v4 1/2 ethernet: intel: Add the device ID's presented while running on Hyper-V
Intel SR-IOV cards present different ID when running on Hyper-V. Add the device IDs presented while running on Hyper-V.
---
V4: No change from V1
drivers/net/ethernet/intel/ixgbevf/defines.h | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
drivers/net/ethernet/intel/ixgbevf/defines.h +5 -0
@@ -33,6 +33,11 @@#define IXGBE_DEV_ID_X550_VF 0x1565#define IXGBE_DEV_ID_X550EM_X_VF 0x15A8 +#define IXGBE_DEV_ID_82599_VF_HV 0x152E +#define IXGBE_DEV_ID_X540_VF_HV 0x1530 +#define IXGBE_DEV_ID_X550_VF_HV 0x1564 +#define IXGBE_DEV_ID_X550EM_X_VF_HV 0x15A9 +#define IXGBE_VF_IRQ_CLEAR_MASK 7#define IXGBE_VF_MAX_TX_QUEUES 8#define IXGBE_VF_MAX_RX_QUEUES 8
Signature · 1 line
1.7.4.1
PATCH v4 2/2 intel: ixgbevf: Support Windows hosts (Hyper-V)
On Hyper-V, the VF/PF communication is a via software mediated path as opposed to the hardware mailbox. Make the necessary adjustments to support Hyper-V.
---
V2: Addressed most of the comments from
Alexander Duyck <[email protected]> and Rustad, Mark D <[email protected]>.
V3: Addressed additional comments from
Alexander Duyck <[email protected]>
V4: Addressed kbuild errors reported by:
kbuild test robot <[email protected]>
drivers/net/ethernet/intel/ixgbevf/ixgbevf.h | 12 ++ drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c | 31 +++- drivers/net/ethernet/intel/ixgbevf/mbx.c | 12 ++ drivers/net/ethernet/intel/ixgbevf/vf.c | 216 +++++++++++++++++++++ drivers/net/ethernet/intel/ixgbevf/vf.h | 2 + 5 files changed, 266 insertions(+), 7 deletions(-)
drivers/net/ethernet/intel/ixgbevf/ixgbevf.h +12 -0
@@ -460,9 +460,13 @@ enum ixbgevf_state_t {enum ixgbevf_boards { board_82599_vf, + board_82599_vf_hv, board_X540_vf, + board_X540_vf_hv, board_X550_vf, + board_X550_vf_hv, board_X550EM_x_vf, + board_X550EM_x_vf_hv, };enum ixgbevf_xcast_modes {
@@ -477,6 +481,13 @@ extern const struct ixgbevf_info ixgbevf_X550_vf_info;extern const struct ixgbevf_info ixgbevf_X550EM_x_vf_info;extern const struct ixgbe_mbx_operations ixgbevf_mbx_ops; + +extern const struct ixgbevf_info ixgbevf_82599_vf_hv_info; +extern const struct ixgbevf_info ixgbevf_X540_vf_hv_info; +extern const struct ixgbevf_info ixgbevf_X550_vf_hv_info; +extern const struct ixgbevf_info ixgbevf_X550EM_x_vf_hv_info; +extern const struct ixgbe_mbx_operations ixgbevf_hv_mbx_ops; +/* needed by ethtool.c */ extern const char ixgbevf_driver_name[];extern const char ixgbevf_driver_version[];
@@ -494,6 +505,7 @@ void ixgbevf_free_rx_resources(struct ixgbevf_ring *);void ixgbevf_free_tx_resources (struct ixgbevf_ring *);void ixgbevf_update_stats (struct ixgbevf_adapter *adapter);int ethtool_ioctl (struct ifreq *ifr); +bool ixgbevf_on_hyperv (struct ixgbe_hw *hw);extern void ixgbevf_write_eitr (struct ixgbevf_q_vector *q_vector);
drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c +24 -7
@@ -62,10 +62,14 @@ static char ixgbevf_copyright[] ="Copyright (c) 2009 - 2015 Intel Corporation." ;static const struct ixgbevf_info *ixgbevf_info_tbl[] = { - [board_82599_vf] = &ixgbevf_82599_vf_info, - [board_X540_vf] = &ixgbevf_X540_vf_info, - [board_X550_vf] = &ixgbevf_X550_vf_info, - [board_X550EM_x_vf] = &ixgbevf_X550EM_x_vf_info, + [board_82599_vf] = &ixgbevf_82599_vf_info, + [board_82599_vf_hv] = &ixgbevf_82599_vf_hv_info, + [board_X540_vf] = &ixgbevf_X540_vf_info, + [board_X540_vf_hv] = &ixgbevf_X540_vf_hv_info, + [board_X550_vf] = &ixgbevf_X550_vf_info, + [board_X550_vf_hv] = &ixgbevf_X550_vf_hv_info, + [board_X550EM_x_vf] = &ixgbevf_X550EM_x_vf_info, + [board_X550EM_x_vf_hv] = &ixgbevf_X550EM_x_vf_hv_info, };/* ixgbevf_pci_tbl - PCI Device ID Table
@@ -78,9 +82,13 @@ static const struct ixgbevf_info *ixgbevf_info_tbl[] = {*/ static const struct pci_device_id ixgbevf_pci_tbl[] = { {PCI_VDEVICE (INTEL ,IXGBE_DEV_ID_82599_VF ), board_82599_vf }, + {PCI_VDEVICE (INTEL ,IXGBE_DEV_ID_82599_VF_HV ), board_82599_vf_hv }, {PCI_VDEVICE (INTEL ,IXGBE_DEV_ID_X540_VF ), board_X540_vf }, + {PCI_VDEVICE (INTEL ,IXGBE_DEV_ID_X540_VF_HV ), board_X540_vf_hv }, {PCI_VDEVICE (INTEL ,IXGBE_DEV_ID_X550_VF ), board_X550_vf }, + {PCI_VDEVICE (INTEL ,IXGBE_DEV_ID_X550_VF_HV ), board_X550_vf_hv }, {PCI_VDEVICE (INTEL ,IXGBE_DEV_ID_X550EM_X_VF ), board_X550EM_x_vf }, + {PCI_VDEVICE (INTEL ,IXGBE_DEV_ID_X550EM_X_VF_HV ), board_X550EM_x_vf_hv},/* required last entry */ {0 , } };
@@ -1795,7 +1803,10 @@ static void ixgbevf_configure_rx(struct ixgbevf_adapter *adapter)ixgbevf_setup_vfmrqc (adapter);/* notify the PF of our intent to use this size of frame */ -ixgbevf_rlpml_set_vf (hw, netdev->mtu +ETH_HLEN +ETH_FCS_LEN ); +if (!ixgbevf_on_hyperv (hw)) +ixgbevf_rlpml_set_vf (hw, netdev->mtu +ETH_HLEN +ETH_FCS_LEN ); +else +ixgbevf_hv_rlpml_set_vf (hw, netdev->mtu +ETH_HLEN +ETH_FCS_LEN );/* Setup the HW Rx Head and Tail Descriptor Pointers and * the Base and Length of the Rx Descriptor Ring
@@ -2056,7 +2067,10 @@ static void ixgbevf_negotiate_api(struct ixgbevf_adapter *adapter)spin_lock_bh (&adapter->mbx_lock);while (api[idx] != ixgbe_mbox_api_unknown) { - err =ixgbevf_negotiate_api_version (hw, api[idx]); +if (!ixgbevf_on_hyperv (hw)) + err =ixgbevf_negotiate_api_version (hw, api[idx]); +else + err =ixgbevf_hv_negotiate_api_version (hw, api[idx]);if (!err)break ; idx++;
@@ -3727,7 +3741,10 @@ static int ixgbevf_change_mtu(struct net_device *netdev, int new_mtu) netdev->mtu = new_mtu;/* notify the PF of our intent to use this size of frame */ -ixgbevf_rlpml_set_vf (hw, max_frame); +if (!ixgbevf_on_hyperv (hw)) +ixgbevf_rlpml_set_vf (hw, max_frame); +else +ixgbevf_hv_rlpml_set_vf (hw, max_frame);return 0 ; }
drivers/net/ethernet/intel/ixgbevf/mbx.c +12 -0
@@ -346,3 +346,15 @@ const struct ixgbe_mbx_operations ixgbevf_mbx_ops = { .check_for_rst = ixgbevf_check_for_rst_vf, }; +/** +* Mailbox operations when running on Hyper-V. +* On Hyper-V, PF/VF communiction is not through the +* hardware mailbox; this communication is through +* a software mediated path. +* Most mail box operations are noop while running on +* Hyper-V. +*/ +const struct ixgbe_mbx_operations ixgbevf_hv_mbx_ops = { + .init_params = ixgbevf_init_mbx_params_vf, + .check_for_rst = ixgbevf_check_for_rst_vf, +};
drivers/net/ethernet/intel/ixgbevf/vf.c +216 -0
298 lines not on this page · raw message
drivers/net/ethernet/intel/ixgbevf/vf.h +2 -0
@@ -208,7 +208,9 @@ static inline u32 ixgbe_read_reg_array(struct ixgbe_hw *hw, u32 reg,#define IXGBE_READ_REG_ARRAY (h, r, o) ixgbe_read_reg_array(h, r, o)void ixgbevf_rlpml_set_vf (struct ixgbe_hw *hw,u16 max_size); +void ixgbevf_hv_rlpml_set_vf (struct ixgbe_hw *hw,u16 max_size);int ixgbevf_negotiate_api_version (struct ixgbe_hw *hw,int api); +int ixgbevf_hv_negotiate_api_version (struct ixgbe_hw *hw,int api);int ixgbevf_get_queues (struct ixgbe_hw *hw,unsigned int *num_tcs,unsigned int *default_tc);int ixgbevf_get_reta_locked (struct ixgbe_hw *hw,u32 *reta,int num_rx_queues);
Signature · 1 line
1.7.4.1
Re: [PATCH net-next V4 2/2] intel: ixgbevf: Support Windows hosts (Hyper-V)
Quoted 189 lines · K. Y. Srinivasan
On Hyper-V, the VF/PF communication is a via software mediated path as opposed to the hardware mailbox. Make the necessary adjustments to support Hyper-V.
Signed-off-by K. Y. Srinivasan <[email protected]>---
V2: Addressed most of the comments from
Alexander Duyck <[email protected]> and Rustad, Mark D <[email protected]>.V3: Addressed additional comments from
Alexander Duyck <[email protected]>V4: Addressed kbuild errors reported by:
kbuild test robot <[email protected]>drivers/net/ethernet/intel/ixgbevf/ixgbevf.h | 12 ++ drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c | 31 +++- drivers/net/ethernet/intel/ixgbevf/mbx.c | 12 ++ drivers/net/ethernet/intel/ixgbevf/vf.c | 216 +++++++++++++++++++++ drivers/net/ethernet/intel/ixgbevf/vf.h | 2 + 5 files changed, 266 insertions(+), 7 deletions(-)drivers/net/ethernet/intel/ixgbevf/ixgbevf.h +12
-0@@ -460,9 +460,13 @@ enum ixbgevf_state_t {enum ixgbevf_boards { board_82599_vf, + board_82599_vf_hv, board_X540_vf, + board_X540_vf_hv, board_X550_vf, + board_X550_vf_hv, board_X550EM_x_vf, + board_X550EM_x_vf_hv, };enum ixgbevf_xcast_modes {@@ -477,6 +481,13 @@ extern const struct ixgbevf_info ixgbevf_X550_vf_info;extern const struct ixgbevf_info ixgbevf_X550EM_x_vf_info;extern const struct ixgbe_mbx_operations ixgbevf_mbx_ops; + +extern const struct ixgbevf_info ixgbevf_82599_vf_hv_info; +extern const struct ixgbevf_info ixgbevf_X540_vf_hv_info; +extern const struct ixgbevf_info ixgbevf_X550_vf_hv_info; +extern const struct ixgbevf_info ixgbevf_X550EM_x_vf_hv_info; +extern const struct ixgbe_mbx_operations ixgbevf_hv_mbx_ops; +/* needed by ethtool.c */ extern const char ixgbevf_driver_name[];extern const char ixgbevf_driver_version[];@@ -494,6 +505,7 @@ void ixgbevf_free_rx_resources(struct ixgbevf_ring *);void ixgbevf_free_tx_resources (struct ixgbevf_ring *);void ixgbevf_update_stats (struct ixgbevf_adapter *adapter);int ethtool_ioctl (struct ifreq *ifr); +bool ixgbevf_on_hyperv (struct ixgbe_hw *hw);extern void ixgbevf_write_eitr (struct ixgbevf_q_vector *q_vector);drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c +24
-7@@ -62,10 +62,14 @@ static char ixgbevf_copyright[] ="Copyright (c) 2009 - 2015 Intel Corporation." ;static const struct ixgbevf_info *ixgbevf_info_tbl[] = { - [board_82599_vf] = &ixgbevf_82599_vf_info, - [board_X540_vf] = &ixgbevf_X540_vf_info, - [board_X550_vf] = &ixgbevf_X550_vf_info, - [board_X550EM_x_vf] = &ixgbevf_X550EM_x_vf_info, + [board_82599_vf] = &ixgbevf_82599_vf_info, + [board_82599_vf_hv] = &ixgbevf_82599_vf_hv_info, + [board_X540_vf] = &ixgbevf_X540_vf_info, + [board_X540_vf_hv] = &ixgbevf_X540_vf_hv_info, + [board_X550_vf] = &ixgbevf_X550_vf_info, + [board_X550_vf_hv] = &ixgbevf_X550_vf_hv_info, + [board_X550EM_x_vf] = &ixgbevf_X550EM_x_vf_info, + [board_X550EM_x_vf_hv] = &ixgbevf_X550EM_x_vf_hv_info, };/* ixgbevf_pci_tbl - PCI Device ID Table @@ -78,9 +82,13 @@ static const struct ixgbevf_info *ixgbevf_info_tbl[] = {*/ static const struct pci_device_id ixgbevf_pci_tbl[] = { {PCI_VDEVICE (INTEL ,IXGBE_DEV_ID_82599_VF ), board_82599_vf }, + {PCI_VDEVICE (INTEL ,IXGBE_DEV_ID_82599_VF_HV ), board_82599_vf_hv }, {PCI_VDEVICE (INTEL ,IXGBE_DEV_ID_X540_VF ), board_X540_vf }, + {PCI_VDEVICE (INTEL ,IXGBE_DEV_ID_X540_VF_HV ), board_X540_vf_hv }, {PCI_VDEVICE (INTEL ,IXGBE_DEV_ID_X550_VF ), board_X550_vf }, + {PCI_VDEVICE (INTEL ,IXGBE_DEV_ID_X550_VF_HV ), board_X550_vf_hv }, {PCI_VDEVICE (INTEL ,IXGBE_DEV_ID_X550EM_X_VF ), board_X550EM_x_vf }, + {PCI_VDEVICE (INTEL ,IXGBE_DEV_ID_X550EM_X_VF_HV ), board_X550EM_x_vf_hv},/* required last entry */ {0 , } };@@ -1795,7 +1803,10 @@ static void ixgbevf_configure_rx(struct ixgbevf_adapter *adapter)ixgbevf_setup_vfmrqc (adapter);/* notify the PF of our intent to use this size of frame */ -ixgbevf_rlpml_set_vf (hw, netdev->mtu +ETH_HLEN +ETH_FCS_LEN ); +if (!ixgbevf_on_hyperv (hw)) +ixgbevf_rlpml_set_vf (hw, netdev->mtu +ETH_HLEN +ETH_FCS_LEN ); +else +ixgbevf_hv_rlpml_set_vf (hw, netdev->mtu +ETH_HLEN +ETH_FCS_LEN );/* Setup the HW Rx Head and Tail Descriptor Pointers and * the Base and Length of the Rx Descriptor Ring @@ -2056,7 +2067,10 @@ static void ixgbevf_negotiate_api(struct ixgbevf_adapter *adapter)spin_lock_bh (&adapter->mbx_lock);while (api[idx] != ixgbe_mbox_api_unknown) { - err =ixgbevf_negotiate_api_version (hw, api[idx]); +if (!ixgbevf_on_hyperv (hw)) + err =ixgbevf_negotiate_api_version (hw, api[idx]); +else + err =ixgbevf_hv_negotiate_api_version (hw, api[idx]);if (!err)break ; idx++;@@ -3727,7 +3741,10 @@ static int ixgbevf_change_mtu(struct net_device *netdev, int new_mtu) netdev->mtu = new_mtu;/* notify the PF of our intent to use this size of frame */ -ixgbevf_rlpml_set_vf (hw, max_frame); +if (!ixgbevf_on_hyperv (hw)) +ixgbevf_rlpml_set_vf (hw, max_frame); +else +ixgbevf_hv_rlpml_set_vf (hw, max_frame);return 0 ; }drivers/net/ethernet/intel/ixgbevf/mbx.c +12
-0@@ -346,3 +346,15 @@ const struct ixgbe_mbx_operations ixgbevf_mbx_ops = { .check_for_rst = ixgbevf_check_for_rst_vf, }; +/** +* Mailbox operations when running on Hyper-V. +* On Hyper-V, PF/VF communiction is not through the +* hardware mailbox; this communication is through +* a software mediated path. +* Most mail box operations are noop while running on +* Hyper-V. +*/ +const struct ixgbe_mbx_operations ixgbevf_hv_mbx_ops = { + .init_params = ixgbevf_init_mbx_params_vf, + .check_for_rst = ixgbevf_check_for_rst_vf, +};drivers/net/ethernet/intel/ixgbevf/vf.c +17
-0@@ -27,6 +27,13 @@#include "vf.h" #include "ixgbevf.h" +/* +* On Hyper-V, to reset, we need to read from this offset +* from the PCI config space. This is the mechanism used on +* Hyper-V to support PF/VF communication. +*/ +#define IXGBE_HV_RESET_OFFSET 0x201 +/** * ixgbevf_start_hw_vf - Prepare hardware for Tx/Rx * @hw: pointer to hardware structure @@ -126,6 +133,27 @@ static s32 ixgbevf_reset_hw_vf(struct ixgbe_hw *hw) }/** +* Hyper-V variant; the VF/PF communication is through the PCI +* config space. +*/ +static s32 ixgbevf_hv_reset_hw_vf (struct ixgbe_hw *hw) +{ +#if IS_ENABLED (CONFIG_PCI_MMCONFIG ) +struct ixgbevf_adapter *adapter = hw->back; +int i; + +for (i =0 ; i <6 ; i++)
drivers/net/ethernet/intel/ixgbevf/vf.c static s32 ixgbevf_reset_hw_vf(struct ixgbe_hw *hw) · line 155
Quoted 10 lines
drivers/net/ethernet/intel/ixgbevf/vf.c +10
-0+pci_read_config_byte (adapter->pdev, + (i +IXGBE_HV_RESET_OFFSET ), + &hw->mac.perm_addr[i]); +#else +pr_err ("PCI_MMCONFIG needs to be enabled for Hyper-V\n" ); +#endif + +return 0 ; +} +
You should probably just return an error here if MMCONFIG is not defined. You can probably move the return into the #if/#else blocks so that you return 0 if MMCONFIG is supported, and you return -EOPNOTSUPP if MMCONFIG is not defined.
That way you don't have to worry about confusing the driver and having it think that it is running with no MAC address assigned by the administrator.
- Alex