]> xenbits.xensource.com Git - people/royger/freebsd.git/commitdiff
ixv(4): Allow PF to control the VF link state
authorPiotr Pietruszewski <piotr.pietruszewski@intel.com>
Fri, 4 Mar 2022 18:33:02 +0000 (10:33 -0800)
committerEric Joyner <erj@FreeBSD.org>
Tue, 8 Mar 2022 00:11:58 +0000 (16:11 -0800)
This patch adds checks of a VF link state provided by PF via mailbox
API. Such change enables the PF to disable a VF administratively.

Since command needed by the PF to control the VF is introduced in
mailbox api version 1.2, this patch also bumps supported mailbox api
version to 1.2.

Co-authored-by: Krzysztof Galazka <krzysztof.galazka@intel.com>
Reviewed By: kbowling@
Tested by: lukasz.szczepaniak@intel.com
MFC after: 3 days
Sponsored by: Intel Corporation
Differential Revision: https://reviews.freebsd.org/D32004

(cherry picked from commit a3e719bbc21a56230a5b8adeb4c531a6dfb77940)

sys/dev/ixgbe/if_ixv.c
sys/dev/ixgbe/ixgbe.h
sys/dev/ixgbe/ixgbe_mbx.h
sys/dev/ixgbe/ixgbe_type.h
sys/dev/ixgbe/ixgbe_vf.c
sys/dev/ixgbe/ixgbe_vf.h

index 1c01add0347bd22069a91c9928e589d2442aff6f..813a8d5fc3ed223b36a782ef3a13a5bc27a60889 100644 (file)
@@ -463,6 +463,13 @@ ixv_if_attach_pre(if_ctx_t ctx)
                goto err_out;
        }
 
+       /* Check if VF was disabled by PF */
+       error = hw->mac.ops.get_link_state(hw, &sc->link_enabled);
+       if (error) {
+               /* PF is not capable of controlling VF state. Enable the link. */
+               sc->link_enabled = true;
+       }
+
        /* If no mac address was assigned, make a random one */
        if (!ixv_check_ether_addr(hw->mac.addr)) {
                ether_gen_addr(iflib_get_ifp(ctx),
@@ -648,6 +655,13 @@ ixv_if_init(if_ctx_t ctx)
        ixv_init_stats(sc);
 
        /* Config/Enable Link */
+       error = hw->mac.ops.get_link_state(hw, &sc->link_enabled);
+       if (error) {
+               /* PF is not capable of controlling VF state. Enable the link. */
+               sc->link_enabled = true;
+       } else if (sc->link_enabled == false)
+               device_printf(dev, "VF is disabled by PF\n");
+
        hw->mac.ops.check_link(hw, &sc->link_speed, &sc->link_up,
            false);
 
@@ -805,7 +819,8 @@ static int
 ixv_negotiate_api(struct ixgbe_softc *sc)
 {
        struct ixgbe_hw *hw = &sc->hw;
-       int             mbx_api[] = { ixgbe_mbox_api_11,
+       int             mbx_api[] = { ixgbe_mbox_api_12,
+                                     ixgbe_mbox_api_11,
                                      ixgbe_mbox_api_10,
                                      ixgbe_mbox_api_unknown };
        int             i = 0;
@@ -914,7 +929,7 @@ ixv_if_update_admin_status(if_ctx_t ctx)
                iflib_get_ifp(ctx)->if_init(ctx);
        }
 
-       if (sc->link_up) {
+       if (sc->link_up && sc->link_enabled) {
                if (sc->link_active == false) {
                        if (bootverbose)
                                device_printf(dev, "Link is up %d Gbps %s \n",
index 8581b01b4a371fb198b27251aa20baeabfb18708..e463fab7122b69e272f8967cbd58dfd810d765a9 100644 (file)
@@ -394,6 +394,7 @@ struct ixgbe_softc {
        u16                     num_segs;
        u32                     link_speed;
        bool                    link_up;
+       bool                    link_enabled;
        u32                     vector;
        u16                     dmac;
        u32                     phy_layer;
index 88387ea3f7c25aaa341cf50d8846a252a484eebf..c5940b0823b085ee5068254e24213b0f58ef5b34 100644 (file)
@@ -115,6 +115,7 @@ enum ixgbe_pfvf_api_rev {
 #define IXGBE_VF_GET_RETA      0x0a    /* VF request for RETA */
 #define IXGBE_VF_GET_RSS_KEY   0x0b    /* get RSS key */
 #define IXGBE_VF_UPDATE_XCAST_MODE     0x0c
+#define IXGBE_VF_GET_LINK_STATE  0x10
 
 /* mode choices for IXGBE_VF_UPDATE_XCAST_MODE */
 enum ixgbevf_xcast_modes {
index 769c47a143d885da8dfdd5f59af7e0e9f881e444..9fb800560e4388e23a772f35632651be15edcbc3 100644 (file)
@@ -4012,6 +4012,7 @@ struct ixgbe_mac_operations {
                                   ixgbe_mc_addr_itr);
        s32 (*update_mc_addr_list)(struct ixgbe_hw *, u8 *, u32,
                                   ixgbe_mc_addr_itr, bool clear);
+       s32 (*get_link_state)(struct ixgbe_hw *hw, bool *link_state);
        s32 (*enable_mc)(struct ixgbe_hw *);
        s32 (*disable_mc)(struct ixgbe_hw *);
        s32 (*clear_vfta)(struct ixgbe_hw *);
index f70f4d667aee623b9cc1b8efb89581665e23346f..75612a7f83cae12e282cf3c2fda66238e997e427 100644 (file)
@@ -73,6 +73,7 @@ s32 ixgbe_init_ops_vf(struct ixgbe_hw *hw)
        hw->mac.ops.init_rx_addrs = NULL;
        hw->mac.ops.update_mc_addr_list = ixgbe_update_mc_addr_list_vf;
        hw->mac.ops.update_xcast_mode = ixgbevf_update_xcast_mode;
+       hw->mac.ops.get_link_state = ixgbe_get_link_state_vf;
        hw->mac.ops.enable_mc = NULL;
        hw->mac.ops.disable_mc = NULL;
        hw->mac.ops.clear_vfta = NULL;
@@ -452,6 +453,34 @@ s32 ixgbevf_update_xcast_mode(struct ixgbe_hw *hw, int xcast_mode)
        return IXGBE_SUCCESS;
 }
 
+/**
+ * ixgbe_get_link_state_vf - Get VF link state from PF
+ * @hw: pointer to the HW structure
+ * @link_state: link state storage
+ *
+ * Returns state of the operation error or success.
+ **/
+s32 ixgbe_get_link_state_vf(struct ixgbe_hw *hw, bool *link_state)
+{
+       u32 msgbuf[2];
+       s32 err;
+       s32 ret_val;
+
+       msgbuf[0] = IXGBE_VF_GET_LINK_STATE;
+       msgbuf[1] = 0x0;
+
+       err = ixgbevf_write_msg_read_ack(hw, msgbuf, msgbuf, 2);
+
+       if (err || (msgbuf[0] & IXGBE_VT_MSGTYPE_NACK)) {
+               ret_val = IXGBE_ERR_MBX;
+       } else {
+               ret_val = IXGBE_SUCCESS;
+               *link_state = msgbuf[1];
+       }
+
+       return ret_val;
+}
+
 /**
  * ixgbe_set_vfta_vf - Set/Unset vlan filter table address
  * @hw: pointer to the HW structure
index 5cdb241ec2aa6984e98a2442e582c22ffe8419e1..49f3a173d561914dc880874f2b92f6345298fe2c 100644 (file)
@@ -135,6 +135,7 @@ s32 ixgbe_update_mc_addr_list_vf(struct ixgbe_hw *hw, u8 *mc_addr_list,
                                 u32 mc_addr_count, ixgbe_mc_addr_itr,
                                 bool clear);
 s32 ixgbevf_update_xcast_mode(struct ixgbe_hw *hw, int xcast_mode);
+s32 ixgbe_get_link_state_vf(struct ixgbe_hw *hw, bool *link_state);
 s32 ixgbe_set_vfta_vf(struct ixgbe_hw *hw, u32 vlan, u32 vind,
                      bool vlan_on, bool vlvf_bypass);
 s32 ixgbevf_rlpml_set_vf(struct ixgbe_hw *hw, u16 max_size);