mirror of https://gitee.com/openkylin/linux.git
ixgbe, ixgbevf: Add new mbox API xcast mode
The limitation of the number of multicast address for VF is not enough for the large scale server with SR-IOV feature. IPv6 requires the multicast MAC address for each IP address to handle the Neighbor Solicitation message. We couldn't assign over 30 IPv6 addresses to a single VF. This patch introduces the new mailbox API, IXGBE_VF_UPDATE_XCAST_MODE, to update multicast mode of VF. This adds 3 modes; - NONE only L2 exact match addresses or Flow Director enabled - MULTI BAM and ROMPE set - ALLMULTI BAM, ROMPE and MPE set If a guest VF user wants over 30 MAC multicast addresses, set IFF_ALLMULTI to request PF to update xcast mode to enable VF multicast promiscuous mode. On the other hand, enabling VF multicast promiscuous mode may affect security and performance in the network of the NIC. Only trusted VF can enable multicast promiscuous mode. The behavior of untrusted VF is the same as previous version. Signed-off-by: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com> Tested-by: Krishneil Singh <Krishneil.k.singh@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
This commit is contained in:
parent
54011e4db8
commit
8443c1a4b1
|
@ -153,9 +153,16 @@ struct vf_data_storage {
|
||||||
u8 spoofchk_enabled;
|
u8 spoofchk_enabled;
|
||||||
bool rss_query_enabled;
|
bool rss_query_enabled;
|
||||||
u8 trusted;
|
u8 trusted;
|
||||||
|
int xcast_mode;
|
||||||
unsigned int vf_api;
|
unsigned int vf_api;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum ixgbevf_xcast_modes {
|
||||||
|
IXGBEVF_XCAST_MODE_NONE = 0,
|
||||||
|
IXGBEVF_XCAST_MODE_MULTI,
|
||||||
|
IXGBEVF_XCAST_MODE_ALLMULTI,
|
||||||
|
};
|
||||||
|
|
||||||
struct vf_macvlans {
|
struct vf_macvlans {
|
||||||
struct list_head l;
|
struct list_head l;
|
||||||
int vf;
|
int vf;
|
||||||
|
|
|
@ -102,6 +102,8 @@ enum ixgbe_pfvf_api_rev {
|
||||||
#define IXGBE_VF_GET_RETA 0x0a /* VF request for RETA */
|
#define IXGBE_VF_GET_RETA 0x0a /* VF request for RETA */
|
||||||
#define IXGBE_VF_GET_RSS_KEY 0x0b /* get RSS key */
|
#define IXGBE_VF_GET_RSS_KEY 0x0b /* get RSS key */
|
||||||
|
|
||||||
|
#define IXGBE_VF_UPDATE_XCAST_MODE 0x0c
|
||||||
|
|
||||||
/* length of permanent address message returned from PF */
|
/* length of permanent address message returned from PF */
|
||||||
#define IXGBE_VF_PERMADDR_MSG_LEN 4
|
#define IXGBE_VF_PERMADDR_MSG_LEN 4
|
||||||
/* word in permanent address message with the current multicast type */
|
/* word in permanent address message with the current multicast type */
|
||||||
|
|
|
@ -119,6 +119,9 @@ static int __ixgbe_enable_sriov(struct ixgbe_adapter *adapter)
|
||||||
|
|
||||||
/* Untrust all VFs */
|
/* Untrust all VFs */
|
||||||
adapter->vfinfo[i].trusted = false;
|
adapter->vfinfo[i].trusted = false;
|
||||||
|
|
||||||
|
/* set the default xcast mode */
|
||||||
|
adapter->vfinfo[i].xcast_mode = IXGBEVF_XCAST_MODE_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1004,6 +1007,59 @@ static int ixgbe_get_vf_rss_key(struct ixgbe_adapter *adapter,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int ixgbe_update_vf_xcast_mode(struct ixgbe_adapter *adapter,
|
||||||
|
u32 *msgbuf, u32 vf)
|
||||||
|
{
|
||||||
|
struct ixgbe_hw *hw = &adapter->hw;
|
||||||
|
int xcast_mode = msgbuf[1];
|
||||||
|
u32 vmolr, disable, enable;
|
||||||
|
|
||||||
|
/* verify the PF is supporting the correct APIs */
|
||||||
|
switch (adapter->vfinfo[vf].vf_api) {
|
||||||
|
case ixgbe_mbox_api_12:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return -EOPNOTSUPP;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (xcast_mode > IXGBEVF_XCAST_MODE_MULTI &&
|
||||||
|
!adapter->vfinfo[vf].trusted) {
|
||||||
|
xcast_mode = IXGBEVF_XCAST_MODE_MULTI;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (adapter->vfinfo[vf].xcast_mode == xcast_mode)
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
switch (xcast_mode) {
|
||||||
|
case IXGBEVF_XCAST_MODE_NONE:
|
||||||
|
disable = IXGBE_VMOLR_BAM | IXGBE_VMOLR_ROMPE | IXGBE_VMOLR_MPE;
|
||||||
|
enable = 0;
|
||||||
|
break;
|
||||||
|
case IXGBEVF_XCAST_MODE_MULTI:
|
||||||
|
disable = IXGBE_VMOLR_MPE;
|
||||||
|
enable = IXGBE_VMOLR_BAM | IXGBE_VMOLR_ROMPE;
|
||||||
|
break;
|
||||||
|
case IXGBEVF_XCAST_MODE_ALLMULTI:
|
||||||
|
disable = 0;
|
||||||
|
enable = IXGBE_VMOLR_BAM | IXGBE_VMOLR_ROMPE | IXGBE_VMOLR_MPE;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return -EOPNOTSUPP;
|
||||||
|
}
|
||||||
|
|
||||||
|
vmolr = IXGBE_READ_REG(hw, IXGBE_VMOLR(vf));
|
||||||
|
vmolr &= ~disable;
|
||||||
|
vmolr |= enable;
|
||||||
|
IXGBE_WRITE_REG(hw, IXGBE_VMOLR(vf), vmolr);
|
||||||
|
|
||||||
|
adapter->vfinfo[vf].xcast_mode = xcast_mode;
|
||||||
|
|
||||||
|
out:
|
||||||
|
msgbuf[1] = xcast_mode;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int ixgbe_rcv_msg_from_vf(struct ixgbe_adapter *adapter, u32 vf)
|
static int ixgbe_rcv_msg_from_vf(struct ixgbe_adapter *adapter, u32 vf)
|
||||||
{
|
{
|
||||||
u32 mbx_size = IXGBE_VFMAILBOX_SIZE;
|
u32 mbx_size = IXGBE_VFMAILBOX_SIZE;
|
||||||
|
@ -1066,6 +1122,9 @@ static int ixgbe_rcv_msg_from_vf(struct ixgbe_adapter *adapter, u32 vf)
|
||||||
case IXGBE_VF_GET_RSS_KEY:
|
case IXGBE_VF_GET_RSS_KEY:
|
||||||
retval = ixgbe_get_vf_rss_key(adapter, msgbuf, vf);
|
retval = ixgbe_get_vf_rss_key(adapter, msgbuf, vf);
|
||||||
break;
|
break;
|
||||||
|
case IXGBE_VF_UPDATE_XCAST_MODE:
|
||||||
|
retval = ixgbe_update_vf_xcast_mode(adapter, msgbuf, vf);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
e_err(drv, "Unhandled Msg %8.8x\n", msgbuf[0]);
|
e_err(drv, "Unhandled Msg %8.8x\n", msgbuf[0]);
|
||||||
retval = IXGBE_ERR_MBX;
|
retval = IXGBE_ERR_MBX;
|
||||||
|
|
|
@ -471,6 +471,12 @@ enum ixgbevf_boards {
|
||||||
board_X550EM_x_vf,
|
board_X550EM_x_vf,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum ixgbevf_xcast_modes {
|
||||||
|
IXGBEVF_XCAST_MODE_NONE = 0,
|
||||||
|
IXGBEVF_XCAST_MODE_MULTI,
|
||||||
|
IXGBEVF_XCAST_MODE_ALLMULTI,
|
||||||
|
};
|
||||||
|
|
||||||
extern const struct ixgbevf_info ixgbevf_82599_vf_info;
|
extern const struct ixgbevf_info ixgbevf_82599_vf_info;
|
||||||
extern const struct ixgbevf_info ixgbevf_X540_vf_info;
|
extern const struct ixgbevf_info ixgbevf_X540_vf_info;
|
||||||
extern const struct ixgbevf_info ixgbevf_X550_vf_info;
|
extern const struct ixgbevf_info ixgbevf_X550_vf_info;
|
||||||
|
|
|
@ -1894,9 +1894,17 @@ static void ixgbevf_set_rx_mode(struct net_device *netdev)
|
||||||
{
|
{
|
||||||
struct ixgbevf_adapter *adapter = netdev_priv(netdev);
|
struct ixgbevf_adapter *adapter = netdev_priv(netdev);
|
||||||
struct ixgbe_hw *hw = &adapter->hw;
|
struct ixgbe_hw *hw = &adapter->hw;
|
||||||
|
unsigned int flags = netdev->flags;
|
||||||
|
int xcast_mode;
|
||||||
|
|
||||||
|
xcast_mode = (flags & IFF_ALLMULTI) ? IXGBEVF_XCAST_MODE_ALLMULTI :
|
||||||
|
(flags & (IFF_BROADCAST | IFF_MULTICAST)) ?
|
||||||
|
IXGBEVF_XCAST_MODE_MULTI : IXGBEVF_XCAST_MODE_NONE;
|
||||||
|
|
||||||
spin_lock_bh(&adapter->mbx_lock);
|
spin_lock_bh(&adapter->mbx_lock);
|
||||||
|
|
||||||
|
hw->mac.ops.update_xcast_mode(hw, netdev, xcast_mode);
|
||||||
|
|
||||||
/* reprogram multicast list */
|
/* reprogram multicast list */
|
||||||
hw->mac.ops.update_mc_addr_list(hw, netdev);
|
hw->mac.ops.update_mc_addr_list(hw, netdev);
|
||||||
|
|
||||||
|
|
|
@ -112,6 +112,8 @@ enum ixgbe_pfvf_api_rev {
|
||||||
#define IXGBE_VF_GET_RETA 0x0a /* VF request for RETA */
|
#define IXGBE_VF_GET_RETA 0x0a /* VF request for RETA */
|
||||||
#define IXGBE_VF_GET_RSS_KEY 0x0b /* get RSS hash key */
|
#define IXGBE_VF_GET_RSS_KEY 0x0b /* get RSS hash key */
|
||||||
|
|
||||||
|
#define IXGBE_VF_UPDATE_XCAST_MODE 0x0c
|
||||||
|
|
||||||
/* length of permanent address message returned from PF */
|
/* length of permanent address message returned from PF */
|
||||||
#define IXGBE_VF_PERMADDR_MSG_LEN 4
|
#define IXGBE_VF_PERMADDR_MSG_LEN 4
|
||||||
/* word in permanent address message with the current multicast type */
|
/* word in permanent address message with the current multicast type */
|
||||||
|
|
|
@ -468,6 +468,46 @@ static s32 ixgbevf_update_mc_addr_list_vf(struct ixgbe_hw *hw,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ixgbevf_update_xcast_mode - Update Multicast mode
|
||||||
|
* @hw: pointer to the HW structure
|
||||||
|
* @netdev: pointer to net device structure
|
||||||
|
* @xcast_mode: new multicast mode
|
||||||
|
*
|
||||||
|
* Updates the Multicast Mode of VF.
|
||||||
|
**/
|
||||||
|
static s32 ixgbevf_update_xcast_mode(struct ixgbe_hw *hw,
|
||||||
|
struct net_device *netdev, int xcast_mode)
|
||||||
|
{
|
||||||
|
struct ixgbe_mbx_info *mbx = &hw->mbx;
|
||||||
|
u32 msgbuf[2];
|
||||||
|
s32 err;
|
||||||
|
|
||||||
|
switch (hw->api_version) {
|
||||||
|
case ixgbe_mbox_api_12:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return -EOPNOTSUPP;
|
||||||
|
}
|
||||||
|
|
||||||
|
msgbuf[0] = IXGBE_VF_UPDATE_XCAST_MODE;
|
||||||
|
msgbuf[1] = xcast_mode;
|
||||||
|
|
||||||
|
err = mbx->ops.write_posted(hw, msgbuf, 2);
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
|
||||||
|
err = mbx->ops.read_posted(hw, msgbuf, 2);
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
|
||||||
|
msgbuf[0] &= ~IXGBE_VT_MSGTYPE_CTS;
|
||||||
|
if (msgbuf[0] == (IXGBE_VF_UPDATE_XCAST_MODE | IXGBE_VT_MSGTYPE_NACK))
|
||||||
|
return -EPERM;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ixgbevf_set_vfta_vf - Set/Unset VLAN filter table address
|
* ixgbevf_set_vfta_vf - Set/Unset VLAN filter table address
|
||||||
* @hw: pointer to the HW structure
|
* @hw: pointer to the HW structure
|
||||||
|
@ -727,6 +767,7 @@ static const struct ixgbe_mac_operations ixgbevf_mac_ops = {
|
||||||
.check_link = ixgbevf_check_mac_link_vf,
|
.check_link = ixgbevf_check_mac_link_vf,
|
||||||
.set_rar = ixgbevf_set_rar_vf,
|
.set_rar = ixgbevf_set_rar_vf,
|
||||||
.update_mc_addr_list = ixgbevf_update_mc_addr_list_vf,
|
.update_mc_addr_list = ixgbevf_update_mc_addr_list_vf,
|
||||||
|
.update_xcast_mode = ixgbevf_update_xcast_mode,
|
||||||
.set_uc_addr = ixgbevf_set_uc_addr_vf,
|
.set_uc_addr = ixgbevf_set_uc_addr_vf,
|
||||||
.set_vfta = ixgbevf_set_vfta_vf,
|
.set_vfta = ixgbevf_set_vfta_vf,
|
||||||
};
|
};
|
||||||
|
|
|
@ -63,6 +63,7 @@ struct ixgbe_mac_operations {
|
||||||
s32 (*set_uc_addr)(struct ixgbe_hw *, u32, u8 *);
|
s32 (*set_uc_addr)(struct ixgbe_hw *, u32, u8 *);
|
||||||
s32 (*init_rx_addrs)(struct ixgbe_hw *);
|
s32 (*init_rx_addrs)(struct ixgbe_hw *);
|
||||||
s32 (*update_mc_addr_list)(struct ixgbe_hw *, struct net_device *);
|
s32 (*update_mc_addr_list)(struct ixgbe_hw *, struct net_device *);
|
||||||
|
s32 (*update_xcast_mode)(struct ixgbe_hw *, struct net_device *, int);
|
||||||
s32 (*enable_mc)(struct ixgbe_hw *);
|
s32 (*enable_mc)(struct ixgbe_hw *);
|
||||||
s32 (*disable_mc)(struct ixgbe_hw *);
|
s32 (*disable_mc)(struct ixgbe_hw *);
|
||||||
s32 (*clear_vfta)(struct ixgbe_hw *);
|
s32 (*clear_vfta)(struct ixgbe_hw *);
|
||||||
|
|
Loading…
Reference in New Issue