DPDK patches and discussions
 help / color / mirror / Atom feed
From: Igor Russkikh <igor.russkikh@aquantia.com>
To: dev@dpdk.org
Cc: pavel.belous@aquantia.com, igor.russkikh@aquantia.com
Subject: [dpdk-dev] [PATCH v2 19/21] net/atlantic: device MTU and statuses
Date: Thu, 13 Sep 2018 14:35:26 +0300	[thread overview]
Message-ID: <1536838528-11800-19-git-send-email-igor.russkikh@aquantia.com> (raw)
In-Reply-To: <1536838528-11800-1-git-send-email-igor.russkikh@aquantia.com>

From: Pavel Belous <pavel.belous@aquantia.com>

Signed-off-by: Igor Russkikh <igor.russkikh@aquantia.com>
---
 drivers/net/atlantic/atl_ethdev.c | 162 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 162 insertions(+)

diff --git a/drivers/net/atlantic/atl_ethdev.c b/drivers/net/atlantic/atl_ethdev.c
index 7ff1126d7..01700b4ad 100644
--- a/drivers/net/atlantic/atl_ethdev.c
+++ b/drivers/net/atlantic/atl_ethdev.c
@@ -78,11 +78,15 @@ static int atl_dev_queue_stats_mapping_set(struct rte_eth_dev *eth_dev,
 					     uint8_t is_rx);
 
 
+static int atl_fw_version_get(struct rte_eth_dev *dev, char *fw_version,
+			      size_t fw_size);
 static void atl_dev_info_get(struct rte_eth_dev *dev,
 			       struct rte_eth_dev_info *dev_info);
 
 static const uint32_t *atl_dev_supported_ptypes_get(struct rte_eth_dev *dev);
 
+static int atl_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);
+
 
 /* VLAN stuff */
 static int atl_vlan_filter_set(struct rte_eth_dev *dev,
@@ -116,6 +120,9 @@ static int atl_flow_ctrl_get(struct rte_eth_dev *dev,
 			       struct rte_eth_fc_conf *fc_conf);
 static int atl_flow_ctrl_set(struct rte_eth_dev *dev,
 			       struct rte_eth_fc_conf *fc_conf);
+
+static void atl_dev_link_status_print(struct rte_eth_dev *dev);
+
 /* Interrupts */
 static int atl_dev_rxq_interrupt_setup(struct rte_eth_dev *dev);
 static int atl_dev_lsc_interrupt_setup(struct rte_eth_dev *dev, uint8_t on);
@@ -195,6 +202,20 @@ static struct rte_pci_driver rte_atl_pmd = {
 	.remove = eth_atl_pci_remove,
 };
 
+#define ATL_RX_OFFLOADS (DEV_RX_OFFLOAD_VLAN_STRIP \
+			| DEV_RX_OFFLOAD_IPV4_CKSUM \
+			| DEV_RX_OFFLOAD_UDP_CKSUM \
+			| DEV_RX_OFFLOAD_TCP_CKSUM \
+			| DEV_RX_OFFLOAD_JUMBO_FRAME \
+			| DEV_RX_OFFLOAD_CRC_STRIP)
+
+#define ATL_TX_OFFLOADS (DEV_TX_OFFLOAD_VLAN_INSERT \
+			| DEV_TX_OFFLOAD_IPV4_CKSUM \
+			| DEV_TX_OFFLOAD_UDP_CKSUM \
+			| DEV_TX_OFFLOAD_TCP_CKSUM \
+			| DEV_TX_OFFLOAD_TCP_TSO \
+			| DEV_TX_OFFLOAD_MULTI_SEGS)
+
 static const struct rte_eth_desc_lim rx_desc_lim = {
 	.nb_max = ATL_MAX_RING_DESC,
 	.nb_min = ATL_MIN_RING_DESC,
@@ -263,6 +284,12 @@ static const struct eth_dev_ops atl_eth_dev_ops = {
 	.xstats_get_names     = atl_dev_xstats_get_names,
 	.stats_reset	      = atl_dev_stats_reset,
 	.xstats_reset	      = atl_dev_xstats_reset,
+	.fw_version_get       = atl_fw_version_get,
+	.dev_infos_get	      = atl_dev_info_get,
+	.dev_supported_ptypes_get = atl_dev_supported_ptypes_get,
+
+	.mtu_set	      = atl_dev_mtu_set,
+
 	/* VLAN */
 	.vlan_filter_set      = atl_vlan_filter_set,
 	.vlan_offload_set     = atl_vlan_offload_set,
@@ -664,6 +691,7 @@ atl_dev_start(struct rte_eth_dev *dev)
 	return 0;
 
 error:
+	PMD_INIT_LOG(ERR, "failure in atl_dev_start(): %d", err);
 	atl_stop_queues(dev);
 	return -EIO;
 }
@@ -850,6 +878,95 @@ static void
 atl_dev_xstats_reset(struct rte_eth_dev *dev __rte_unused)
 {
 }
+
+
+static int
+atl_fw_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size)
+{
+	struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	uint32_t fw_ver = 0;
+	unsigned int ret = 0;
+
+	ret = hw_atl_utils_get_fw_version(hw, &fw_ver);
+	if (ret)
+		return 0;
+
+	ret = snprintf(fw_version, fw_size, "%u.%u.%u", fw_ver >> 24,
+		       (fw_ver >> 16) & 0xFFU, fw_ver & 0xFFFFU);
+
+	ret += 1; /* add string null-terminator */
+
+	if (fw_size < ret)
+		return ret;
+
+	return 0;
+}
+
+static void
+atl_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
+{
+	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
+
+	dev_info->max_rx_queues = AQ_HW_MAX_RX_QUEUES;
+	dev_info->max_tx_queues = AQ_HW_MAX_TX_QUEUES;
+
+	dev_info->min_rx_bufsize = 1024;
+	dev_info->max_rx_pktlen = HW_ATL_B0_MTU_JUMBO;
+	dev_info->max_mac_addrs = HW_ATL_B0_MAC_MAX;
+	dev_info->max_vfs = pci_dev->max_vfs;
+
+	dev_info->max_hash_mac_addrs = 0;
+	dev_info->max_vmdq_pools = 0;
+	dev_info->vmdq_queue_num = 0;
+
+	dev_info->rx_offload_capa = ATL_RX_OFFLOADS;
+
+	dev_info->tx_offload_capa = ATL_TX_OFFLOADS;
+
+
+	dev_info->default_rxconf = (struct rte_eth_rxconf) {
+		.rx_free_thresh = ATL_DEFAULT_RX_FREE_THRESH,
+	};
+
+	dev_info->default_txconf = (struct rte_eth_txconf) {
+		.tx_free_thresh = ATL_DEFAULT_TX_FREE_THRESH,
+	};
+
+	dev_info->rx_desc_lim = rx_desc_lim;
+	dev_info->tx_desc_lim = tx_desc_lim;
+
+	dev_info->hash_key_size = HW_ATL_B0_RSS_HASHKEY_BITS / 8;
+	dev_info->reta_size = HW_ATL_B0_RSS_REDIRECTION_MAX;
+	dev_info->flow_type_rss_offloads = ATL_RSS_OFFLOAD_ALL;
+
+	dev_info->speed_capa = ETH_LINK_SPEED_1G | ETH_LINK_SPEED_10G;
+	dev_info->speed_capa |= ETH_LINK_SPEED_100M;
+	dev_info->speed_capa |= ETH_LINK_SPEED_2_5G;
+	dev_info->speed_capa |= ETH_LINK_SPEED_5G;
+}
+
+static const uint32_t *
+atl_dev_supported_ptypes_get(struct rte_eth_dev *dev)
+{
+	static const uint32_t ptypes[] = {
+		RTE_PTYPE_L2_ETHER,
+		RTE_PTYPE_L2_ETHER_ARP,
+		RTE_PTYPE_L2_ETHER_VLAN,
+		RTE_PTYPE_L3_IPV4,
+		RTE_PTYPE_L3_IPV6,
+		RTE_PTYPE_L4_TCP,
+		RTE_PTYPE_L4_UDP,
+		RTE_PTYPE_L4_SCTP,
+		RTE_PTYPE_L4_ICMP,
+		RTE_PTYPE_UNKNOWN
+	};
+
+	if (dev->rx_pkt_burst == atl_recv_pkts)
+		return ptypes;
+
+	return NULL;
+}
+
 /* return 0 means link status changed, -1 means not changed */
 static int
 atl_dev_link_update(struct rte_eth_dev *dev, int wait __rte_unused)
@@ -1275,6 +1392,38 @@ atl_set_default_mac_addr(struct rte_eth_dev *dev, struct ether_addr *addr)
 	return 0;
 }
 
+static bool
+is_device_supported(struct rte_eth_dev *dev, struct rte_pci_driver *drv)
+{
+	if (strcmp(dev->device->driver->name, drv->driver.name))
+		return false;
+
+	return true;
+}
+
+bool
+is_atl_supported(struct rte_eth_dev *dev)
+{
+	return is_device_supported(dev, &rte_atl_pmd);
+}
+
+static int
+atl_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
+{
+	struct rte_eth_dev_info dev_info;
+	uint32_t frame_size = mtu + ETHER_HDR_LEN + ETHER_CRC_LEN;
+
+	atl_dev_info_get(dev, &dev_info);
+
+	if ((mtu < ETHER_MIN_MTU) || (frame_size > dev_info.max_rx_pktlen))
+		return -EINVAL;
+
+	/* update max frame size */
+	dev->data->dev_conf.rxmode.max_rx_pkt_len = frame_size;
+
+	return 0;
+}
+
 static int
 atl_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
 {
@@ -1533,3 +1682,16 @@ atl_rss_hash_conf_get(struct rte_eth_dev *dev,
 RTE_PMD_REGISTER_PCI(net_atlantic, rte_atl_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_atlantic, pci_id_atl_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_atlantic, "* igb_uio | uio_pci_generic");
+
+RTE_INIT(atl_init_log);
+static void
+atl_init_log(void)
+{
+	atl_logtype_init = rte_log_register("pmd.atlantic.init");
+	if (atl_logtype_init >= 0)
+		rte_log_set_level(atl_logtype_init, RTE_LOG_DEBUG);
+	atl_logtype_driver = rte_log_register("pmd.atlantic.driver");
+	if (atl_logtype_driver >= 0)
+		rte_log_set_level(atl_logtype_driver, RTE_LOG_DEBUG);
+}
+
-- 
2.13.3.windows.1

  parent reply	other threads:[~2018-09-13 11:36 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-13 11:35 [dpdk-dev] [PATCH v2 01/21] net/atlantic: atlantic PMD driver skeleton Igor Russkikh
2018-09-13 11:35 ` [dpdk-dev] [PATCH v2 02/21] net/atlantic: documentation and rel notes Igor Russkikh
2018-09-13 11:35 ` [dpdk-dev] [PATCH v2 03/21] net/atlantic: logging macroes and some typedefs Igor Russkikh
2018-09-13 11:35 ` [dpdk-dev] [PATCH v2 04/21] net/atlantic: hw_atl register declarations Igor Russkikh
2018-09-13 11:35 ` [dpdk-dev] [PATCH v2 05/21] net/atlantic: b0 hardware layer main logic Igor Russkikh
2018-09-13 11:35 ` [dpdk-dev] [PATCH v2 06/21] net/atlantic: firmware operations layer Igor Russkikh
2018-09-13 11:35 ` [dpdk-dev] [PATCH v2 07/21] net/atlantic: hardware register access routines Igor Russkikh
2018-09-13 11:35 ` [dpdk-dev] [PATCH v2 08/21] net/atlantic: rte device start, stop, initial configuration Igor Russkikh
2018-09-13 11:35 ` [dpdk-dev] [PATCH v2 09/21] net/atlantic: link status and interrupt management Igor Russkikh
2018-09-13 11:35 ` [dpdk-dev] [PATCH v2 10/21] net/atlantic: add hw adapter structures and defines Igor Russkikh
2018-09-13 11:35 ` [dpdk-dev] [PATCH v2 11/21] net/atlantic: RSS and RETA manipulation API Igor Russkikh
2018-09-13 11:35 ` [dpdk-dev] [PATCH v2 12/21] net/atlantic: flow control configuration Igor Russkikh
2018-09-13 11:35 ` [dpdk-dev] [PATCH v2 13/21] net/atlantic: MAC address manipulations Igor Russkikh
2018-09-13 11:35 ` [dpdk-dev] [PATCH v2 14/21] net/atlantic: eeprom and register manipulation routines Igor Russkikh
2018-09-13 11:35 ` [dpdk-dev] [PATCH v2 15/21] net/atlantic: LED control DPDK and private APIs Igor Russkikh
2018-09-13 11:35 ` [dpdk-dev] [PATCH v2 16/21] net/atlantic: promisc and allmulti configuration Igor Russkikh
2018-09-13 11:35 ` [dpdk-dev] [PATCH v2 17/21] net/atlantic: device statistics, xstats Igor Russkikh
2018-09-13 11:35 ` [dpdk-dev] [PATCH v2 18/21] net/atlantic: VLAN filters and offloads Igor Russkikh
2018-09-13 11:35 ` Igor Russkikh [this message]
2018-09-13 11:35 ` [dpdk-dev] [PATCH v2 20/21] net/atlantic: RX side structures and implementation Igor Russkikh
2018-09-13 11:35 ` [dpdk-dev] [PATCH v2 21/21] net/atlantic: TX " Igor Russkikh
2018-09-21 14:21 ` [dpdk-dev] [PATCH v2 01/21] net/atlantic: atlantic PMD driver skeleton Ferruh Yigit
2018-09-21 15:35   ` Igor Russkikh
2018-09-21 17:04     ` Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1536838528-11800-19-git-send-email-igor.russkikh@aquantia.com \
    --to=igor.russkikh@aquantia.com \
    --cc=dev@dpdk.org \
    --cc=pavel.belous@aquantia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).