From patchwork Thu Sep 1 20:30:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Samudrala, Sridhar" X-Patchwork-Id: 665035 X-Patchwork-Delegate: jeffrey.t.kirsher@intel.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3sQFtw5gyvz9s8x for ; Fri, 2 Sep 2016 07:36:24 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 51AB631B17; Thu, 1 Sep 2016 21:36:23 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id BwH+aUie4gZn; Thu, 1 Sep 2016 21:36:20 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 241EE31B24; Thu, 1 Sep 2016 21:36:20 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 7FECA1CE830 for ; Thu, 1 Sep 2016 21:36:18 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 7BFEE86267 for ; Thu, 1 Sep 2016 21:36:18 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id KYtqrsYd6RFY for ; Thu, 1 Sep 2016 21:36:17 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by hemlock.osuosl.org (Postfix) with ESMTPS id D692585AD0 for ; Thu, 1 Sep 2016 21:36:17 +0000 (UTC) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga104.fm.intel.com with ESMTP; 01 Sep 2016 14:36:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.30,268,1470726000"; d="scan'208";a="3841314" Received: from unknown (HELO sri-mi-02.jf.intel.com) ([10.166.31.66]) by orsmga005.jf.intel.com with ESMTP; 01 Sep 2016 14:36:17 -0700 From: Sridhar Samudrala To: intel-wired-lan@lists.osuosl.org, john.r.fastabend@intel.com, anjali.singhai@intel.com, alexander.h.duyck@intel.com Date: Thu, 1 Sep 2016 22:30:03 +0200 Message-Id: <1472761803-2683-1-git-send-email-sridhar.samudrala@intel.com> X-Mailer: git-send-email 2.5.5 Subject: [Intel-wired-lan] [dev-queue PATCH] i40e: Sync link state between VFs and VF Port representors(VFPR). X-BeenThere: intel-wired-lan@lists.osuosl.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-wired-lan-bounces@lists.osuosl.org Sender: "Intel-wired-lan" This patch enables - reflecting the link state of VFPR based on VF admin state & link state of VF based on admin state of VFPR. - bringing up/down the VFPR sends a notification to update VF link state. - bringing up/down the VF will cause the link state update of VFPR. - enable/disable VF link state via ndo_set_vf_link_state will update the admin state of associated VFPR. PF: enp5s0f0, VFs: enp5s2,enp5s2f1 VFPRs:enp5s0f0-vf0, enp5s0f0-vf1 # modprobe i40e # echo 2 > /sys/class/net/enp5s0f0/device/sriov_numvfs # ip link set enp5s2 up # ip link set enp5s0f0-vf0 up # ip link set enp5s0f0-vf1 up # ip link show enp5s0f0-vf0 215: enp5s0f0-vf0: mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000 link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff /* enp5s0f0-vf0 UP -> enp5s2 CARRIER ON */ # ip link show enp5s2 218: enp5s2: mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000 link/ether ea:4d:60:bc:6f:85 brd ff:ff:ff:ff:ff:ff /* enp5s2f1 DOWN -> enp5s0f0-vf1 NO-CARRIER */ # ip link show enp5s0f0-vf1 216: enp5s0f0-vf1: mtu 1500 qdisc fq_codel state DOWN mode DEFAULT group default qlen 1000 link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff # ip link set enp5s0f0-vf0 down # ip link set enp5s2f1 up /* enp5s2 UP -> enp5s0f0-vf1 CARRIER ON */ # ip link show enp5s0f0-vf1 216: enp5s0f0-vf1: mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000 link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff /* enp5s0-vf0 DOWN -> enp5s2 NO_CARRIER */ # ip link show enp5s2 218: enp5s2: mtu 1500 qdisc mq state DOWN mode DEFAULT group default qlen 1000 link/ether ea:4d:60:bc:6f:85 brd ff:ff:ff:ff:ff:ff # ip -d link show enp5s0f0 213: enp5s0f0: mtu 1500 qdisc noop portid 6805ca2e7268 state DOWN mode DEFAULT group default qlen 1000 link/ether 68:05:ca:2e:72:68 brd ff:ff:ff:ff:ff:ff promiscuity 0 addrgenmode eui64 vf 0 MAC 00:00:00:00:00:00, spoof checking on, link-state disable vf 1 MAC 00:00:00:00:00:00, spoof checking on, link-state enable Signed-off-by: Sridhar Samudrala Tested-by: Andrew Bowers --- drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c index 5eb2069..99b2ee3 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c @@ -1013,11 +1013,25 @@ complete_reset: static int i40e_vf_netdev_open(struct net_device *dev) { + struct i40e_vf_netdev_priv *priv = netdev_priv(dev); + struct i40e_vf *vf = priv->vf; + + vf->link_forced = true; + vf->link_up = true; + i40e_vc_notify_vf_link_state(vf); + return 0; } static int i40e_vf_netdev_stop(struct net_device *dev) { + struct i40e_vf_netdev_priv *priv = netdev_priv(dev); + struct i40e_vf *vf = priv->vf; + + vf->link_forced = true; + vf->link_up = false; + i40e_vc_notify_vf_link_state(vf); + return 0; } @@ -1907,6 +1921,10 @@ static int i40e_vc_enable_queues_msg(struct i40e_vf *vf, u8 *msg, u16 msglen) if (i40e_vsi_control_rings(pf->vsi[vf->lan_vsi_idx], true)) aq_ret = I40E_ERR_TIMEOUT; + + if ((0 == aq_ret) && vf->ctrl_netdev) + netif_carrier_on(vf->ctrl_netdev); + error_param: /* send the response to the VF */ return i40e_vc_send_resp_to_vf(vf, I40E_VIRTCHNL_OP_ENABLE_QUEUES, @@ -1947,6 +1965,9 @@ static int i40e_vc_disable_queues_msg(struct i40e_vf *vf, u8 *msg, u16 msglen) if (i40e_vsi_control_rings(pf->vsi[vf->lan_vsi_idx], false)) aq_ret = I40E_ERR_TIMEOUT; + if ((0 == aq_ret) && vf->ctrl_netdev) + netif_carrier_off(vf->ctrl_netdev); + error_param: /* send the response to the VF */ return i40e_vc_send_resp_to_vf(vf, I40E_VIRTCHNL_OP_DISABLE_QUEUES, @@ -3179,6 +3200,7 @@ int i40e_ndo_set_vf_link_state(struct net_device *netdev, int vf_id, int link) struct i40e_virtchnl_pf_event pfe; struct i40e_hw *hw = &pf->hw; struct i40e_vf *vf; + struct net_device *vf_netdev; int abs_vf_id; int ret = 0; @@ -3219,6 +3241,17 @@ int i40e_ndo_set_vf_link_state(struct net_device *netdev, int vf_id, int link) ret = -EINVAL; goto error_out; } + + vf_netdev = vf->ctrl_netdev; + if (vf_netdev) { + unsigned int flags = vf_netdev->flags; + + if (vf->link_up) + dev_change_flags(vf_netdev, flags | IFF_UP); + else + dev_change_flags(vf_netdev, flags & ~IFF_UP); + } + /* Notify the VF of its new link state */ i40e_aq_send_msg_to_vf(hw, abs_vf_id, I40E_VIRTCHNL_OP_EVENT, 0, (u8 *)&pfe, sizeof(pfe), NULL);