Skip to contentSkip to conversation

net/ionic: fix device configuration and init

PATCH In review Andrew Boyer 2 participants 9 messages Jan 11, 2021 – Jan 18, 2021 Network drivers

lore
Share & tools
lore
#0 lore raw

cover net/ionic: fix device configuration and init

This patch series fixes up configuration flag handling, fixes up link autonegotiation, and reduces the init time.

DTS was used to identify the issues and verify the fixes.

Andrew Boyer (6):
net/ionic: revise configuration flag handling net/ionic: combine queue init and enable commands net/ionic: set port admin state to up in port init net/ionic: don't add station MAC filter on init net/ionic: clear up confusion around FC autoneg net/ionic: correctly set link speed and autonegotiation

 drivers/net/ionic/ionic_ethdev.c | 123 +++++++++++++++----------------
 drivers/net/ionic/ionic_lif.c    | 120 ++++++++++++++++++++++--------
 drivers/net/ionic/ionic_lif.h    |   3 +-
 drivers/net/ionic/ionic_main.c   |  14 +---
 drivers/net/ionic/ionic_rxtx.c   |  14 ++--
 5 files changed, 161 insertions(+), 113 deletions(-)
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/6 net/ionic: revise configuration flag handling

Configuration flags come to the driver in dev_configure(). From there, the driver calls ionic_lif_configure() to update the lif->feature bitfield, and then programs the port.

Features like VLAN_RX_FILTER and RX_HASH cannot be disabled in the device, so do nothing in response to requests to disable them. (The device config would ideally show them enabled by default, but some DTS tests fail if RSS_HASH is set but RSS is not.)

Move features from the per-queue to per-port lists. IONIC does not really support per-queue configuration: the stack disallows disabling a queue feature if it is enabled on the port, while the device disallows enabling a queue feature if it is disabled on the port. Thus all configuration is per-port.

Move the guts of ionic_vlan_offload_set() into a new function, ionic_lif_configure_vlan_offload(), so it can be called by ionic_lif_configure().

Move the check for DEV_RX_OFFLOAD_SCATTER from rx_queue_setup() up into ionic_lif_configure().

Warn if rx_drop_en is not set.

---
 drivers/net/ionic/ionic_ethdev.c |  77 +++++++++---------------
 drivers/net/ionic/ionic_lif.c    | 100 ++++++++++++++++++++++++++-----
 drivers/net/ionic/ionic_lif.h    |   3 +-
 drivers/net/ionic/ionic_rxtx.c   |   6 +-
 4 files changed, 118 insertions(+), 68 deletions(-)
drivers/net/ionic/ionic_ethdev.c +27 -50
index fd7cd510e..5ff155f85 100644
@@ -397,25 +397,16 @@ ionic_dev_info_get(struct rte_eth_dev *eth_dev,
 		ETH_LINK_SPEED_100G;
 
 	/*
-	 * Per-queue capabilities. Actually most of the offloads are enabled
-	 * by default on the port and can be used on selected queues (by adding
-	 * packet flags at runtime when required)
+	 * Per-queue capabilities
+	 * RTE does not support disabling a feature on a queue if it is
+	 * enabled globally on the device. Thus the driver does not advertise
+	 * capabilities like DEV_TX_OFFLOAD_IPV4_CKSUM as per-queue even
+	 * though the driver would be otherwise capable of disabling it on
+	 * a per-queue basis.
 	 */
 
-	dev_info->rx_queue_offload_capa =
-		DEV_RX_OFFLOAD_IPV4_CKSUM |
-		DEV_RX_OFFLOAD_UDP_CKSUM |
-		DEV_RX_OFFLOAD_TCP_CKSUM |
-		0;
-
-	dev_info->tx_queue_offload_capa =
-		DEV_TX_OFFLOAD_IPV4_CKSUM |
-		DEV_TX_OFFLOAD_UDP_CKSUM |
-		DEV_TX_OFFLOAD_TCP_CKSUM |
-		DEV_TX_OFFLOAD_VLAN_INSERT |
-		DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM |
-		DEV_TX_OFFLOAD_OUTER_UDP_CKSUM |
-		0;
+	dev_info->rx_queue_offload_capa = 0;
+	dev_info->tx_queue_offload_capa = 0;
 
 	/*
 	 * Per-port capabilities
@@ -423,15 +414,25 @@ ionic_dev_info_get(struct rte_eth_dev *eth_dev,
 	 */
 
 	dev_info->rx_offload_capa = dev_info->rx_queue_offload_capa |
+		DEV_RX_OFFLOAD_IPV4_CKSUM |
+		DEV_RX_OFFLOAD_UDP_CKSUM |
+		DEV_RX_OFFLOAD_TCP_CKSUM |
 		DEV_RX_OFFLOAD_JUMBO_FRAME |
 		DEV_RX_OFFLOAD_VLAN_FILTER |
 		DEV_RX_OFFLOAD_VLAN_STRIP |
 		DEV_RX_OFFLOAD_SCATTER |
+		DEV_RX_OFFLOAD_RSS_HASH |
 		0;
 
 	dev_info->tx_offload_capa = dev_info->tx_queue_offload_capa |
+		DEV_TX_OFFLOAD_IPV4_CKSUM |
+		DEV_TX_OFFLOAD_UDP_CKSUM |
+		DEV_TX_OFFLOAD_TCP_CKSUM |
+		DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM |
+		DEV_TX_OFFLOAD_OUTER_UDP_CKSUM |
 		DEV_TX_OFFLOAD_MULTI_SEGS |
 		DEV_TX_OFFLOAD_TCP_TSO |
+		DEV_TX_OFFLOAD_VLAN_INSERT |
 		0;
 
 	dev_info->rx_desc_lim = rx_desc_lim;
@@ -445,6 +446,11 @@ ionic_dev_info_get(struct rte_eth_dev *eth_dev,
 	dev_info->default_rxportconf.ring_size = IONIC_DEF_TXRX_DESC;
 	dev_info->default_txportconf.ring_size = IONIC_DEF_TXRX_DESC;
 
+	dev_info->default_rxconf = (struct rte_eth_rxconf) {
+		/* Packets are always dropped if no desc are available */
+		.rx_drop_en = 1,
+	};
+
 	return 0;
 }
 
@@ -502,34 +508,8 @@ static int
 ionic_vlan_offload_set(struct rte_eth_dev *eth_dev, int mask)
 {
 	struct ionic_lif *lif = IONIC_ETH_DEV_TO_LIF(eth_dev);
-	struct rte_eth_rxmode *rxmode;
-	rxmode = &eth_dev->data->dev_conf.rxmode;
-	int i;
-
-	if (mask & ETH_VLAN_STRIP_MASK) {
-		if (rxmode->offloads & DEV_RX_OFFLOAD_VLAN_STRIP) {
-			for (i = 0; i < eth_dev->data->nb_rx_queues; i++) {
-				struct ionic_qcq *rxq =
-					eth_dev->data->rx_queues[i];
-				rxq->offloads |= DEV_RX_OFFLOAD_VLAN_STRIP;
-			}
-			lif->features |= IONIC_ETH_HW_VLAN_RX_STRIP;
-		} else {
-			for (i = 0; i < eth_dev->data->nb_rx_queues; i++) {
-				struct ionic_qcq *rxq =
-					eth_dev->data->rx_queues[i];
-				rxq->offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP;
-			}
-			lif->features &= ~IONIC_ETH_HW_VLAN_RX_STRIP;
-		}
-	}
 
-	if (mask & ETH_VLAN_FILTER_MASK) {
-		if (rxmode->offloads & DEV_RX_OFFLOAD_VLAN_FILTER)
-			lif->features |= IONIC_ETH_HW_VLAN_RX_FILTER;
-		else
-			lif->features &= ~IONIC_ETH_HW_VLAN_RX_FILTER;
-	}
+	ionic_lif_configure_vlan_offload(lif, mask);
 
 	ionic_lif_set_features(lif);
 
@@ -845,15 +825,12 @@ static int
 ionic_dev_configure(struct rte_eth_dev *eth_dev)
 {
 	struct ionic_lif *lif = IONIC_ETH_DEV_TO_LIF(eth_dev);
-	int err;
 
 	IONIC_PRINT_CALL();
 
-	err = ionic_lif_configure(lif);
-	if (err) {
-		IONIC_PRINT(ERR, "Cannot configure LIF: %d", err);
-		return err;
-	}
+	ionic_lif_configure(lif);
+
+	ionic_lif_set_features(lif);
 
 	return 0;
 }
drivers/net/ionic/ionic_lif.c +86 -14

120 lines not on this page · raw message

drivers/net/ionic/ionic_lif.h +2 -1
index 86d933606..4f48845eb 100644
@@ -131,7 +131,8 @@ void ionic_lif_deinit(struct ionic_lif *lif);
 int ionic_lif_start(struct ionic_lif *lif);
 void ionic_lif_stop(struct ionic_lif *lif);
 
-int ionic_lif_configure(struct ionic_lif *lif);
+void ionic_lif_configure(struct ionic_lif *lif);
+void ionic_lif_configure_vlan_offload(struct ionic_lif *lif, int mask);
 void ionic_lif_reset(struct ionic_lif *lif);
 
 int ionic_intr_alloc(struct ionic_lif *lif, struct ionic_intr_info *intr);
drivers/net/ionic/ionic_rxtx.c +3 -3
index d06f1246c..cf7ff6ce7 100644
@@ -675,6 +675,9 @@ ionic_dev_rx_queue_setup(struct rte_eth_dev *eth_dev,
 		"Configuring skt %u RX queue %u with %u buffers, offloads %jx",
 		socket_id, rx_queue_id, nb_desc, offloads);
 
+	if (!rx_conf->rx_drop_en)
+		IONIC_PRINT(WARNING, "No-drop mode is not supported");
+
 	/* Validate number of receive descriptors */
 	if (!rte_is_power_of_2(nb_desc) ||
 			nb_desc < IONIC_MIN_RING_DESC ||
@@ -685,9 +688,6 @@ ionic_dev_rx_queue_setup(struct rte_eth_dev *eth_dev,
 		return -EINVAL; /* or use IONIC_DEFAULT_RING_DESC */
 	}
 
-	if (rx_conf->offloads & DEV_RX_OFFLOAD_SCATTER)
-		eth_dev->data->scattered_rx = 1;
-
 	/* Free memory prior to re-allocation if needed... */
 	if (eth_dev->data->rx_queues[rx_queue_id] != NULL) {
 		void *rx_queue = eth_dev->data->rx_queues[rx_queue_id];
Signature · 1 line
2.17.1
#2 lore raw

PATCH 2/6 net/ionic: combine queue init and enable commands

In reply to Andrew Boyer

Adding F_ENA to the q_init command has the same effect as q_enable. This reduces the startup time a bit.

---
 drivers/net/ionic/ionic_lif.c  | 4 ++--
 drivers/net/ionic/ionic_rxtx.c | 8 ++++----
 2 files changed, 6 insertions(+), 6 deletions(-)
drivers/net/ionic/ionic_lif.c +2 -2
index ed1595e62..673f789f3 100644
@@ -1371,7 +1371,7 @@ ionic_lif_txq_init(struct ionic_qcq *qcq)
 			.opcode = IONIC_CMD_Q_INIT,
 			.type = q->type,
 			.index = q->index,
-			.flags = IONIC_QINIT_F_SG,
+			.flags = IONIC_QINIT_F_SG | IONIC_QINIT_F_ENA,
 			.intr_index = cq->bound_intr->index,
 			.ring_size = rte_log2_u32(q->num_descs),
 			.ring_base = q->base_pa,
@@ -1417,7 +1417,7 @@ ionic_lif_rxq_init(struct ionic_qcq *qcq)
 			.opcode = IONIC_CMD_Q_INIT,
 			.type = q->type,
 			.index = q->index,
-			.flags = IONIC_QINIT_F_SG,
+			.flags = IONIC_QINIT_F_SG | IONIC_QINIT_F_ENA,
 			.intr_index = cq->bound_intr->index,
 			.ring_size = rte_log2_u32(q->num_descs),
 			.ring_base = q->base_pa,
drivers/net/ionic/ionic_rxtx.c +4 -4
index cf7ff6ce7..5d0e9d5d5 100644
@@ -232,10 +232,10 @@ ionic_dev_tx_queue_start(struct rte_eth_dev *eth_dev, uint16_t tx_queue_id)
 		err = ionic_lif_txq_init(txq);
 		if (err)
 			return err;
+	} else {
+		ionic_qcq_enable(txq);
 	}
 
-	ionic_qcq_enable(txq);
-
 	tx_queue_state[tx_queue_id] = RTE_ETH_QUEUE_STATE_STARTED;
 
 	return 0;
@@ -988,6 +988,8 @@ ionic_dev_rx_queue_start(struct rte_eth_dev *eth_dev, uint16_t rx_queue_id)
 		err = ionic_lif_rxq_init(rxq);
 		if (err)
 			return err;
+	} else {
+		ionic_qcq_enable(rxq);
 	}
 
 	/* Allocate buffers for descriptor rings */
@@ -997,8 +999,6 @@ ionic_dev_rx_queue_start(struct rte_eth_dev *eth_dev, uint16_t rx_queue_id)
 		return -1;
 	}
 
-	ionic_qcq_enable(rxq);
-
 	rx_queue_state[rx_queue_id] = RTE_ETH_QUEUE_STATE_STARTED;
 
 	return 0;
Signature · 1 line
2.17.1
#3 lore raw

PATCH 3/6 net/ionic: set port admin state to up in port init

In reply to Andrew Boyer

This reduces the startup time a bit.

---
 drivers/net/ionic/ionic_main.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)
drivers/net/ionic/ionic_main.c +3 -11
index ce5d11311..467696a54 100644
@@ -403,21 +403,13 @@ ionic_port_init(struct ionic_adapter *adapter)
 	for (i = 0; i < nwords; i++)
 		iowrite32(ident->port.config.words[i], &idev->dev_cmd->data[i]);
 
+	idev->port_info->config.state = IONIC_PORT_ADMIN_STATE_UP;
 	ionic_dev_cmd_port_init(idev);
 	err = ionic_dev_cmd_wait_check(idev, IONIC_DEVCMD_TIMEOUT);
-	if (err) {
+	if (err)
 		IONIC_PRINT(ERR, "Failed to init port");
-		return err;
-	}
-
-	ionic_dev_cmd_port_state(idev, IONIC_PORT_ADMIN_STATE_UP);
-	err = ionic_dev_cmd_wait_check(idev, IONIC_DEVCMD_TIMEOUT);
-	if (err) {
-		IONIC_PRINT(WARNING, "Failed to bring port UP");
-		return err;
-	}
 
-	return 0;
+	return err;
 }
 
 int
Signature · 1 line
2.17.1
#4 lore raw

PATCH 4/6 net/ionic: don't add station MAC filter on init

In reply to Andrew Boyer

The address is not needed in the firmware.
This reduces the startup time a bit.

---
 drivers/net/ionic/ionic_lif.c | 16 ----------------
 1 file changed, 16 deletions(-)
drivers/net/ionic/ionic_lif.c +0 -16
index 673f789f3..f39b54e8e 100644
@@ -1469,24 +1469,8 @@ ionic_station_set(struct ionic_lif *lif)
 	if (err)
 		return err;
 
-	if (!rte_is_zero_ether_addr((struct rte_ether_addr *)
-			lif->mac_addr)) {
-		IONIC_PRINT(INFO, "deleting station MAC addr");
-
-		ionic_lif_addr_del(lif, lif->mac_addr);
-	}
-
 	memcpy(lif->mac_addr, ctx.comp.lif_getattr.mac, RTE_ETHER_ADDR_LEN);
 
-	if (rte_is_zero_ether_addr((struct rte_ether_addr *)lif->mac_addr)) {
-		IONIC_PRINT(NOTICE, "empty MAC addr (VF?)");
-		return 0;
-	}
-
-	IONIC_PRINT(DEBUG, "adding station MAC addr");
-
-	ionic_lif_addr_add(lif, lif->mac_addr);
-
 	return 0;
 }
 
Signature · 1 line
2.17.1
#5 lore raw

PATCH 5/6 net/ionic: clear up confusion around FC autoneg

In reply to Andrew Boyer

IONIC does not support Flow-Control autonegotiation.

Always wait for completion after each dev cmd.

---
 drivers/net/ionic/ionic_ethdev.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)
drivers/net/ionic/ionic_ethdev.c +12 -6
index 5ff155f85..838e93ef7 100644
@@ -463,7 +463,8 @@ ionic_flow_ctrl_get(struct rte_eth_dev *eth_dev,
 	struct ionic_dev *idev = &adapter->idev;
 
 	if (idev->port_info) {
-		fc_conf->autoneg = idev->port_info->config.an_enable;
+		/* Flow control autoneg not supported */
+		fc_conf->autoneg = 0;
 
 		if (idev->port_info->config.pause_type)
 			fc_conf->mode = RTE_FC_FULL;
@@ -482,7 +483,12 @@ ionic_flow_ctrl_set(struct rte_eth_dev *eth_dev,
 	struct ionic_adapter *adapter = lif->adapter;
 	struct ionic_dev *idev = &adapter->idev;
 	uint8_t pause_type = IONIC_PORT_PAUSE_TYPE_NONE;
-	uint8_t an_enable;
+	int err;
+
+	if (fc_conf->autoneg) {
+		IONIC_PRINT(WARNING, "Flow control autoneg not supported");
+		return -ENOTSUP;
+	}
 
 	switch (fc_conf->mode) {
 	case RTE_FC_NONE:
@@ -496,12 +502,12 @@ ionic_flow_ctrl_set(struct rte_eth_dev *eth_dev,
 		return -ENOTSUP;
 	}
 
-	an_enable = fc_conf->autoneg;
-
 	ionic_dev_cmd_port_pause(idev, pause_type);
-	ionic_dev_cmd_port_autoneg(idev, an_enable);
+	err = ionic_dev_cmd_wait_check(idev, IONIC_DEVCMD_TIMEOUT);
+	if (err)
+		IONIC_PRINT(WARNING, "Failed to configure flow control");
 
-	return 0;
+	return err;
 }
 
 static int
Signature · 1 line
2.17.1
#6 lore raw

PATCH 6/6 net/ionic: correctly set link speed and autonegotiation

In reply to Andrew Boyer

Don't assume autoneg in link_update().

Always call ionic_dev_cmd_port_autoneg() in start().

This allows the client to specify the link settings.

---
 drivers/net/ionic/ionic_ethdev.c | 28 ++++++++++++++++++++++------
 1 file changed, 22 insertions(+), 6 deletions(-)
drivers/net/ionic/ionic_ethdev.c +22 -6
index 838e93ef7..2face7c63 100644
@@ -276,7 +276,10 @@ ionic_dev_link_update(struct rte_eth_dev *eth_dev,
 
 	/* Initialize */
 	memset(&link, 0, sizeof(link));
-	link.link_autoneg = ETH_LINK_AUTONEG;
+
+	if (adapter->idev.port_info->config.an_enable) {
+		link.link_autoneg = ETH_LINK_AUTONEG;
+	}
 
 	if (!adapter->link_up ||
 	    !(lif->state & IONIC_LIF_F_UP)) {
@@ -869,7 +872,8 @@ ionic_dev_start(struct rte_eth_dev *eth_dev)
 	struct ionic_lif *lif = IONIC_ETH_DEV_TO_LIF(eth_dev);
 	struct ionic_adapter *adapter = lif->adapter;
 	struct ionic_dev *idev = &adapter->idev;
-	uint32_t allowed_speeds;
+	uint32_t speed = 0, allowed_speeds;
+	uint8_t an_enable;
 	int err;
 
 	IONIC_PRINT_CALL();
@@ -896,11 +900,23 @@ ionic_dev_start(struct rte_eth_dev *eth_dev)
 		return err;
 	}
 
-	if (eth_dev->data->dev_conf.link_speeds & ETH_LINK_SPEED_FIXED) {
-		uint32_t speed = ionic_parse_link_speeds(dev_conf->link_speeds);
+	/* Configure link */
+	an_enable = (dev_conf->link_speeds & ETH_LINK_SPEED_FIXED) == 0;
 
-		if (speed)
-			ionic_dev_cmd_port_speed(idev, speed);
+	ionic_dev_cmd_port_autoneg(idev, an_enable);
+	err = ionic_dev_cmd_wait_check(idev, IONIC_DEVCMD_TIMEOUT);
+	if (err)
+		IONIC_PRINT(WARNING, "Failed to %s autonegotiation",
+			an_enable ? "enable" : "disable");
+
+	if (!an_enable)
+		speed = ionic_parse_link_speeds(dev_conf->link_speeds);
+	if (speed) {
+		ionic_dev_cmd_port_speed(idev, speed);
+		err = ionic_dev_cmd_wait_check(idev, IONIC_DEVCMD_TIMEOUT);
+		if (err)
+			IONIC_PRINT(WARNING, "Failed to set link speed %u",
+				speed);
 	}
 
 	ionic_dev_link_update(eth_dev, 0);
Signature · 1 line
2.17.1
#7 lore raw

Re: [dpdk-dev] [PATCH 6/6] net/ionic: correctly set link speed and autonegotiation

Quoted 7 lines · Andrew Boyer

Don't assume autoneg in link_update().

Always call ionic_dev_cmd_port_autoneg() in start().

This allows the client to specify the link settings.

    Fixes: 598f6726390f ("net/ionic: add basic port operations")
    Cc: [email protected]
#8 lore raw
In reply to Andrew Boyer
Quoted 5 lines · Andrew Boyer

This patch series fixes up configuration flag handling, fixes up link autonegotiation, and reduces the init time.

DTS was used to identify the issues and verify the fixes.

Quoted 8 lines

Andrew Boyer (6):
net/ionic: revise configuration flag handling net/ionic: combine queue init and enable commands net/ionic: set port admin state to up in port init net/ionic: don't add station MAC filter on init net/ionic: clear up confusion around FC autoneg net/ionic: correctly set link speed and autonegotiation

Series applied to dpdk-next-net/main, thanks.