Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/972076/?format=api
{ "id": 972076, "url": "http://patchwork.ozlabs.org/api/patches/972076/?format=api", "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20180920004308.13772-7-anirudh.venkataramanan@intel.com/", "project": { "id": 46, "url": "http://patchwork.ozlabs.org/api/projects/46/?format=api", "name": "Intel Wired Ethernet development", "link_name": "intel-wired-lan", "list_id": "intel-wired-lan.osuosl.org", "list_email": "intel-wired-lan@osuosl.org", "web_url": "", "scm_url": "", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20180920004308.13772-7-anirudh.venkataramanan@intel.com>", "list_archive_url": null, "date": "2018-09-20T00:42:58", "name": "[v2,06/16] ice: Add handlers for VF netdevice operations", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "74b01a2d6db8daba1e1b221c8357661bb6026fef", "submitter": { "id": 73601, "url": "http://patchwork.ozlabs.org/api/people/73601/?format=api", "name": "Anirudh Venkataramanan", "email": "anirudh.venkataramanan@intel.com" }, "delegate": { "id": 68, "url": "http://patchwork.ozlabs.org/api/users/68/?format=api", "username": "jtkirshe", "first_name": "Jeff", "last_name": "Kirsher", "email": "jeffrey.t.kirsher@intel.com" }, "mbox": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20180920004308.13772-7-anirudh.venkataramanan@intel.com/mbox/", "series": [ { "id": 66527, "url": "http://patchwork.ozlabs.org/api/series/66527/?format=api", "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/list/?series=66527", "date": "2018-09-20T00:42:53", "name": "Add SR-IOV support, feature updates", "version": 2, "mbox": "http://patchwork.ozlabs.org/series/66527/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/972076/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/972076/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<intel-wired-lan-bounces@osuosl.org>", "X-Original-To": [ "incoming@patchwork.ozlabs.org", "intel-wired-lan@lists.osuosl.org" ], "Delivered-To": [ "patchwork-incoming@bilbo.ozlabs.org", "intel-wired-lan@lists.osuosl.org" ], "Authentication-Results": [ "ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=osuosl.org\n\t(client-ip=140.211.166.136; helo=silver.osuosl.org;\n\tenvelope-from=intel-wired-lan-bounces@osuosl.org;\n\treceiver=<UNKNOWN>)", "ozlabs.org;\n\tdmarc=fail (p=none dis=none) header.from=intel.com" ], "Received": [ "from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 42FydZ1bdSz9sBJ\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 20 Sep 2018 10:43:30 +1000 (AEST)", "from localhost (localhost [127.0.0.1])\n\tby silver.osuosl.org (Postfix) with ESMTP id 9DD8E227A0;\n\tThu, 20 Sep 2018 00:43:28 +0000 (UTC)", "from silver.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id EPsipQoRPpgW; Thu, 20 Sep 2018 00:43:18 +0000 (UTC)", "from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby silver.osuosl.org (Postfix) with ESMTP id 20F1D30973;\n\tThu, 20 Sep 2018 00:43:14 +0000 (UTC)", "from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133])\n\tby ash.osuosl.org (Postfix) with ESMTP id 1F2001C08AF\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tThu, 20 Sep 2018 00:43:12 +0000 (UTC)", "from localhost (localhost [127.0.0.1])\n\tby hemlock.osuosl.org (Postfix) with ESMTP id 1A0C388AEA\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tThu, 20 Sep 2018 00:43:12 +0000 (UTC)", "from hemlock.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id wBlGh-kKxS8u for <intel-wired-lan@lists.osuosl.org>;\n\tThu, 20 Sep 2018 00:43:10 +0000 (UTC)", "from mga11.intel.com (mga11.intel.com [192.55.52.93])\n\tby hemlock.osuosl.org (Postfix) with ESMTPS id BC10B88ADB\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tThu, 20 Sep 2018 00:43:10 +0000 (UTC)", "from orsmga004.jf.intel.com ([10.7.209.38])\n\tby fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t19 Sep 2018 17:43:10 -0700", "from shasta.jf.intel.com ([10.166.241.11])\n\tby orsmga004.jf.intel.com with ESMTP; 19 Sep 2018 17:43:09 -0700" ], "X-Virus-Scanned": [ "amavisd-new at osuosl.org", "amavisd-new at osuosl.org" ], "X-Greylist": "domain auto-whitelisted by SQLgrey-1.7.6", "X-Amp-Result": "SKIPPED(no attachment in message)", "X-Amp-File-Uploaded": "False", "X-ExtLoop1": "1", "X-IronPort-AV": "E=Sophos;i=\"5.53,396,1531810800\"; d=\"scan'208\";a=\"234371596\"", "From": "Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>", "To": "intel-wired-lan@lists.osuosl.org", "Date": "Wed, 19 Sep 2018 17:42:58 -0700", "Message-Id": "<20180920004308.13772-7-anirudh.venkataramanan@intel.com>", "X-Mailer": "git-send-email 2.14.3", "In-Reply-To": "<20180920004308.13772-1-anirudh.venkataramanan@intel.com>", "References": "<20180920004308.13772-1-anirudh.venkataramanan@intel.com>", "Subject": "[Intel-wired-lan] [PATCH v2 06/16] ice: Add handlers for VF\n\tnetdevice operations", "X-BeenThere": "intel-wired-lan@osuosl.org", "X-Mailman-Version": "2.1.24", "Precedence": "list", "List-Id": "Intel Wired Ethernet Linux Kernel Driver Development\n\t<intel-wired-lan.osuosl.org>", "List-Unsubscribe": "<https://lists.osuosl.org/mailman/options/intel-wired-lan>, \n\t<mailto:intel-wired-lan-request@osuosl.org?subject=unsubscribe>", "List-Archive": "<http://lists.osuosl.org/pipermail/intel-wired-lan/>", "List-Post": "<mailto:intel-wired-lan@osuosl.org>", "List-Help": "<mailto:intel-wired-lan-request@osuosl.org?subject=help>", "List-Subscribe": "<https://lists.osuosl.org/mailman/listinfo/intel-wired-lan>, \n\t<mailto:intel-wired-lan-request@osuosl.org?subject=subscribe>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=\"us-ascii\"", "Content-Transfer-Encoding": "7bit", "Errors-To": "intel-wired-lan-bounces@osuosl.org", "Sender": "\"Intel-wired-lan\" <intel-wired-lan-bounces@osuosl.org>" }, "content": "This patch implements handlers for the following NDO operations:\n\n.ndo_set_vf_spoofchk\n.ndo_set_vf_mac\n.ndo_get_vf_config\n.ndo_set_vf_trust\n.ndo_set_vf_vlan\n.ndo_set_vf_link_state\n\nSigned-off-by: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>\n---\n drivers/net/ethernet/intel/ice/ice_lan_tx_rx.h | 12 +\n drivers/net/ethernet/intel/ice/ice_main.c | 6 +\n drivers/net/ethernet/intel/ice/ice_sriov.c | 86 +++++\n drivers/net/ethernet/intel/ice/ice_sriov.h | 9 +\n drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c | 438 +++++++++++++++++++++++\n drivers/net/ethernet/intel/ice/ice_virtchnl_pf.h | 79 +++-\n 6 files changed, 629 insertions(+), 1 deletion(-)", "diff": "diff --git a/drivers/net/ethernet/intel/ice/ice_lan_tx_rx.h b/drivers/net/ethernet/intel/ice/ice_lan_tx_rx.h\nindex f5269f780e1c..7d2a66739e3f 100644\n--- a/drivers/net/ethernet/intel/ice/ice_lan_tx_rx.h\n+++ b/drivers/net/ethernet/intel/ice/ice_lan_tx_rx.h\n@@ -474,4 +474,16 @@ static inline struct ice_rx_ptype_decoded ice_decode_rx_desc_ptype(u16 ptype)\n {\n \treturn ice_ptype_lkup[ptype];\n }\n+\n+#define ICE_LINK_SPEED_UNKNOWN\t\t0\n+#define ICE_LINK_SPEED_10MBPS\t\t10\n+#define ICE_LINK_SPEED_100MBPS\t\t100\n+#define ICE_LINK_SPEED_1000MBPS\t\t1000\n+#define ICE_LINK_SPEED_2500MBPS\t\t2500\n+#define ICE_LINK_SPEED_5000MBPS\t\t5000\n+#define ICE_LINK_SPEED_10000MBPS\t10000\n+#define ICE_LINK_SPEED_20000MBPS\t20000\n+#define ICE_LINK_SPEED_25000MBPS\t25000\n+#define ICE_LINK_SPEED_40000MBPS\t40000\n+\n #endif /* _ICE_LAN_TX_RX_H_ */\ndiff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c\nindex 9dd12f6cab98..bb66b614be90 100644\n--- a/drivers/net/ethernet/intel/ice/ice_main.c\n+++ b/drivers/net/ethernet/intel/ice/ice_main.c\n@@ -3905,6 +3905,12 @@ static const struct net_device_ops ice_netdev_ops = {\n #ifdef CONFIG_NET_POLL_CONTROLLER\n \t.ndo_poll_controller = ice_netpoll,\n #endif /* CONFIG_NET_POLL_CONTROLLER */\n+\t.ndo_set_vf_spoofchk = ice_set_vf_spoofchk,\n+\t.ndo_set_vf_mac = ice_set_vf_mac,\n+\t.ndo_get_vf_config = ice_get_vf_cfg,\n+\t.ndo_set_vf_trust = ice_set_vf_trust,\n+\t.ndo_set_vf_vlan = ice_set_vf_port_vlan,\n+\t.ndo_set_vf_link_state\t= ice_set_vf_link_state,\n \t.ndo_vlan_rx_add_vid = ice_vlan_rx_add_vid,\n \t.ndo_vlan_rx_kill_vid = ice_vlan_rx_kill_vid,\n \t.ndo_set_features = ice_set_features,\ndiff --git a/drivers/net/ethernet/intel/ice/ice_sriov.c b/drivers/net/ethernet/intel/ice/ice_sriov.c\nindex 191e832134b6..b75713809997 100644\n--- a/drivers/net/ethernet/intel/ice/ice_sriov.c\n+++ b/drivers/net/ethernet/intel/ice/ice_sriov.c\n@@ -39,3 +39,89 @@ ice_aq_send_msg_to_vf(struct ice_hw *hw, u16 vfid, u32 v_opcode, u32 v_retval,\n \n \treturn ice_sq_send_cmd(hw, &hw->mailboxq, &desc, msg, msglen, cd);\n }\n+\n+/**\n+ * ice_conv_link_speed_to_virtchnl\n+ * @adv_link_support: determines the format of the returned link speed\n+ * @link_speed: variable containing the link_speed to be converted\n+ *\n+ * Convert link speed supported by hw to link speed supported by virtchnl.\n+ * If adv_link_support is true, then return link speed in Mbps. Else return\n+ * link speed as a VIRTCHNL_LINK_SPEED_* casted to a u32. Note that the caller\n+ * needs to cast back to an enum virtchnl_link_speed in the case where\n+ * adv_link_support is false, but when adv_link_support is true the caller can\n+ * expect the speed in Mbps.\n+ */\n+u32 ice_conv_link_speed_to_virtchnl(bool adv_link_support, u16 link_speed)\n+{\n+\tu32 speed;\n+\n+\tif (adv_link_support)\n+\t\tswitch (link_speed) {\n+\t\tcase ICE_AQ_LINK_SPEED_10MB:\n+\t\t\tspeed = ICE_LINK_SPEED_10MBPS;\n+\t\t\tbreak;\n+\t\tcase ICE_AQ_LINK_SPEED_100MB:\n+\t\t\tspeed = ICE_LINK_SPEED_100MBPS;\n+\t\t\tbreak;\n+\t\tcase ICE_AQ_LINK_SPEED_1000MB:\n+\t\t\tspeed = ICE_LINK_SPEED_1000MBPS;\n+\t\t\tbreak;\n+\t\tcase ICE_AQ_LINK_SPEED_2500MB:\n+\t\t\tspeed = ICE_LINK_SPEED_2500MBPS;\n+\t\t\tbreak;\n+\t\tcase ICE_AQ_LINK_SPEED_5GB:\n+\t\t\tspeed = ICE_LINK_SPEED_5000MBPS;\n+\t\t\tbreak;\n+\t\tcase ICE_AQ_LINK_SPEED_10GB:\n+\t\t\tspeed = ICE_LINK_SPEED_10000MBPS;\n+\t\t\tbreak;\n+\t\tcase ICE_AQ_LINK_SPEED_20GB:\n+\t\t\tspeed = ICE_LINK_SPEED_20000MBPS;\n+\t\t\tbreak;\n+\t\tcase ICE_AQ_LINK_SPEED_25GB:\n+\t\t\tspeed = ICE_LINK_SPEED_25000MBPS;\n+\t\t\tbreak;\n+\t\tcase ICE_AQ_LINK_SPEED_40GB:\n+\t\t\tspeed = ICE_LINK_SPEED_40000MBPS;\n+\t\t\tbreak;\n+\t\tdefault:\n+\t\t\tspeed = ICE_LINK_SPEED_UNKNOWN;\n+\t\t\tbreak;\n+\t\t}\n+\telse\n+\t\t/* Virtchnl speeds are not defined for every speed supported in\n+\t\t * the hardware. To maintain compatibility with older AVF\n+\t\t * drivers, while reporting the speed the new speed values are\n+\t\t * resolved to the closest known virtchnl speeds\n+\t\t */\n+\t\tswitch (link_speed) {\n+\t\tcase ICE_AQ_LINK_SPEED_10MB:\n+\t\tcase ICE_AQ_LINK_SPEED_100MB:\n+\t\t\tspeed = (u32)VIRTCHNL_LINK_SPEED_100MB;\n+\t\t\tbreak;\n+\t\tcase ICE_AQ_LINK_SPEED_1000MB:\n+\t\tcase ICE_AQ_LINK_SPEED_2500MB:\n+\t\tcase ICE_AQ_LINK_SPEED_5GB:\n+\t\t\tspeed = (u32)VIRTCHNL_LINK_SPEED_1GB;\n+\t\t\tbreak;\n+\t\tcase ICE_AQ_LINK_SPEED_10GB:\n+\t\t\tspeed = (u32)VIRTCHNL_LINK_SPEED_10GB;\n+\t\t\tbreak;\n+\t\tcase ICE_AQ_LINK_SPEED_20GB:\n+\t\t\tspeed = (u32)VIRTCHNL_LINK_SPEED_20GB;\n+\t\t\tbreak;\n+\t\tcase ICE_AQ_LINK_SPEED_25GB:\n+\t\t\tspeed = (u32)VIRTCHNL_LINK_SPEED_25GB;\n+\t\t\tbreak;\n+\t\tcase ICE_AQ_LINK_SPEED_40GB:\n+\t\t\t/* fall through */\n+\t\t\tspeed = (u32)VIRTCHNL_LINK_SPEED_40GB;\n+\t\t\tbreak;\n+\t\tdefault:\n+\t\t\tspeed = (u32)VIRTCHNL_LINK_SPEED_UNKNOWN;\n+\t\t\tbreak;\n+\t\t}\n+\n+\treturn speed;\n+}\ndiff --git a/drivers/net/ethernet/intel/ice/ice_sriov.h b/drivers/net/ethernet/intel/ice/ice_sriov.h\nindex f9b86fd05c8b..3d78a0795138 100644\n--- a/drivers/net/ethernet/intel/ice/ice_sriov.h\n+++ b/drivers/net/ethernet/intel/ice/ice_sriov.h\n@@ -11,6 +11,7 @@ enum ice_status\n ice_aq_send_msg_to_vf(struct ice_hw *hw, u16 vfid, u32 v_opcode, u32 v_retval,\n \t\t u8 *msg, u16 msglen, struct ice_sq_cd *cd);\n \n+u32 ice_conv_link_speed_to_virtchnl(bool adv_link_support, u16 link_speed);\n #else /* CONFIG_PCI_IOV */\n static inline enum ice_status\n ice_aq_send_msg_to_vf(struct ice_hw __always_unused *hw,\n@@ -21,5 +22,13 @@ ice_aq_send_msg_to_vf(struct ice_hw __always_unused *hw,\n {\n \treturn 0;\n }\n+\n+static inline u32\n+ice_conv_link_speed_to_virtchnl(bool __always_unused adv_link_support,\n+\t\t\t\tu16 __always_unused link_speed)\n+{\n+\treturn 0;\n+}\n+\n #endif /* CONFIG_PCI_IOV */\n #endif /* _ICE_SRIOV_H_ */\ndiff --git a/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c b/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c\nindex f8f5cccb0b5c..a73bfc5f434c 100644\n--- a/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c\n+++ b/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c\n@@ -34,6 +34,51 @@ ice_vc_vf_broadcast(struct ice_pf *pf, enum virtchnl_ops v_opcode,\n \t}\n }\n \n+/**\n+ * ice_set_pfe_link - Set the link speed/status of the virtchnl_pf_event\n+ * @vf: pointer to the VF structure\n+ * @pfe: pointer to the virtchnl_pf_event to set link speed/status for\n+ * @ice_link_speed: link speed specified by ICE_AQ_LINK_SPEED_*\n+ * @link_up: whether or not to set the link up/down\n+ */\n+static void\n+ice_set_pfe_link(struct ice_vf *vf, struct virtchnl_pf_event *pfe,\n+\t\t int ice_link_speed, bool link_up)\n+{\n+\tif (vf->driver_caps & VIRTCHNL_VF_CAP_ADV_LINK_SPEED) {\n+\t\tpfe->event_data.link_event_adv.link_status = link_up;\n+\t\t/* Speed in Mbps */\n+\t\tpfe->event_data.link_event_adv.link_speed =\n+\t\t\tice_conv_link_speed_to_virtchnl(true, ice_link_speed);\n+\t} else {\n+\t\tpfe->event_data.link_event.link_status = link_up;\n+\t\t/* Legacy method for virtchnl link speeds */\n+\t\tpfe->event_data.link_event.link_speed =\n+\t\t\t(enum virtchnl_link_speed)\n+\t\t\tice_conv_link_speed_to_virtchnl(false, ice_link_speed);\n+\t}\n+}\n+\n+/**\n+ * ice_set_pfe_link_forced - Force the virtchnl_pf_event link speed/status\n+ * @vf: pointer to the VF structure\n+ * @pfe: pointer to the virtchnl_pf_event to set link speed/status for\n+ * @link_up: whether or not to set the link up/down\n+ */\n+static void\n+ice_set_pfe_link_forced(struct ice_vf *vf, struct virtchnl_pf_event *pfe,\n+\t\t\tbool link_up)\n+{\n+\tu16 link_speed;\n+\n+\tif (link_up)\n+\t\tlink_speed = ICE_AQ_LINK_SPEED_40GB;\n+\telse\n+\t\tlink_speed = ICE_AQ_LINK_SPEED_UNKNOWN;\n+\n+\tice_set_pfe_link(vf, pfe, link_speed, link_up);\n+}\n+\n /**\n * ice_get_vf_vector - get VF interrupt vector register offset\n * @vf_msix: number of msix vector per VF on a PF\n@@ -291,6 +336,24 @@ static int ice_vsi_set_pvid(struct ice_vsi *vsi, u16 vid)\n \treturn 0;\n }\n \n+/**\n+ * ice_vsi_kill_pvid - Remove port VLAN id from the VSI\n+ * @vsi: the VSI being changed\n+ */\n+static int ice_vsi_kill_pvid(struct ice_vsi *vsi)\n+{\n+\tstruct ice_pf *pf = vsi->back;\n+\n+\tif (ice_vsi_manage_vlan_stripping(vsi, false)) {\n+\t\tdev_err(&pf->pdev->dev, \"Error removing Port VLAN on VSI %i\\n\",\n+\t\t\tvsi->vsi_num);\n+\t\treturn -ENODEV;\n+\t}\n+\n+\tvsi->info.pvid = 0;\n+\treturn 0;\n+}\n+\n /**\n * ice_vf_vsi_setup - Set up a VF VSI\n * @pf: board private structure\n@@ -814,6 +877,29 @@ void ice_vc_notify_reset(struct ice_pf *pf)\n \t\t\t (u8 *)&pfe, sizeof(struct virtchnl_pf_event));\n }\n \n+/**\n+ * ice_vc_notify_vf_reset - Notify VF of a reset event\n+ * @vf: pointer to the VF structure\n+ */\n+static void ice_vc_notify_vf_reset(struct ice_vf *vf)\n+{\n+\tstruct virtchnl_pf_event pfe;\n+\n+\t/* validate the request */\n+\tif (!vf || vf->vf_id >= vf->pf->num_alloc_vfs)\n+\t\treturn;\n+\n+\t/* verify if the VF is in either init or active before proceeding */\n+\tif (!test_bit(ICE_VF_STATE_INIT, vf->vf_states) &&\n+\t !test_bit(ICE_VF_STATE_ACTIVE, vf->vf_states))\n+\t\treturn;\n+\n+\tpfe.event = VIRTCHNL_EVENT_RESET_IMPENDING;\n+\tpfe.severity = PF_EVENT_SEVERITY_CERTAIN_DOOM;\n+\tice_aq_send_msg_to_vf(&vf->pf->hw, vf->vf_id, VIRTCHNL_OP_EVENT, 0,\n+\t\t\t (u8 *)&pfe, sizeof(pfe), NULL);\n+}\n+\n /**\n * ice_alloc_vfs - Allocate and set up VFs resources\n * @pf: pointer to the PF structure\n@@ -1008,3 +1094,355 @@ void ice_process_vflr_event(struct ice_pf *pf)\n \t\t\tice_reset_vf(vf, true);\n \t}\n }\n+\n+/**\n+ * ice_vc_dis_vf - Disable a given VF via SW reset\n+ * @vf: pointer to the VF info\n+ *\n+ * Disable the VF through a SW reset\n+ */\n+static void ice_vc_dis_vf(struct ice_vf *vf)\n+{\n+\tice_vc_notify_vf_reset(vf);\n+\tice_reset_vf(vf, false);\n+}\n+\n+/**\n+ * ice_set_vf_port_vlan\n+ * @netdev: network interface device structure\n+ * @vf_id: VF identifier\n+ * @vlan_id: VLAN id being set\n+ * @qos: priority setting\n+ * @vlan_proto: VLAN protocol\n+ *\n+ * program VF Port VLAN id and/or qos\n+ */\n+int\n+ice_set_vf_port_vlan(struct net_device *netdev, int vf_id, u16 vlan_id, u8 qos,\n+\t\t __be16 vlan_proto)\n+{\n+\tu16 vlanprio = vlan_id | (qos << ICE_VLAN_PRIORITY_S);\n+\tstruct ice_netdev_priv *np = netdev_priv(netdev);\n+\tstruct ice_pf *pf = np->vsi->back;\n+\tstruct ice_vsi *vsi;\n+\tstruct ice_vf *vf;\n+\tint ret = 0;\n+\n+\t/* validate the request */\n+\tif (vf_id >= pf->num_alloc_vfs) {\n+\t\tdev_err(&pf->pdev->dev, \"invalid VF id: %d\\n\", vf_id);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tif (vlan_id > ICE_MAX_VLANID || qos > 7) {\n+\t\tdev_err(&pf->pdev->dev, \"Invalid VF Parameters\\n\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tif (vlan_proto != htons(ETH_P_8021Q)) {\n+\t\tdev_err(&pf->pdev->dev, \"VF VLAN protocol is not supported\\n\");\n+\t\treturn -EPROTONOSUPPORT;\n+\t}\n+\n+\tvf = &pf->vf[vf_id];\n+\tvsi = pf->vsi[vf->lan_vsi_idx];\n+\tif (!test_bit(ICE_VF_STATE_INIT, vf->vf_states)) {\n+\t\tdev_err(&pf->pdev->dev, \"VF %d in reset. Try again.\\n\", vf_id);\n+\t\treturn -EBUSY;\n+\t}\n+\n+\tif (le16_to_cpu(vsi->info.pvid) == vlanprio) {\n+\t\t/* duplicate request, so just return success */\n+\t\tdev_info(&pf->pdev->dev,\n+\t\t\t \"Duplicate pvid %d request\\n\", vlanprio);\n+\t\treturn ret;\n+\t}\n+\n+\t/* If pvid, then remove all filters on the old VLAN */\n+\tif (vsi->info.pvid)\n+\t\tice_vsi_kill_vlan(vsi, (le16_to_cpu(vsi->info.pvid) &\n+\t\t\t\t VLAN_VID_MASK));\n+\n+\tif (vlan_id || qos) {\n+\t\tret = ice_vsi_set_pvid(vsi, vlanprio);\n+\t\tif (ret)\n+\t\t\tgoto error_set_pvid;\n+\t} else {\n+\t\tice_vsi_kill_pvid(vsi);\n+\t}\n+\n+\tif (vlan_id) {\n+\t\tdev_info(&pf->pdev->dev, \"Setting VLAN %d, QOS 0x%x on VF %d\\n\",\n+\t\t\t vlan_id, qos, vf_id);\n+\n+\t\t/* add new VLAN filter for each MAC */\n+\t\tret = ice_vsi_add_vlan(vsi, vlan_id);\n+\t\tif (ret)\n+\t\t\tgoto error_set_pvid;\n+\t}\n+\n+\t/* The Port VLAN needs to be saved across resets the same as the\n+\t * default LAN MAC address.\n+\t */\n+\tvf->port_vlan_id = le16_to_cpu(vsi->info.pvid);\n+\n+error_set_pvid:\n+\treturn ret;\n+}\n+\n+/**\n+ * ice_get_vf_cfg\n+ * @netdev: network interface device structure\n+ * @vf_id: VF identifier\n+ * @ivi: VF configuration structure\n+ *\n+ * return VF configuration\n+ */\n+int ice_get_vf_cfg(struct net_device *netdev, int vf_id,\n+\t\t struct ifla_vf_info *ivi)\n+{\n+\tstruct ice_netdev_priv *np = netdev_priv(netdev);\n+\tstruct ice_vsi *vsi = np->vsi;\n+\tstruct ice_pf *pf = vsi->back;\n+\tstruct ice_vf *vf;\n+\n+\t/* validate the request */\n+\tif (vf_id >= pf->num_alloc_vfs) {\n+\t\tnetdev_err(netdev, \"invalid VF id: %d\\n\", vf_id);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tvf = &pf->vf[vf_id];\n+\tvsi = pf->vsi[vf->lan_vsi_idx];\n+\n+\tif (!test_bit(ICE_VF_STATE_INIT, vf->vf_states)) {\n+\t\tnetdev_err(netdev, \"VF %d in reset. Try again.\\n\", vf_id);\n+\t\treturn -EBUSY;\n+\t}\n+\n+\tivi->vf = vf_id;\n+\tether_addr_copy(ivi->mac, vf->dflt_lan_addr.addr);\n+\n+\t/* VF configuration for VLAN and applicable QoS */\n+\tivi->vlan = le16_to_cpu(vsi->info.pvid) & ICE_VLAN_M;\n+\tivi->qos = (le16_to_cpu(vsi->info.pvid) & ICE_PRIORITY_M) >>\n+\t\t ICE_VLAN_PRIORITY_S;\n+\n+\tivi->trusted = vf->trusted;\n+\tivi->spoofchk = vf->spoofchk;\n+\tif (!vf->link_forced)\n+\t\tivi->linkstate = IFLA_VF_LINK_STATE_AUTO;\n+\telse if (vf->link_up)\n+\t\tivi->linkstate = IFLA_VF_LINK_STATE_ENABLE;\n+\telse\n+\t\tivi->linkstate = IFLA_VF_LINK_STATE_DISABLE;\n+\tivi->max_tx_rate = vf->tx_rate;\n+\tivi->min_tx_rate = 0;\n+\treturn 0;\n+}\n+\n+/**\n+ * ice_set_vf_spoofchk\n+ * @netdev: network interface device structure\n+ * @vf_id: VF identifier\n+ * @ena: flag to enable or disable feature\n+ *\n+ * Enable or disable VF spoof checking\n+ */\n+int ice_set_vf_spoofchk(struct net_device *netdev, int vf_id, bool ena)\n+{\n+\tstruct ice_netdev_priv *np = netdev_priv(netdev);\n+\tstruct ice_vsi_ctx ctx = { 0 };\n+\tstruct ice_vsi *vsi = np->vsi;\n+\tstruct ice_pf *pf = vsi->back;\n+\tstruct ice_vf *vf;\n+\tint status;\n+\n+\t/* validate the request */\n+\tif (vf_id >= pf->num_alloc_vfs) {\n+\t\tnetdev_err(netdev, \"invalid VF id: %d\\n\", vf_id);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tvf = &pf->vf[vf_id];\n+\tif (!test_bit(ICE_VF_STATE_INIT, vf->vf_states)) {\n+\t\tnetdev_err(netdev, \"VF %d in reset. Try again.\\n\", vf_id);\n+\t\treturn -EBUSY;\n+\t}\n+\n+\tif (ena == vf->spoofchk) {\n+\t\tdev_dbg(&pf->pdev->dev, \"VF spoofchk already %s\\n\",\n+\t\t\tena ? \"ON\" : \"OFF\");\n+\t\treturn 0;\n+\t}\n+\n+\tctx.info.valid_sections = cpu_to_le16(ICE_AQ_VSI_PROP_SECURITY_VALID);\n+\n+\tif (ena) {\n+\t\tctx.info.sec_flags |= ICE_AQ_VSI_SEC_FLAG_ENA_MAC_ANTI_SPOOF;\n+\t\tctx.info.sw_flags2 |= ICE_AQ_VSI_SW_FLAG_RX_PRUNE_EN_M;\n+\t}\n+\n+\tstatus = ice_update_vsi(&pf->hw, vsi->idx, &ctx, NULL);\n+\tif (status) {\n+\t\tdev_dbg(&pf->pdev->dev,\n+\t\t\t\"Error %d, failed to update VSI* parameters\\n\", status);\n+\t\treturn -EIO;\n+\t}\n+\n+\tvf->spoofchk = ena;\n+\tvsi->info.sec_flags = ctx.info.sec_flags;\n+\tvsi->info.sw_flags2 = ctx.info.sw_flags2;\n+\n+\treturn status;\n+}\n+\n+/**\n+ * ice_set_vf_mac\n+ * @netdev: network interface device structure\n+ * @vf_id: VF identifier\n+ * @mac: mac address\n+ *\n+ * program VF mac address\n+ */\n+int ice_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac)\n+{\n+\tstruct ice_netdev_priv *np = netdev_priv(netdev);\n+\tstruct ice_vsi *vsi = np->vsi;\n+\tstruct ice_pf *pf = vsi->back;\n+\tstruct ice_vf *vf;\n+\tint ret = 0;\n+\n+\t/* validate the request */\n+\tif (vf_id >= pf->num_alloc_vfs) {\n+\t\tnetdev_err(netdev, \"invalid VF id: %d\\n\", vf_id);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tvf = &pf->vf[vf_id];\n+\tif (!test_bit(ICE_VF_STATE_INIT, vf->vf_states)) {\n+\t\tnetdev_err(netdev, \"VF %d in reset. Try again.\\n\", vf_id);\n+\t\treturn -EBUSY;\n+\t}\n+\n+\tif (is_zero_ether_addr(mac) || is_multicast_ether_addr(mac)) {\n+\t\tnetdev_err(netdev, \"%pM not a valid unicast address\\n\", mac);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\t/* copy mac into dflt_lan_addr and trigger a VF reset. The reset\n+\t * flow will use the updated dflt_lan_addr and add a MAC filter\n+\t * using ice_add_mac. Also set pf_set_mac to indicate that the PF has\n+\t * set the MAC address for this VF.\n+\t */\n+\tether_addr_copy(vf->dflt_lan_addr.addr, mac);\n+\tvf->pf_set_mac = true;\n+\tnetdev_info(netdev,\n+\t\t \"mac on VF %d set to %pM\\n. VF driver will be reinitialized\\n\",\n+\t\t vf_id, mac);\n+\n+\tice_vc_dis_vf(vf);\n+\treturn ret;\n+}\n+\n+/**\n+ * ice_set_vf_trust\n+ * @netdev: network interface device structure\n+ * @vf_id: VF identifier\n+ * @trusted: Boolean value to enable/disable trusted vf\n+ *\n+ * Enable or disable a given VF as trusted\n+ */\n+int ice_set_vf_trust(struct net_device *netdev, int vf_id, bool trusted)\n+{\n+\tstruct ice_netdev_priv *np = netdev_priv(netdev);\n+\tstruct ice_vsi *vsi = np->vsi;\n+\tstruct ice_pf *pf = vsi->back;\n+\tstruct ice_vf *vf;\n+\n+\t/* validate the request */\n+\tif (vf_id >= pf->num_alloc_vfs) {\n+\t\tdev_err(&pf->pdev->dev, \"invalid VF id: %d\\n\", vf_id);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tvf = &pf->vf[vf_id];\n+\tif (!test_bit(ICE_VF_STATE_INIT, vf->vf_states)) {\n+\t\tdev_err(&pf->pdev->dev, \"VF %d in reset. Try again.\\n\", vf_id);\n+\t\treturn -EBUSY;\n+\t}\n+\n+\t/* Check if already trusted */\n+\tif (trusted == vf->trusted)\n+\t\treturn 0;\n+\n+\tvf->trusted = trusted;\n+\tice_vc_dis_vf(vf);\n+\tdev_info(&pf->pdev->dev, \"VF %u is now %strusted\\n\",\n+\t\t vf_id, trusted ? \"\" : \"un\");\n+\n+\treturn 0;\n+}\n+\n+/**\n+ * ice_set_vf_link_state\n+ * @netdev: network interface device structure\n+ * @vf_id: VF identifier\n+ * @link_state: required link state\n+ *\n+ * Set VF's link state, irrespective of physical link state status\n+ */\n+int ice_set_vf_link_state(struct net_device *netdev, int vf_id, int link_state)\n+{\n+\tstruct ice_netdev_priv *np = netdev_priv(netdev);\n+\tstruct ice_pf *pf = np->vsi->back;\n+\tstruct virtchnl_pf_event pfe = { 0 };\n+\tstruct ice_link_status *ls;\n+\tstruct ice_vf *vf;\n+\tstruct ice_hw *hw;\n+\n+\tif (vf_id >= pf->num_alloc_vfs) {\n+\t\tdev_err(&pf->pdev->dev, \"Invalid VF Identifier %d\\n\", vf_id);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tvf = &pf->vf[vf_id];\n+\thw = &pf->hw;\n+\tls = &pf->hw.port_info->phy.link_info;\n+\n+\tif (!test_bit(ICE_VF_STATE_INIT, vf->vf_states)) {\n+\t\tdev_err(&pf->pdev->dev, \"vf %d in reset. Try again.\\n\", vf_id);\n+\t\treturn -EBUSY;\n+\t}\n+\n+\tpfe.event = VIRTCHNL_EVENT_LINK_CHANGE;\n+\tpfe.severity = PF_EVENT_SEVERITY_INFO;\n+\n+\tswitch (link_state) {\n+\tcase IFLA_VF_LINK_STATE_AUTO:\n+\t\tvf->link_forced = false;\n+\t\tvf->link_up = ls->link_info & ICE_AQ_LINK_UP;\n+\t\tbreak;\n+\tcase IFLA_VF_LINK_STATE_ENABLE:\n+\t\tvf->link_forced = true;\n+\t\tvf->link_up = true;\n+\t\tbreak;\n+\tcase IFLA_VF_LINK_STATE_DISABLE:\n+\t\tvf->link_forced = true;\n+\t\tvf->link_up = false;\n+\t\tbreak;\n+\tdefault:\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tif (vf->link_forced)\n+\t\tice_set_pfe_link_forced(vf, &pfe, vf->link_up);\n+\telse\n+\t\tice_set_pfe_link(vf, &pfe, ls->link_speed, vf->link_up);\n+\n+\t/* Notify the VF of its new link state */\n+\tice_aq_send_msg_to_vf(hw, vf->vf_id, VIRTCHNL_OP_EVENT, 0, (u8 *)&pfe,\n+\t\t\t sizeof(pfe), NULL);\n+\n+\treturn 0;\n+}\ndiff --git a/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.h b/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.h\nindex c6932559244f..4f9e5bc5851a 100644\n--- a/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.h\n+++ b/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.h\n@@ -5,6 +5,11 @@\n #define _ICE_VIRTCHNL_PF_H_\n #include \"ice.h\"\n \n+#define ICE_MAX_VLANID\t\t\t4095\n+#define ICE_VLAN_PRIORITY_S\t\t12\n+#define ICE_VLAN_M\t\t\t0xFFF\n+#define ICE_PRIORITY_M\t\t\t0x7000\n+\n /* Static VF transaction/status register def */\n #define VF_DEVICE_STATUS\t\t0xAA\n #define VF_TRANS_PENDING_M\t\t0x20\n@@ -36,15 +41,20 @@ struct ice_vf {\n \tstruct ice_pf *pf;\n \n \ts16 vf_id;\t\t\t/* VF id in the PF space */\n+\tu32 driver_caps;\t\t/* reported by VF driver */\n \tint first_vector_idx;\t\t/* first vector index of this VF */\n \tstruct ice_sw *vf_sw_id;\t/* switch id the VF VSIs connect to */\n \tstruct virtchnl_ether_addr dflt_lan_addr;\n \tu16 port_vlan_id;\n+\tu8 pf_set_mac;\t\t\t/* VF MAC address set by VMM admin */\n \tu8 trusted;\n \tu16 lan_vsi_idx;\t\t/* index into PF struct */\n \tu16 lan_vsi_num;\t\t/* ID as used by firmware */\n \tunsigned long vf_caps;\t\t/* vf's adv. capabilities */\n \tDECLARE_BITMAP(vf_states, ICE_VF_STATES_NBITS);\t/* vf runtime states */\n+\tunsigned int tx_rate;\t\t/* Tx bandwidth limit in Mbps */\n+\tu8 link_forced;\n+\tu8 link_up;\t\t\t/* only valid if VF link is forced */\n \tu8 spoofchk;\n \tu16 num_mac;\n \tu16 num_vlan;\n@@ -53,14 +63,29 @@ struct ice_vf {\n #ifdef CONFIG_PCI_IOV\n void ice_process_vflr_event(struct ice_pf *pf);\n int ice_sriov_configure(struct pci_dev *pdev, int num_vfs);\n+int ice_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac);\n+int ice_get_vf_cfg(struct net_device *netdev, int vf_id,\n+\t\t struct ifla_vf_info *ivi);\n+\n void ice_free_vfs(struct ice_pf *pf);\n void ice_vc_notify_reset(struct ice_pf *pf);\n bool ice_reset_all_vfs(struct ice_pf *pf, bool is_vflr);\n+\n+int ice_set_vf_port_vlan(struct net_device *netdev, int vf_id,\n+\t\t\t u16 vlan_id, u8 qos, __be16 vlan_proto);\n+\n+int ice_set_vf_bw(struct net_device *netdev, int vf_id, int min_tx_rate,\n+\t\t int max_tx_rate);\n+\n+int ice_set_vf_trust(struct net_device *netdev, int vf_id, bool trusted);\n+\n+int ice_set_vf_link_state(struct net_device *netdev, int vf_id, int link_state);\n+\n+int ice_set_vf_spoofchk(struct net_device *netdev, int vf_id, bool ena);\n #else /* CONFIG_PCI_IOV */\n #define ice_process_vflr_event(pf) do {} while (0)\n #define ice_free_vfs(pf) do {} while (0)\n #define ice_vc_notify_reset(pf) do {} while (0)\n-\n static inline bool\n ice_reset_all_vfs(struct ice_pf __always_unused *pf,\n \t\t bool __always_unused is_vflr)\n@@ -74,5 +99,57 @@ ice_sriov_configure(struct pci_dev __always_unused *pdev,\n {\n \treturn -EOPNOTSUPP;\n }\n+\n+static inline int\n+ice_set_vf_mac(struct net_device __always_unused *netdev,\n+\t int __always_unused vf_id, u8 __always_unused *mac)\n+{\n+\treturn -EOPNOTSUPP;\n+}\n+\n+static inline int\n+ice_get_vf_cfg(struct net_device __always_unused *netdev,\n+\t int __always_unused vf_id,\n+\t struct ifla_vf_info __always_unused *ivi)\n+{\n+\treturn -EOPNOTSUPP;\n+}\n+\n+static inline int\n+ice_set_vf_trust(struct net_device __always_unused *netdev,\n+\t\t int __always_unused vf_id, bool __always_unused trusted)\n+{\n+\treturn -EOPNOTSUPP;\n+}\n+\n+static inline int\n+ice_set_vf_port_vlan(struct net_device __always_unused *netdev,\n+\t\t int __always_unused vf_id, u16 __always_unused vid,\n+\t\t u8 __always_unused qos, __be16 __always_unused v_proto)\n+{\n+\treturn -EOPNOTSUPP;\n+}\n+\n+static inline int\n+ice_set_vf_spoofchk(struct net_device __always_unused *netdev,\n+\t\t int __always_unused vf_id, bool __always_unused ena)\n+{\n+\treturn -EOPNOTSUPP;\n+}\n+\n+static inline int\n+ice_set_vf_link_state(struct net_device __always_unused *netdev,\n+\t\t int __always_unused vf_id, int __always_unused link_state)\n+{\n+\treturn -EOPNOTSUPP;\n+}\n+\n+static inline int\n+ice_set_vf_bw(struct net_device __always_unused *netdev,\n+\t int __always_unused vf_id, int __always_unused min_tx_rate,\n+\t int __always_unused max_tx_rate)\n+{\n+\treturn -EOPNOTSUPP;\n+}\n #endif /* CONFIG_PCI_IOV */\n #endif /* _ICE_VIRTCHNL_PF_H_ */\n", "prefixes": [ "v2", "06/16" ] }