All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 0/2]cxgb4/cxgb4vf: VF link state support
@ 2019-02-28 10:46 Arjun Vynipadath
  2019-02-28 10:46 ` [PATCH net-next 1/2] cxgb4: Add VF Link " Arjun Vynipadath
  2019-02-28 10:46 ` [PATCH net-next 2/2] cxgb4vf: Revert force link up behaviour Arjun Vynipadath
  0 siblings, 2 replies; 4+ messages in thread
From: Arjun Vynipadath @ 2019-02-28 10:46 UTC (permalink / raw)
  To: netdev, davem; +Cc: nirranjan, indranil, dt, Arjun Vynipadath

This series of patches adds support for ndo_set_vf_link_state in
cxgb4 driver.

Patch 1 implements ndo_set_vf_link_state
Patch 2 reverts the existing force_link_up behaviour for cxgb4vf driver.

Arjun Vynipadath (2):
  cxgb4: Add VF Link state support
  cxgb4vf: Revert force link up behaviour

 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h         |  1 +
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c    | 57 +++++++++++++++++++---
 drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h      | 10 ++++
 .../net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c    | 13 ++---
 4 files changed, 65 insertions(+), 16 deletions(-)

-- 
2.9.5


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH net-next 1/2] cxgb4: Add VF Link state support
  2019-02-28 10:46 [PATCH net-next 0/2]cxgb4/cxgb4vf: VF link state support Arjun Vynipadath
@ 2019-02-28 10:46 ` Arjun Vynipadath
  2019-02-28 18:30   ` David Miller
  2019-02-28 10:46 ` [PATCH net-next 2/2] cxgb4vf: Revert force link up behaviour Arjun Vynipadath
  1 sibling, 1 reply; 4+ messages in thread
From: Arjun Vynipadath @ 2019-02-28 10:46 UTC (permalink / raw)
  To: netdev, davem; +Cc: nirranjan, indranil, dt, Arjun Vynipadath, Vishal Kulkarni

Use ndo_set_vf_link_state to control the link states associated
with the virtual interfaces.

Signed-off-by: Arjun Vynipadath <arjun@chelsio.com>
Signed-off-by: Vishal Kulkarni <vishal@chelsio.com>
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h      |  1 +
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 57 ++++++++++++++++++++++---
 drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h   |  8 ++++
 3 files changed, 60 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
index b7b0eb104430..dd6379809c74 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
@@ -885,6 +885,7 @@ struct vf_info {
 	unsigned int tx_rate;
 	bool pf_set_mac;
 	u16 vlan;
+	int link_state;
 };
 
 enum {
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index bcbac247a73d..4eda5285c867 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -2740,6 +2740,7 @@ static int cxgb4_mgmt_get_vf_config(struct net_device *dev,
 	ivi->min_tx_rate = 0;
 	ether_addr_copy(ivi->mac, vfinfo->vf_mac_addr);
 	ivi->vlan = vfinfo->vlan;
+	ivi->linkstate = vfinfo->link_state;
 	return 0;
 }
 
@@ -2879,6 +2880,49 @@ static int cxgb4_mgmt_set_vf_vlan(struct net_device *dev, int vf,
 		ret, (vlan ? "setting" : "clearing"), adap->pf, vf);
 	return ret;
 }
+
+static int cxgb4_mgmt_set_vf_link_state(struct net_device *dev, int vf,
+					int link)
+{
+	struct port_info *pi = netdev_priv(dev);
+	struct adapter *adap = pi->adapter;
+	int ret = 0;
+	u32 param, val;
+
+	if (vf >= adap->num_vfs)
+		return -EINVAL;
+
+	switch (link) {
+	case IFLA_VF_LINK_STATE_AUTO:
+		val = VF_LINK_STATE_AUTO;
+		break;
+
+	case IFLA_VF_LINK_STATE_ENABLE:
+		val = VF_LINK_STATE_ENABLE;
+		break;
+
+	case IFLA_VF_LINK_STATE_DISABLE:
+		val = VF_LINK_STATE_DISABLE;
+		break;
+
+	default:
+		return -EINVAL;
+	}
+
+	param = (FW_PARAMS_MNEM_V(FW_PARAMS_MNEM_PFVF) |
+		 FW_PARAMS_PARAM_X_V(FW_PARAMS_PARAM_PFVF_LINK_STATE));
+	ret = t4_set_params(adap, adap->mbox, adap->pf, vf + 1, 1,
+			    &param, &val);
+	if (ret) {
+		dev_err(adap->pdev_dev,
+			"Error %d in setting PF %d VF %d link state\n",
+			ret, adap->pf, vf);
+		return -EINVAL;
+	}
+
+	adap->vfinfo[vf].link_state = link;
+	return ret;
+}
 #endif /* CONFIG_PCI_IOV */
 
 static int cxgb_set_mac_addr(struct net_device *dev, void *p)
@@ -3294,12 +3338,13 @@ static const struct net_device_ops cxgb4_netdev_ops = {
 
 #ifdef CONFIG_PCI_IOV
 static const struct net_device_ops cxgb4_mgmt_netdev_ops = {
-	.ndo_open             = cxgb4_mgmt_open,
-	.ndo_set_vf_mac       = cxgb4_mgmt_set_vf_mac,
-	.ndo_get_vf_config    = cxgb4_mgmt_get_vf_config,
-	.ndo_set_vf_rate      = cxgb4_mgmt_set_vf_rate,
-	.ndo_get_phys_port_id = cxgb4_mgmt_get_phys_port_id,
-	.ndo_set_vf_vlan      = cxgb4_mgmt_set_vf_vlan,
+	.ndo_open               = cxgb4_mgmt_open,
+	.ndo_set_vf_mac         = cxgb4_mgmt_set_vf_mac,
+	.ndo_get_vf_config      = cxgb4_mgmt_get_vf_config,
+	.ndo_set_vf_rate        = cxgb4_mgmt_set_vf_rate,
+	.ndo_get_phys_port_id   = cxgb4_mgmt_get_phys_port_id,
+	.ndo_set_vf_vlan        = cxgb4_mgmt_set_vf_vlan,
+	.ndo_set_vf_link_state	= cxgb4_mgmt_set_vf_link_state,
 };
 #endif
 
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h b/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h
index 631f1663f4e0..9a3bab797760 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h
@@ -1312,6 +1312,14 @@ enum fw_params_param_pfvf {
 	FW_PARAMS_PARAM_PFVF_RAWF_END = 0x37,
 	FW_PARAMS_PARAM_PFVF_NCRYPTO_LOOKASIDE = 0x39,
 	FW_PARAMS_PARAM_PFVF_PORT_CAPS32 = 0x3A,
+	FW_PARAMS_PARAM_PFVF_LINK_STATE = 0x40,
+};
+
+/* Virtual link state as seen by the specified VF */
+enum vf_link_states {
+	VF_LINK_STATE_AUTO		= 0x00,
+	VF_LINK_STATE_ENABLE		= 0x01,
+	VF_LINK_STATE_DISABLE		= 0x02,
 };
 
 /*
-- 
2.9.5


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH net-next 2/2] cxgb4vf: Revert force link up behaviour
  2019-02-28 10:46 [PATCH net-next 0/2]cxgb4/cxgb4vf: VF link state support Arjun Vynipadath
  2019-02-28 10:46 ` [PATCH net-next 1/2] cxgb4: Add VF Link " Arjun Vynipadath
@ 2019-02-28 10:46 ` Arjun Vynipadath
  1 sibling, 0 replies; 4+ messages in thread
From: Arjun Vynipadath @ 2019-02-28 10:46 UTC (permalink / raw)
  To: netdev, davem; +Cc: nirranjan, indranil, dt, Arjun Vynipadath, Vishal Kulkarni

Reverting force link up changes since this behaviour can be
achieved using VF link state feature.

Reverts:
commit 0913667ab3ad ("cxgb4vf: Forcefully link up virtual interfaces")

Signed-off-by: Arjun Vynipadath <arjun@chelsio.com>
Signed-off-by: Vishal Kulkarni <vishal@chelsio.com>
---
 drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
index 3300b69a42b3..ed888227d81d 100644
--- a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
@@ -155,6 +155,8 @@ void t4vf_os_link_changed(struct adapter *adapter, int pidx, int link_ok)
 		const char *fc;
 		const struct port_info *pi = netdev_priv(dev);
 
+		netif_carrier_on(dev);
+
 		switch (pi->link_cfg.speed) {
 		case 100:
 			s = "100Mbps";
@@ -200,6 +202,7 @@ void t4vf_os_link_changed(struct adapter *adapter, int pidx, int link_ok)
 
 		netdev_info(dev, "link up, %s, full-duplex, %s PAUSE\n", s, fc);
 	} else {
+		netif_carrier_off(dev);
 		netdev_info(dev, "link down\n");
 	}
 }
@@ -339,16 +342,6 @@ static int link_start(struct net_device *dev)
 	if (ret == 0)
 		ret = t4vf_enable_pi(pi->adapter, pi, true, true);
 
-	/* The Virtual Interfaces are connected to an internal switch on the
-	 * chip which allows VIs attached to the same port to talk to each
-	 * other even when the port link is down.  As a result, we generally
-	 * want to always report a VI's link as being "up", provided there are
-	 * no errors in enabling vi.
-	 */
-
-	if (ret == 0)
-		netif_carrier_on(dev);
-
 	return ret;
 }
 
-- 
2.9.5


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next 1/2] cxgb4: Add VF Link state support
  2019-02-28 10:46 ` [PATCH net-next 1/2] cxgb4: Add VF Link " Arjun Vynipadath
@ 2019-02-28 18:30   ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2019-02-28 18:30 UTC (permalink / raw)
  To: arjun; +Cc: netdev, nirranjan, indranil, dt, vishal

From: Arjun Vynipadath <arjun@chelsio.com>
Date: Thu, 28 Feb 2019 16:16:26 +0530

> @@ -2879,6 +2880,49 @@ static int cxgb4_mgmt_set_vf_vlan(struct net_device *dev, int vf,
>  		ret, (vlan ? "setting" : "clearing"), adap->pf, vf);
>  	return ret;
>  }
> +
> +static int cxgb4_mgmt_set_vf_link_state(struct net_device *dev, int vf,
> +					int link)
> +{
> +	struct port_info *pi = netdev_priv(dev);
> +	struct adapter *adap = pi->adapter;
> +	int ret = 0;
> +	u32 param, val;

Reverse christmas tree please.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-02-28 18:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-28 10:46 [PATCH net-next 0/2]cxgb4/cxgb4vf: VF link state support Arjun Vynipadath
2019-02-28 10:46 ` [PATCH net-next 1/2] cxgb4: Add VF Link " Arjun Vynipadath
2019-02-28 18:30   ` David Miller
2019-02-28 10:46 ` [PATCH net-next 2/2] cxgb4vf: Revert force link up behaviour Arjun Vynipadath

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.