From: Ivan Malov <ivan.ma...@oktetlabs.ru>

Reviewed-by: Andy Moreton <amoreton at solarflare.com>
Signed-off-by: Ivan Malov <ivan.malov at oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko at solarflare.com>
---
 doc/guides/nics/features/sfc_efx.ini |  2 +
 doc/guides/nics/sfc_efx.rst          |  2 +
 drivers/net/sfc/efx/Makefile         |  1 +
 drivers/net/sfc/efx/sfc.c            | 14 ++++++
 drivers/net/sfc/efx/sfc.h            |  6 +++
 drivers/net/sfc/efx/sfc_ethdev.c     | 17 ++++++++
 drivers/net/sfc/efx/sfc_tx.c         | 85 ++++++++++++++++++++++++++++++++++++
 drivers/net/sfc/efx/sfc_tx.h         | 53 ++++++++++++++++++++++
 8 files changed, 180 insertions(+)
 create mode 100644 drivers/net/sfc/efx/sfc_tx.c
 create mode 100644 drivers/net/sfc/efx/sfc_tx.h

diff --git a/doc/guides/nics/features/sfc_efx.ini 
b/doc/guides/nics/features/sfc_efx.ini
index 7dc2e92..67df1c6 100644
--- a/doc/guides/nics/features/sfc_efx.ini
+++ b/doc/guides/nics/features/sfc_efx.ini
@@ -5,6 +5,8 @@
 ;
 [Features]
 Link status          = Y
+L3 checksum offload  = P
+L4 checksum offload  = P
 BSD nic_uio          = Y
 Linux UIO            = Y
 Linux VFIO           = Y
diff --git a/doc/guides/nics/sfc_efx.rst b/doc/guides/nics/sfc_efx.rst
index 8145a6b..aadd775 100644
--- a/doc/guides/nics/sfc_efx.rst
+++ b/doc/guides/nics/sfc_efx.rst
@@ -46,6 +46,8 @@ SFC EFX PMD has support for:

 - Link state information

+- IPv4/IPv6 TCP/UDP transmit checksum offload
+

 Non-supported Features
 ----------------------
diff --git a/drivers/net/sfc/efx/Makefile b/drivers/net/sfc/efx/Makefile
index eb82c89..8ecca83 100644
--- a/drivers/net/sfc/efx/Makefile
+++ b/drivers/net/sfc/efx/Makefile
@@ -88,6 +88,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += sfc_intr.c
 SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += sfc_ev.c
 SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += sfc_port.c
 SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += sfc_rx.c
+SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += sfc_tx.c

 VPATH += $(SRCDIR)/base

diff --git a/drivers/net/sfc/efx/sfc.c b/drivers/net/sfc/efx/sfc.c
index 1c0f59d..6990ccd 100644
--- a/drivers/net/sfc/efx/sfc.c
+++ b/drivers/net/sfc/efx/sfc.c
@@ -38,6 +38,7 @@
 #include "sfc_log.h"
 #include "sfc_ev.h"
 #include "sfc_rx.h"
+#include "sfc_tx.h"


 int
@@ -362,10 +363,17 @@ sfc_configure(struct sfc_adapter *sa)
        if (rc != 0)
                goto fail_rx_init;

+       rc = sfc_tx_init(sa);
+       if (rc != 0)
+               goto fail_tx_init;
+
        sa->state = SFC_ADAPTER_CONFIGURED;
        sfc_log_init(sa, "done");
        return 0;

+fail_tx_init:
+       sfc_rx_fini(sa);
+
 fail_rx_init:
        sfc_port_fini(sa);

@@ -392,6 +400,7 @@ sfc_close(struct sfc_adapter *sa)
        SFC_ASSERT(sa->state == SFC_ADAPTER_CONFIGURED);
        sa->state = SFC_ADAPTER_CLOSING;

+       sfc_tx_fini(sa);
        sfc_rx_fini(sa);
        sfc_port_fini(sa);
        sfc_ev_fini(sa);
@@ -438,6 +447,7 @@ int
 sfc_attach(struct sfc_adapter *sa)
 {
        struct rte_pci_device *pci_dev = sa->eth_dev->pci_dev;
+       const efx_nic_cfg_t *encp;
        efx_nic_t *enp;
        int rc;

@@ -488,6 +498,10 @@ sfc_attach(struct sfc_adapter *sa)
        if (rc != 0)
                goto fail_estimate_rsrc_limits;

+       encp = efx_nic_cfg_get(sa->nic);
+       sa->txq_max_entries = encp->enc_txq_max_ndescs;
+       SFC_ASSERT(rte_is_power_of_2(sa->txq_max_entries));
+
        rc = sfc_intr_attach(sa);
        if (rc != 0)
                goto fail_intr_attach;
diff --git a/drivers/net/sfc/efx/sfc.h b/drivers/net/sfc/efx/sfc.h
index a592b53..de0395e 100644
--- a/drivers/net/sfc/efx/sfc.h
+++ b/drivers/net/sfc/efx/sfc.h
@@ -115,6 +115,7 @@ struct sfc_intr {

 struct sfc_evq_info;
 struct sfc_rxq_info;
+struct sfc_txq_info;

 struct sfc_port {
        unsigned int                    flow_ctrl;
@@ -148,6 +149,8 @@ struct sfc_adapter {
        unsigned int                    rxq_max;
        unsigned int                    txq_max;

+       unsigned int                    txq_max_entries;
+
        unsigned int                    evq_count;
        struct sfc_evq_info             *evq_info;

@@ -156,6 +159,9 @@ struct sfc_adapter {

        unsigned int                    rxq_count;
        struct sfc_rxq_info             *rxq_info;
+
+       unsigned int                    txq_count;
+       struct sfc_txq_info             *txq_info;
 };

 /*
diff --git a/drivers/net/sfc/efx/sfc_ethdev.c b/drivers/net/sfc/efx/sfc_ethdev.c
index 61ae1bd..4afd30c 100644
--- a/drivers/net/sfc/efx/sfc_ethdev.c
+++ b/drivers/net/sfc/efx/sfc_ethdev.c
@@ -51,16 +51,33 @@ sfc_dev_infos_get(struct rte_eth_dev *dev, struct 
rte_eth_dev_info *dev_info)
        dev_info->max_rx_pktlen = EFX_MAC_PDU_MAX;

        dev_info->max_rx_queues = sa->rxq_max;
+       dev_info->max_tx_queues = sa->txq_max;

        /* By default packets are dropped if no descriptors are available */
        dev_info->default_rxconf.rx_drop_en = 1;

+       dev_info->tx_offload_capa =
+               DEV_TX_OFFLOAD_IPV4_CKSUM |
+               DEV_TX_OFFLOAD_UDP_CKSUM |
+               DEV_TX_OFFLOAD_TCP_CKSUM;
+
+       dev_info->default_txconf.txq_flags = ETH_TXQ_FLAGS_NOVLANOFFL |
+                                            ETH_TXQ_FLAGS_NOXSUMSCTP;
+
        dev_info->rx_desc_lim.nb_max = EFX_RXQ_MAXNDESCS;
        dev_info->rx_desc_lim.nb_min = EFX_RXQ_MINNDESCS;
        /* The RXQ hardware requires that the descriptor count is a power
         * of 2, but rx_desc_lim cannot properly describe that constraint.
         */
        dev_info->rx_desc_lim.nb_align = EFX_RXQ_MINNDESCS;
+
+       dev_info->tx_desc_lim.nb_max = sa->txq_max_entries;
+       dev_info->tx_desc_lim.nb_min = EFX_TXQ_MINNDESCS;
+       /*
+        * The TXQ hardware requires that the descriptor count is a power
+        * of 2, but tx_desc_lim cannot properly describe that constraint
+        */
+       dev_info->tx_desc_lim.nb_align = EFX_TXQ_MINNDESCS;
 }

 static int
diff --git a/drivers/net/sfc/efx/sfc_tx.c b/drivers/net/sfc/efx/sfc_tx.c
new file mode 100644
index 0000000..c418185
--- /dev/null
+++ b/drivers/net/sfc/efx/sfc_tx.c
@@ -0,0 +1,85 @@
+/*-
+ * Copyright (c) 2016 Solarflare Communications Inc.
+ * All rights reserved.
+ *
+ * This software was jointly developed between OKTET Labs (under contract
+ * for Solarflare) and Solarflare Communications, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "sfc.h"
+#include "sfc_log.h"
+#include "sfc_ev.h"
+#include "sfc_tx.h"
+
+static int
+sfc_tx_qinit_info(struct sfc_adapter *sa, unsigned int sw_index)
+{
+       struct sfc_txq_info *txq_info = &sa->txq_info[sw_index];
+       int rc = 0;
+
+       sfc_log_init(sa, "TxQ = %u", sw_index);
+
+       return 0;
+}
+
+int
+sfc_tx_init(struct sfc_adapter *sa)
+{
+       int sw_index;
+       int rc = 0;
+
+       sa->txq_count = sa->eth_dev->data->nb_tx_queues;
+
+       sa->txq_info = rte_calloc_socket("sfc-txqs", sa->txq_count,
+                                        sizeof(sa->txq_info[0]), 0,
+                                        sa->socket_id);
+       if (sa->txq_info == NULL)
+               goto fail_txqs_alloc;
+
+       for (sw_index = 0; sw_index < sa->txq_count; ++sw_index) {
+               rc = sfc_tx_qinit_info(sa, sw_index);
+               if (rc != 0)
+                       goto fail_tx_qinit_info;
+       }
+
+       return 0;
+
+fail_tx_qinit_info:
+       rte_free(sa->txq_info);
+       sa->txq_info = NULL;
+
+fail_txqs_alloc:
+       sa->txq_count = 0;
+
+       sfc_log_init(sa, "failed (rc = %d)", rc);
+       return rc;
+}
+
+void
+sfc_tx_fini(struct sfc_adapter *sa)
+{
+       rte_free(sa->txq_info);
+       sa->txq_info = NULL;
+       sa->txq_count = 0;
+}
diff --git a/drivers/net/sfc/efx/sfc_tx.h b/drivers/net/sfc/efx/sfc_tx.h
new file mode 100644
index 0000000..b2d4875
--- /dev/null
+++ b/drivers/net/sfc/efx/sfc_tx.h
@@ -0,0 +1,53 @@
+/*-
+ * Copyright (c) 2016 Solarflare Communications Inc.
+ * All rights reserved.
+ *
+ * This software was jointly developed between OKTET Labs (under contract
+ * for Solarflare) and Solarflare Communications, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SFC_TX_H
+#define        _SFC_TX_H
+
+#include <rte_mbuf.h>
+#include <rte_ethdev.h>
+
+#include "efx.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct sfc_adapter;
+
+struct sfc_txq_info {
+};
+
+int sfc_tx_init(struct sfc_adapter *sa);
+void sfc_tx_fini(struct sfc_adapter *sa);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* _SFC_TX_H */
-- 
2.5.5

Reply via email to