[dpdk-dev] [PATCH v2] vfio: Fix overflow while assigning vfio BAR region offset and size

2015-07-10 Thread Rahul Lakkireddy
On Tue, Jul 07, 2015 at 10:50:23 +, Burakov, Anatoly wrote:
> Hi Rahul,
> 
> > However, unsigned long seems to be working fine for all builds.
> 
> unsigned long it is then, if there aren't any other objections.
> 
> Thanks,
> Anatoly

Hi Alejandro,

Are you planning to update the original patch as per below and re-submit:
http://dpdk.org/ml/archives/dev/2015-July/020963.html

Or, I can also submit it if you want.
Please let me know.

Thanks,
Rahul



[dpdk-dev] [PATCH v3] vfio: Fix overflow while assigning vfio BAR region offset and size

2015-07-13 Thread Rahul Lakkireddy
When using vfio, the probe fails for BAR > 0 after the
commit-id 90a1633b2 (eal/linux: allow to map BARs with MSI-X tables).

While debugging further, found that the BAR region offset and size read from
vfio are u64, but are assigned to uint32_t variables.  This results in the u64
value getting truncated to 0 and passing wrong offset and size to mmap for
subsequent BAR regions.

The fix is to use unsigned long for the offset and size.

This is based on patch by Alejandro Lucero 
posted at below:

http://dpdk.org/ml/archives/dev/2015-June/020201.html

and updated with diff from below to fix 32-bit compilation:

http://dpdk.org/ml/archives/dev/2015-July/020963.html

Fixes: 90a1633b2347 ("eal/linux: allow to map BARs with MSI-X tables")
Signed-off-by: Rahul Lakkireddy 
Signed-off-by: Kumar Sanghvi 
---
v3:
- Use unsigned long instead and updated the commit log.

v2:
- For fixing 32-bit build failure, rather than converting uint32_t var to 
uint64_t
  as done in v1, taking a different approach instead to revert a part of above
  commit-id so as to use the original region offset and size directly.
- Add the commit-id that this patch fixes and update commit log.

 lib/librte_eal/linuxapp/eal/eal_pci_vfio.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c 
b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
index 426953a..6127f5f 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
@@ -728,7 +728,7 @@ pci_vfio_map_resource(struct rte_pci_device *dev)
struct vfio_region_info reg = { .argsz = sizeof(reg) };
void *bar_addr;
struct memreg {
-   uint32_t offset, size;
+   unsigned long offset, size;
} memreg[2] = {};

reg.index = i;
@@ -771,7 +771,7 @@ pci_vfio_map_resource(struct rte_pci_device *dev)
RTE_LOG(DEBUG, EAL,
"Trying to map BAR %d that contains the 
MSI-X "
"table. Trying offsets: "
-   "%04x:%04x, %04x:%04x\n", i,
+   "0x%04lx:0x%04lx, 0x%04lx:0x%04lx\n", i,
memreg[0].offset, memreg[0].size,
memreg[1].offset, memreg[1].size);
}
-- 
2.4.1



[dpdk-dev] [PATCH] doc: Spell fixes, re-organize and update CXGBE documentation

2015-07-16 Thread Rahul Lakkireddy
Fix spelling and grammar errors.  Re-organize sections for better explanation
in the documentation.  Add a section describing compilation of CXGBE with DPDK.
Add a note describing that CXGBE currently only supports binding to PF4.

Signed-off-by: Rahul Lakkireddy 
Signed-off-by: Kumar Sanghvi 
---
 doc/guides/nics/cxgbe.rst | 95 +++
 1 file changed, 54 insertions(+), 41 deletions(-)

diff --git a/doc/guides/nics/cxgbe.rst b/doc/guides/nics/cxgbe.rst
index 6ac5e07..7557db0 100644
--- a/doc/guides/nics/cxgbe.rst
+++ b/doc/guides/nics/cxgbe.rst
@@ -34,21 +34,21 @@ CXGBE Poll Mode Driver
 The CXGBE PMD (**librte_pmd_cxgbe**) provides poll mode driver support
 for **Chelsio T5** 10/40 Gbps family of adapters.

-More information can be found at `Chelsio Communications
+More information can be found at `Chelsio Communications Official Website
 <http://www.chelsio.com>`_.

 Features
 

-CXGBE PMD has the support for:
+CXGBE PMD has support for:

-- Multiple queues for TX and RX.
-- Receiver Side Steering (RSS).
-- VLAN filtering.
-- Checksum offload.
-- Promiscuous mode.
-- All multicast mode.
-- Port hardware statistics.
+- Multiple queues for TX and RX
+- Receiver Side Steering (RSS)
+- VLAN filtering
+- Checksum offload
+- Promiscuous mode
+- All multicast mode
+- Port hardware statistics

 Limitations
 ---
@@ -57,16 +57,35 @@ The Chelsio T5 devices provide two/four ports but expose a 
single PCI bus
 address, thus, librte_pmd_cxgbe registers itself as a
 PCI driver that allocates one Ethernet device per detected port.

-For this reason, one cannot white/blacklist a single port without also
-white/blacklisting the others on the same device.
+For this reason, one cannot whitelist/blacklist a single port without
+whitelisting/blacklisting the other ports on the same device.

-Configuration
+Supported Chelsio T5 NICs
+-
+
+- 1G NICs: T502-BT
+- 10G NICs: T520-BT, T520-CR, T520-LL-CR, T520-SO-CR, T540-CR
+- 40G NICs: T580-CR, T580-LP-CR, T580-SO-CR
+- Other T5 NICs: T522-CR
+
+Prerequisites
 -

-Compiling CXGBE PMD
+- Requires firmware version **1.13.32.0** and higher. Visit
+  `Chelsio Download Center <http://service.chelsio.com>`_ to get latest 
firmware
+  bundled with the latest Chelsio Unified Wire package. Installing and loading
+  the latest cxgb4 kernel driver from the Chelsio Unified Wire package should
+  get you the latest firmware. More information can be obtained from the User
+  Guide that is bundled with the Chelsio Unified Wire package.
+
+Pre-Installation Configuration
+--
+
+Config File Options
 ~~~

-These options can be modified in the ``.config`` file.
+The following options can be modified in the ``.config`` file. Please note that
+enabling debugging options may affect system performance.

 - ``CONFIG_RTE_LIBRTE_CXGBE_PMD`` (default **y**)

@@ -74,39 +93,37 @@ These options can be modified in the ``.config`` file.

 - ``CONFIG_RTE_LIBRTE_CXGBE_DEBUG`` (default **n**)

-  Toggle debugging code. Enabling this option adds additional generic debugging
-  messages at the cost of lower performance.
+  Toggle display of generic debugging messages.

 - ``CONFIG_RTE_LIBRTE_CXGBE_DEBUG_REG`` (default **n**)

-  Toggle debugging code. Enabling this option adds additional registers related
-  run-time checks and debugging messages at the cost of lower performance.
+  Toggle display of registers related run-time check messages.

 - ``CONFIG_RTE_LIBRTE_CXGBE_DEBUG_MBOX`` (default **n**)

-  Toggle debugging code. Enabling this option adds additional firmware mailbox
-  related run-time checks and debugging messages at the cost of lower
-  performance.
+  Toggle display of firmware mailbox related run-time check messages.

 - ``CONFIG_RTE_LIBRTE_CXGBE_DEBUG_TX`` (default **n**)

-  Toggle debugging code. Enabling this option adds additional transmission data
-  path run-time checks and debugging messages at the cost of lower performance.
+  Toggle display of transmission data path run-time check messages.

 - ``CONFIG_RTE_LIBRTE_CXGBE_DEBUG_RX`` (default **n**)

-  Toggle debugging code. Enabling this option adds additional receiving data
-  path run-time checks and debugging messages at the cost of lower performance.
+  Toggle display of receiving data path run-time check messages.

-Prerequisites
--
+Driver Compilation
+~~

-- Requires firmware version **1.13.32.0** and higher. Visit
-  `Chelsio Download Center <http://service.chelsio.com>`_ to get latest 
firmware
-  bundled with the latest Chelsio Unified Wire package. Installing and loading
-  the latest cxgb4 kernel driver from the Chelsio Unified Wire package should
-  get you the latest firmware. More information can be obtained from the User
-  Guide that is bundled with the Chelsio Unified Wire package.
+To compile CXGBE PMD for Linux x86_64 gcc target, run t

[dpdk-dev] Does FreeBSD's nic_uio have bind/unbind interface support?

2015-07-16 Thread Rahul Lakkireddy
Hi All,

It seems that on FreeBSD, nic_uio currently only binds the devices matched in
rte_pci_dev_ids.h.  On Linux, it's possible to bind any listed device with
igb_uio or vfio.

The pci device ids supported by cxgbe PMD, maintained in a table, are not part
of rte_pci_dev_ids.h.  Hence, Chelsio T5 cards don't get bound to nic_uio,
resulting in probe failure on FreeBSD.

On manually adding Chelsio pci device id to rte_pci_dev_ids.h, the Chelsio T5
card gets detected fine on FreeBSD.

So, we would like to know and understand if adding all supported Chelsio pci
device ids to rte_pci_dev_ids.h is the correct way of doing things for FreeBSD?

Any suggestions are appreciated.

Thanks,
Rahul


[dpdk-dev] [PATCH 0/3] cxgbe: Fix compilation and enable FreeBSD support for CXGBE PMD

2015-07-18 Thread Rahul Lakkireddy
This series of patches fix compilation and enable CXGBE poll mode driver for
FreeBSD.  The first patch fixes a limitation of nic_uio that only binds to
devices present in rte_pci_dev_ids.h.  The second patch does the actual
compilation fix and enabling of CXGBE PMD for FreeBSD.  The last patch updates
cxgbe documentation to reflect the FreeBSD support for CXGBE PMD.

Rahul Lakkireddy (3):
  nic_uio: Fix to allow any device to be bound to nic_uio
  cxgbe: Enable and fix FreeBSD compilation for CXGBE PMD
  doc: Update documentation to reflect FreeBSD support for CXGBE PMD

 config/common_bsdapp|   2 +-
 doc/guides/nics/cxgbe.rst   | 280 ++--
 drivers/net/cxgbe/base/common.h |   2 +-
 drivers/net/cxgbe/base/t4_hw.c  |   6 +-
 drivers/net/cxgbe/cxgbe_compat.h|  12 +-
 drivers/net/cxgbe/cxgbe_main.c  |   4 +-
 drivers/net/cxgbe/sge.c |  10 +-
 lib/librte_eal/bsdapp/nic_uio/nic_uio.c |  46 ++
 8 files changed, 297 insertions(+), 65 deletions(-)

-- 
2.4.1



[dpdk-dev] [PATCH 1/3] nic_uio: Fix to allow any device to be bound to nic_uio

2015-07-18 Thread Rahul Lakkireddy
nic_uio requires the pci ids to be present in rte_pci_dev_ids.h in order to
bind the devices to nic_uio.  However, it's better to remove this whitelist of
pci ids, and instead rely on hw.nic_uio.bdfs kenv parameter to allow binding
any device to nic_uio.

Suggested-by: David Marchand 
Signed-off-by: Rahul Lakkireddy 
Signed-off-by: Kumar Sanghvi 
---
 lib/librte_eal/bsdapp/nic_uio/nic_uio.c | 46 +
 1 file changed, 12 insertions(+), 34 deletions(-)

diff --git a/lib/librte_eal/bsdapp/nic_uio/nic_uio.c 
b/lib/librte_eal/bsdapp/nic_uio/nic_uio.c
index 2354e84..eca53de 100644
--- a/lib/librte_eal/bsdapp/nic_uio/nic_uio.c
+++ b/lib/librte_eal/bsdapp/nic_uio/nic_uio.c
@@ -106,24 +106,6 @@ struct pci_bdf {
uint32_t function;
 };

-
-#define RTE_PCI_DEV_ID_DECL_EM(vend, dev)  {vend, dev},
-#define RTE_PCI_DEV_ID_DECL_IGB(vend, dev) {vend, dev},
-#define RTE_PCI_DEV_ID_DECL_IGBVF(vend, dev)   {vend, dev},
-#define RTE_PCI_DEV_ID_DECL_IXGBE(vend, dev)   {vend, dev},
-#define RTE_PCI_DEV_ID_DECL_IXGBEVF(vend, dev) {vend, dev},
-#define RTE_PCI_DEV_ID_DECL_I40E(vend, dev){vend, dev},
-#define RTE_PCI_DEV_ID_DECL_I40EVF(vend, dev)  {vend, dev},
-#define RTE_PCI_DEV_ID_DECL_VIRTIO(vend, dev)  {vend, dev},
-#define RTE_PCI_DEV_ID_DECL_VMXNET3(vend, dev) {vend, dev},
-#define RTE_PCI_DEV_ID_DECL_ENIC(vend, dev){vend, dev},
-
-const struct device devices[] = {
-#include 
-};
-#define NUM_DEVICES (sizeof(devices)/sizeof(devices[0]))
-
-
 static devclass_t nic_uio_devclass;

 DEFINE_CLASS_0(nic_uio, nic_uio_driver, nic_uio_methods, sizeof(struct 
nic_uio_softc));
@@ -195,10 +177,9 @@ nic_uio_probe (device_t dev)
 {
int i;

-   for (i = 0; i < NUM_DEVICES; i++)
-   if (pci_get_vendor(dev) == devices[i].vend &&
-   pci_get_device(dev) == devices[i].dev) {
-
+   for (i = 0; i < num_detached; i++)
+   if (pci_get_vendor(dev) == pci_get_vendor(detached_devices[i]) 
&&
+   pci_get_device(dev) == pci_get_device(detached_devices[i])) 
{
device_set_desc(dev, "Intel(R) DPDK PCI Device");
return BUS_PROBE_SPECIFIC;
}
@@ -256,7 +237,6 @@ static void
 nic_uio_load(void)
 {
uint32_t bus, device, function;
-   int i;
device_t dev;
char bdf_str[256];
char *token, *remaining;
@@ -295,17 +275,15 @@ nic_uio_load(void)
if (dev == NULL)
continue;

-   for (i = 0; i < NUM_DEVICES; i++)
-   if (pci_get_vendor(dev) == devices[i].vend &&
-   pci_get_device(dev) == devices[i].dev) {
-   if (num_detached < 
MAX_DETACHED_DEVICES) {
-   printf("nic_uio_load: 
detaching and storing dev=%p\n", dev);
-   
detached_devices[num_detached++] = dev;
-   } else
-   printf("nic_uio_load: 
reached MAX_DETACHED_DEVICES=%d. dev=%p won't be reattached\n",
-   
MAX_DETACHED_DEVICES, dev);
-   device_detach(dev);
-   }
+   if (num_detached < MAX_DETACHED_DEVICES) {
+   printf("nic_uio_load: detaching and storing dev=%p\n",
+  dev);
+   detached_devices[num_detached++] = dev;
+   } else {
+   printf("nic_uio_load: reached MAX_DETACHED_DEVICES=%d. 
dev=%p won't be reattached\n",
+  MAX_DETACHED_DEVICES, dev);
+   }
+   device_detach(dev);
}
 }

-- 
2.4.1



[dpdk-dev] [PATCH 2/3] cxgbe: Enable and fix FreeBSD compilation for CXGBE PMD

2015-07-18 Thread Rahul Lakkireddy
Fix "MACRO redefined" and "function redefined" compilation errors in FreeBSD
by adding CXGBE prefix to them.  Also remove reference to a linux header
linux/if_ether.h and use DPDK macros directly.  Finally, enable CXGBE PMD for
FreeBSD.

Signed-off-by: Rahul Lakkireddy 
Signed-off-by: Kumar Sanghvi 
---
 config/common_bsdapp |  2 +-
 drivers/net/cxgbe/base/common.h  |  2 +-
 drivers/net/cxgbe/base/t4_hw.c   |  6 +++---
 drivers/net/cxgbe/cxgbe_compat.h | 12 ++--
 drivers/net/cxgbe/cxgbe_main.c   |  4 ++--
 drivers/net/cxgbe/sge.c  | 10 +-
 6 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/config/common_bsdapp b/config/common_bsdapp
index 4e505bf..e96e4a5 100644
--- a/config/common_bsdapp
+++ b/config/common_bsdapp
@@ -217,7 +217,7 @@ CONFIG_RTE_LIBRTE_MLX4_SOFT_COUNTERS=1
 #
 # Compile burst-oriented Chelsio Terminator 10GbE/40GbE (CXGBE) PMD
 #
-CONFIG_RTE_LIBRTE_CXGBE_PMD=n
+CONFIG_RTE_LIBRTE_CXGBE_PMD=y
 CONFIG_RTE_LIBRTE_CXGBE_DEBUG=n
 CONFIG_RTE_LIBRTE_CXGBE_DEBUG_REG=n
 CONFIG_RTE_LIBRTE_CXGBE_DEBUG_MBOX=n
diff --git a/drivers/net/cxgbe/base/common.h b/drivers/net/cxgbe/base/common.h
index 6ddc7d4..cf2e82d 100644
--- a/drivers/net/cxgbe/base/common.h
+++ b/drivers/net/cxgbe/base/common.h
@@ -43,7 +43,7 @@
 extern "C" {
 #endif

-#define PAGE_SIZE RTE_PGSIZE_4K
+#define CXGBE_PAGE_SIZE RTE_PGSIZE_4K

 enum {
MAX_NPORTS = 4, /* max # of ports */
diff --git a/drivers/net/cxgbe/base/t4_hw.c b/drivers/net/cxgbe/base/t4_hw.c
index c57200e..884d2cf 100644
--- a/drivers/net/cxgbe/base/t4_hw.c
+++ b/drivers/net/cxgbe/base/t4_hw.c
@@ -127,7 +127,7 @@ void t4_load_mtus(struct adapter *adap, const unsigned 
short *mtus,

for (i = 0; i < NMTUS; ++i) {
unsigned int mtu = mtus[i];
-   unsigned int log2 = fls(mtu);
+   unsigned int log2 = cxgbe_fls(mtu);

if (!(mtu & ((1 << log2) >> 2))) /* round */
log2--;
@@ -1545,11 +1545,11 @@ int t4_fixup_host_params_compat(struct adapter *adap,
unsigned int cache_line_size,
enum chip_type chip_compat)
 {
-   unsigned int page_shift = fls(page_size) - 1;
+   unsigned int page_shift = cxgbe_fls(page_size) - 1;
unsigned int sge_hps = page_shift - 10;
unsigned int stat_len = cache_line_size > 64 ? 128 : 64;
unsigned int fl_align = cache_line_size < 32 ? 32 : cache_line_size;
-   unsigned int fl_align_log = fls(fl_align) - 1;
+   unsigned int fl_align_log = cxgbe_fls(fl_align) - 1;

t4_write_reg(adap, A_SGE_HOST_PAGE_SIZE,
 V_HOSTPAGESIZEPF0(sge_hps) |
diff --git a/drivers/net/cxgbe/cxgbe_compat.h b/drivers/net/cxgbe/cxgbe_compat.h
index 3b871ee..e68f8f5 100644
--- a/drivers/net/cxgbe/cxgbe_compat.h
+++ b/drivers/net/cxgbe/cxgbe_compat.h
@@ -119,8 +119,8 @@
 #define L1_CACHE_BYTES  BIT(L1_CACHE_SHIFT)

 #define PAGE_SHIFT  12
-#define ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1))
-#define PTR_ALIGN(p, a) ((typeof(p))ALIGN((unsigned long)(p), (a)))
+#define CXGBE_ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1))
+#define PTR_ALIGN(p, a) ((typeof(p))CXGBE_ALIGN((unsigned long)(p), (a)))

 #define VLAN_HLEN 4

@@ -178,7 +178,7 @@ typedef uint64_t  dma_addr_t;
 /*
  * round up val _p to a power of 2 size _s
  */
-#define roundup(_p, _s) (((unsigned long)(_p) + (_s - 1)) & ~(_s - 1))
+#define cxgbe_roundup(_p, _s) (((unsigned long)(_p) + (_s - 1)) & ~(_s - 1))

 #undef container_of
 #define container_of(ptr, type, member) ({ \
@@ -214,13 +214,13 @@ static inline uint8_t hweight32(uint32_t word32)
 } /* weight32 */

 /**
- * fls - find last (most-significant) bit set
+ * cxgbe_fls - find last (most-significant) bit set
  * @x: the word to search
  *
  * This is defined the same way as ffs.
- * Note fls(0) = 0, fls(1) = 1, fls(0x8000) = 32.
+ * Note cxgbe_fls(0) = 0, cxgbe_fls(1) = 1, cxgbe_fls(0x8000) = 32.
  */
-static inline int fls(int x)
+static inline int cxgbe_fls(int x)
 {
return x ? sizeof(x) * 8 - __builtin_clz(x) : 0;
 }
diff --git a/drivers/net/cxgbe/cxgbe_main.c b/drivers/net/cxgbe/cxgbe_main.c
index b879820..3755444 100644
--- a/drivers/net/cxgbe/cxgbe_main.c
+++ b/drivers/net/cxgbe/cxgbe_main.c
@@ -411,7 +411,7 @@ static int adap_init0_tweaks(struct adapter *adapter)
 * Line Size, etc.  The firmware default is for a 4KB Page Size and
 * 64B Cache Line Size ...
 */
-   t4_fixup_host_params_compat(adapter, PAGE_SIZE, L1_CACHE_BYTES,
+   t4_fixup_host_params_compat(adapter, CXGBE_PAGE_SIZE, L1_CACHE_BYTES,
T5_LAST_REV);

/*
@@ -1100,7 +1100,7 @@ int cxgbe_probe(struct adapter *adapter)
qpp = 1 << ((t4_read_reg(adapter,
A_SGE_EGRESS_QUEUES_PER_PAGE_PF) >> s_qpp)
   

[dpdk-dev] [PATCH 3/3] doc: Update documentation to reflect FreeBSD support for CXGBE PMD

2015-07-18 Thread Rahul Lakkireddy
Update cxgbe documentation to include support for FreeBSD:
1. Add instructions on how to compile CXGBE PMD in FreeBSD.
2. Add instructions on how to flash firmware image on Chelsio T5 cards in
   FreeBSD.
3. Add sample application usage for FreeBSD.
4. Add an extra step to reload kernel module in Linux in order for the new
   firmware to be loaded.
5. Typo fixes.

Signed-off-by: Rahul Lakkireddy 
Signed-off-by: Kumar Sanghvi 
---
 doc/guides/nics/cxgbe.rst | 280 +++---
 1 file changed, 267 insertions(+), 13 deletions(-)

diff --git a/doc/guides/nics/cxgbe.rst b/doc/guides/nics/cxgbe.rst
index 7557db0..148cd25 100644
--- a/doc/guides/nics/cxgbe.rst
+++ b/doc/guides/nics/cxgbe.rst
@@ -32,7 +32,8 @@ CXGBE Poll Mode Driver
 ==

 The CXGBE PMD (**librte_pmd_cxgbe**) provides poll mode driver support
-for **Chelsio T5** 10/40 Gbps family of adapters.
+for **Chelsio T5** 10/40 Gbps family of adapters. CXGBE PMD has support
+for the latest Linux and FreeBSD operating systems.

 More information can be found at `Chelsio Communications Official Website
 <http://www.chelsio.com>`_.
@@ -73,10 +74,20 @@ Prerequisites

 - Requires firmware version **1.13.32.0** and higher. Visit
   `Chelsio Download Center <http://service.chelsio.com>`_ to get latest 
firmware
-  bundled with the latest Chelsio Unified Wire package. Installing and loading
-  the latest cxgb4 kernel driver from the Chelsio Unified Wire package should
-  get you the latest firmware. More information can be obtained from the User
-  Guide that is bundled with the Chelsio Unified Wire package.
+  bundled with the latest Chelsio Unified Wire package.
+
+  For Linux, installing and loading the latest cxgb4 kernel driver from the
+  Chelsio Unified Wire package should get you the latest firmware. More
+  information can be obtained from the User Guide that is bundled with the
+  Chelsio Unified Wire package.
+
+  For FreeBSD, the latest firmware obtained from the Chelsio Unified Wire
+  package must be manually flashed via cxgbetool available in FreeBSD source
+  repository.
+
+  Instructions on how to manually flash the firmware are given in section
+  :ref:`linux-installation` for Linux and section :ref:`freebsd-installation`
+  for FreeBSD.

 Pre-Installation Configuration
 --
@@ -111,6 +122,8 @@ enabling debugging options may affect system performance.

   Toggle display of receiving data path run-time check messages.

+.. _driver-compilation:
+
 Driver Compilation
 ~~

@@ -122,11 +135,24 @@ command:
cd 
make config T=x86_64-native-linuxapp-gcc install

-Installation
-
+To compile CXGBE PMD for FreeBSD x86_64 clang target, run the following "gmake"
+command:

-Steps to manually install the latest firmware from the downloaded source files
-are as follows:
+.. code-block:: console
+
+   cd 
+   gmake config T=x86_64-native-bsdapp-clang install
+
+Linux
+-
+
+.. _linux-installation:
+
+Linux Installation
+~~
+
+Steps to manually install the latest firmware from the downloaded Chelsio
+Unified Wire package for Linux operating system are as follows:

 #. Load the kernel module:

@@ -166,6 +192,13 @@ are as follows:

   cxgbtool p1p1 loadfw /src/network/firmware/t5fw-*.bin

+#. Unload and reload the kernel module:
+
+   .. code-block:: console
+
+  modprobe -r cxgb4
+  modprobe cxgb4
+
 #. Verify with ethtool:

.. code-block:: console
@@ -179,10 +212,17 @@ are as follows:
   firmware-version: 1.13.32.0, TP 0.1.4.8

 Sample Application Notes
--
+

 This section demonstrates how to launch **testpmd** with Chelsio T5
-devices managed by librte_pmd_cxgbe.
+devices managed by librte_pmd_cxgbe in Linux operating system.
+
+#. Change to DPDK source directory where the target has been compiled in
+   section :ref:`driver-compilation`:
+
+   .. code-block:: console
+
+  cd 

 #. Load the kernel module:

@@ -253,7 +293,7 @@ devices managed by librte_pmd_cxgbe.

.. note::

-  CXGBE PMD currently only supports the binding of PF4 for Chelsio T5 NICs.
+  Currently, CXGBE PMD only supports the binding of PF4 for Chelsio T5 
NICs.

 #. Start testpmd with basic parameters:

@@ -271,7 +311,221 @@ devices managed by librte_pmd_cxgbe.
   EAL:   PCI memory mapped at 0x7fd7c020
   EAL:   PCI memory mapped at 0x7fd77cdfd000
   EAL:   PCI memory mapped at 0x7fd7c10b7000
-  PMD: rte_cxgbe_pmd: fw: 1.13.33.0, TP: 0.1.4.8
+  PMD: rte_cxgbe_pmd: fw: 1.13.32.0, TP: 0.1.4.8
+  PMD: rte_cxgbe_pmd: Coming up as MASTER: Initializing adapter
+  Interactive-mode selected
+  Configuring Port 0 (socket 0)
+  Port 0: 00:07:43:2D:EA:C0
+  Configuring Port 1 (socket 0)
+  Port 1: 00:07:43:2D:EA:C8
+  Checking link statuses...
+  PMD: rte_cxgbe_pmd: Port0: passive DA port module inserted
+  PMD

[dpdk-dev] [PATCH v2 0/3] cxgbe: Fix compilation and enable FreeBSD support for CXGBE PMD

2015-07-20 Thread Rahul Lakkireddy
This series of patches fix compilation and enable CXGBE poll mode driver for
FreeBSD.  The first patch fixes a limitation of nic_uio that only binds to
devices present in rte_pci_dev_ids.h.  The second patch does the actual
compilation fix and enabling of CXGBE PMD for FreeBSD.  The last patch updates
cxgbe documentation to reflect the FreeBSD support for CXGBE PMD.

v2:
- Replace "Intel(R) DPDK" with just "DPDK" in device description for nic_uio.

Rahul Lakkireddy (3):
  nic_uio: Fix to allow any device to be bound to nic_uio
  cxgbe: Enable and fix FreeBSD compilation for CXGBE PMD
  doc: Update documentation to reflect FreeBSD support for CXGBE PMD

 config/common_bsdapp|   2 +-
 doc/guides/nics/cxgbe.rst   | 280 ++--
 drivers/net/cxgbe/base/common.h |   2 +-
 drivers/net/cxgbe/base/t4_hw.c  |   6 +-
 drivers/net/cxgbe/cxgbe_compat.h|  12 +-
 drivers/net/cxgbe/cxgbe_main.c  |   4 +-
 drivers/net/cxgbe/sge.c |  10 +-
 lib/librte_eal/bsdapp/nic_uio/nic_uio.c |  48 ++
 8 files changed, 298 insertions(+), 66 deletions(-)

-- 
2.4.1



[dpdk-dev] [PATCH v2 2/3] cxgbe: Enable and fix FreeBSD compilation for CXGBE PMD

2015-07-20 Thread Rahul Lakkireddy
Fix "MACRO redefined" and "function redefined" compilation errors in FreeBSD
by adding CXGBE prefix to them.  Also remove reference to a linux header
linux/if_ether.h and use DPDK macros directly.  Finally, enable CXGBE PMD for
FreeBSD.

Signed-off-by: Rahul Lakkireddy 
Signed-off-by: Kumar Sanghvi 
---
v2:
- No changes.

 config/common_bsdapp |  2 +-
 drivers/net/cxgbe/base/common.h  |  2 +-
 drivers/net/cxgbe/base/t4_hw.c   |  6 +++---
 drivers/net/cxgbe/cxgbe_compat.h | 12 ++--
 drivers/net/cxgbe/cxgbe_main.c   |  4 ++--
 drivers/net/cxgbe/sge.c  | 10 +-
 6 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/config/common_bsdapp b/config/common_bsdapp
index 4e505bf..e96e4a5 100644
--- a/config/common_bsdapp
+++ b/config/common_bsdapp
@@ -217,7 +217,7 @@ CONFIG_RTE_LIBRTE_MLX4_SOFT_COUNTERS=1
 #
 # Compile burst-oriented Chelsio Terminator 10GbE/40GbE (CXGBE) PMD
 #
-CONFIG_RTE_LIBRTE_CXGBE_PMD=n
+CONFIG_RTE_LIBRTE_CXGBE_PMD=y
 CONFIG_RTE_LIBRTE_CXGBE_DEBUG=n
 CONFIG_RTE_LIBRTE_CXGBE_DEBUG_REG=n
 CONFIG_RTE_LIBRTE_CXGBE_DEBUG_MBOX=n
diff --git a/drivers/net/cxgbe/base/common.h b/drivers/net/cxgbe/base/common.h
index 6ddc7d4..cf2e82d 100644
--- a/drivers/net/cxgbe/base/common.h
+++ b/drivers/net/cxgbe/base/common.h
@@ -43,7 +43,7 @@
 extern "C" {
 #endif

-#define PAGE_SIZE RTE_PGSIZE_4K
+#define CXGBE_PAGE_SIZE RTE_PGSIZE_4K

 enum {
MAX_NPORTS = 4, /* max # of ports */
diff --git a/drivers/net/cxgbe/base/t4_hw.c b/drivers/net/cxgbe/base/t4_hw.c
index c57200e..884d2cf 100644
--- a/drivers/net/cxgbe/base/t4_hw.c
+++ b/drivers/net/cxgbe/base/t4_hw.c
@@ -127,7 +127,7 @@ void t4_load_mtus(struct adapter *adap, const unsigned 
short *mtus,

for (i = 0; i < NMTUS; ++i) {
unsigned int mtu = mtus[i];
-   unsigned int log2 = fls(mtu);
+   unsigned int log2 = cxgbe_fls(mtu);

if (!(mtu & ((1 << log2) >> 2))) /* round */
log2--;
@@ -1545,11 +1545,11 @@ int t4_fixup_host_params_compat(struct adapter *adap,
unsigned int cache_line_size,
enum chip_type chip_compat)
 {
-   unsigned int page_shift = fls(page_size) - 1;
+   unsigned int page_shift = cxgbe_fls(page_size) - 1;
unsigned int sge_hps = page_shift - 10;
unsigned int stat_len = cache_line_size > 64 ? 128 : 64;
unsigned int fl_align = cache_line_size < 32 ? 32 : cache_line_size;
-   unsigned int fl_align_log = fls(fl_align) - 1;
+   unsigned int fl_align_log = cxgbe_fls(fl_align) - 1;

t4_write_reg(adap, A_SGE_HOST_PAGE_SIZE,
 V_HOSTPAGESIZEPF0(sge_hps) |
diff --git a/drivers/net/cxgbe/cxgbe_compat.h b/drivers/net/cxgbe/cxgbe_compat.h
index 3b871ee..e68f8f5 100644
--- a/drivers/net/cxgbe/cxgbe_compat.h
+++ b/drivers/net/cxgbe/cxgbe_compat.h
@@ -119,8 +119,8 @@
 #define L1_CACHE_BYTES  BIT(L1_CACHE_SHIFT)

 #define PAGE_SHIFT  12
-#define ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1))
-#define PTR_ALIGN(p, a) ((typeof(p))ALIGN((unsigned long)(p), (a)))
+#define CXGBE_ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1))
+#define PTR_ALIGN(p, a) ((typeof(p))CXGBE_ALIGN((unsigned long)(p), (a)))

 #define VLAN_HLEN 4

@@ -178,7 +178,7 @@ typedef uint64_t  dma_addr_t;
 /*
  * round up val _p to a power of 2 size _s
  */
-#define roundup(_p, _s) (((unsigned long)(_p) + (_s - 1)) & ~(_s - 1))
+#define cxgbe_roundup(_p, _s) (((unsigned long)(_p) + (_s - 1)) & ~(_s - 1))

 #undef container_of
 #define container_of(ptr, type, member) ({ \
@@ -214,13 +214,13 @@ static inline uint8_t hweight32(uint32_t word32)
 } /* weight32 */

 /**
- * fls - find last (most-significant) bit set
+ * cxgbe_fls - find last (most-significant) bit set
  * @x: the word to search
  *
  * This is defined the same way as ffs.
- * Note fls(0) = 0, fls(1) = 1, fls(0x8000) = 32.
+ * Note cxgbe_fls(0) = 0, cxgbe_fls(1) = 1, cxgbe_fls(0x8000) = 32.
  */
-static inline int fls(int x)
+static inline int cxgbe_fls(int x)
 {
return x ? sizeof(x) * 8 - __builtin_clz(x) : 0;
 }
diff --git a/drivers/net/cxgbe/cxgbe_main.c b/drivers/net/cxgbe/cxgbe_main.c
index b879820..3755444 100644
--- a/drivers/net/cxgbe/cxgbe_main.c
+++ b/drivers/net/cxgbe/cxgbe_main.c
@@ -411,7 +411,7 @@ static int adap_init0_tweaks(struct adapter *adapter)
 * Line Size, etc.  The firmware default is for a 4KB Page Size and
 * 64B Cache Line Size ...
 */
-   t4_fixup_host_params_compat(adapter, PAGE_SIZE, L1_CACHE_BYTES,
+   t4_fixup_host_params_compat(adapter, CXGBE_PAGE_SIZE, L1_CACHE_BYTES,
T5_LAST_REV);

/*
@@ -1100,7 +1100,7 @@ int cxgbe_probe(struct adapter *adapter)
qpp = 1 << ((t4_read_reg(adapter,
A_SGE_EGRESS_QUEUES_PER_PAGE_PF) >> s_

[dpdk-dev] [PATCH v2 3/3] doc: Update documentation to reflect FreeBSD support for CXGBE PMD

2015-07-20 Thread Rahul Lakkireddy
Update cxgbe documentation to include support for FreeBSD:
1. Add instructions on how to compile CXGBE PMD in FreeBSD.
2. Add instructions on how to flash firmware image on Chelsio T5 cards in
   FreeBSD.
3. Add sample application usage for FreeBSD.
4. Add an extra step to reload kernel module in Linux in order for the new
   firmware to be loaded.
5. Typo fixes.

Signed-off-by: Rahul Lakkireddy 
Signed-off-by: Kumar Sanghvi 
---
v2:
- No changes.

 doc/guides/nics/cxgbe.rst | 280 +++---
 1 file changed, 267 insertions(+), 13 deletions(-)

diff --git a/doc/guides/nics/cxgbe.rst b/doc/guides/nics/cxgbe.rst
index 7557db0..148cd25 100644
--- a/doc/guides/nics/cxgbe.rst
+++ b/doc/guides/nics/cxgbe.rst
@@ -32,7 +32,8 @@ CXGBE Poll Mode Driver
 ==

 The CXGBE PMD (**librte_pmd_cxgbe**) provides poll mode driver support
-for **Chelsio T5** 10/40 Gbps family of adapters.
+for **Chelsio T5** 10/40 Gbps family of adapters. CXGBE PMD has support
+for the latest Linux and FreeBSD operating systems.

 More information can be found at `Chelsio Communications Official Website
 <http://www.chelsio.com>`_.
@@ -73,10 +74,20 @@ Prerequisites

 - Requires firmware version **1.13.32.0** and higher. Visit
   `Chelsio Download Center <http://service.chelsio.com>`_ to get latest 
firmware
-  bundled with the latest Chelsio Unified Wire package. Installing and loading
-  the latest cxgb4 kernel driver from the Chelsio Unified Wire package should
-  get you the latest firmware. More information can be obtained from the User
-  Guide that is bundled with the Chelsio Unified Wire package.
+  bundled with the latest Chelsio Unified Wire package.
+
+  For Linux, installing and loading the latest cxgb4 kernel driver from the
+  Chelsio Unified Wire package should get you the latest firmware. More
+  information can be obtained from the User Guide that is bundled with the
+  Chelsio Unified Wire package.
+
+  For FreeBSD, the latest firmware obtained from the Chelsio Unified Wire
+  package must be manually flashed via cxgbetool available in FreeBSD source
+  repository.
+
+  Instructions on how to manually flash the firmware are given in section
+  :ref:`linux-installation` for Linux and section :ref:`freebsd-installation`
+  for FreeBSD.

 Pre-Installation Configuration
 --
@@ -111,6 +122,8 @@ enabling debugging options may affect system performance.

   Toggle display of receiving data path run-time check messages.

+.. _driver-compilation:
+
 Driver Compilation
 ~~

@@ -122,11 +135,24 @@ command:
cd 
make config T=x86_64-native-linuxapp-gcc install

-Installation
-
+To compile CXGBE PMD for FreeBSD x86_64 clang target, run the following "gmake"
+command:

-Steps to manually install the latest firmware from the downloaded source files
-are as follows:
+.. code-block:: console
+
+   cd 
+   gmake config T=x86_64-native-bsdapp-clang install
+
+Linux
+-
+
+.. _linux-installation:
+
+Linux Installation
+~~
+
+Steps to manually install the latest firmware from the downloaded Chelsio
+Unified Wire package for Linux operating system are as follows:

 #. Load the kernel module:

@@ -166,6 +192,13 @@ are as follows:

   cxgbtool p1p1 loadfw /src/network/firmware/t5fw-*.bin

+#. Unload and reload the kernel module:
+
+   .. code-block:: console
+
+  modprobe -r cxgb4
+  modprobe cxgb4
+
 #. Verify with ethtool:

.. code-block:: console
@@ -179,10 +212,17 @@ are as follows:
   firmware-version: 1.13.32.0, TP 0.1.4.8

 Sample Application Notes
--
+

 This section demonstrates how to launch **testpmd** with Chelsio T5
-devices managed by librte_pmd_cxgbe.
+devices managed by librte_pmd_cxgbe in Linux operating system.
+
+#. Change to DPDK source directory where the target has been compiled in
+   section :ref:`driver-compilation`:
+
+   .. code-block:: console
+
+  cd 

 #. Load the kernel module:

@@ -253,7 +293,7 @@ devices managed by librte_pmd_cxgbe.

.. note::

-  CXGBE PMD currently only supports the binding of PF4 for Chelsio T5 NICs.
+  Currently, CXGBE PMD only supports the binding of PF4 for Chelsio T5 
NICs.

 #. Start testpmd with basic parameters:

@@ -271,7 +311,221 @@ devices managed by librte_pmd_cxgbe.
   EAL:   PCI memory mapped at 0x7fd7c020
   EAL:   PCI memory mapped at 0x7fd77cdfd000
   EAL:   PCI memory mapped at 0x7fd7c10b7000
-  PMD: rte_cxgbe_pmd: fw: 1.13.33.0, TP: 0.1.4.8
+  PMD: rte_cxgbe_pmd: fw: 1.13.32.0, TP: 0.1.4.8
+  PMD: rte_cxgbe_pmd: Coming up as MASTER: Initializing adapter
+  Interactive-mode selected
+  Configuring Port 0 (socket 0)
+  Port 0: 00:07:43:2D:EA:C0
+  Configuring Port 1 (socket 0)
+  Port 1: 00:07:43:2D:EA:C8
+  Checking link statuses...
+  PMD: rte_cxgbe_pmd: Port0: passive DA port modu

[dpdk-dev] [PATCH v2 1/3] nic_uio: Fix to allow any device to be bound to nic_uio

2015-07-20 Thread Rahul Lakkireddy
Hi David,

On Mon, Jul 20, 2015 at 09:43:57 +0200, David Marchand wrote:
>Hum, what bothers me is that you do not rely on the same criteria to
>re-attach the devices to nic_uio.
>See below.
> 
>  ?lib/librte_eal/bsdapp/nic_uio/nic_uio.c | 48
>  +
>  ?1 file changed, 13 insertions(+), 35 deletions(-)
> 
>  diff --git a/lib/librte_eal/bsdapp/nic_uio/nic_uio.c
>  b/lib/librte_eal/bsdapp/nic_uio/nic_uio.c
>  index 2354e84..f868dc8 100644
>  --- a/lib/librte_eal/bsdapp/nic_uio/nic_uio.c
>  +++ b/lib/librte_eal/bsdapp/nic_uio/nic_uio.c
>  [snip]
>  @@ -195,11 +177,10 @@ nic_uio_probe (device_t dev)
>  ?{
>  ? ? ? ? int i;
> 
>  -? ? ? ?for (i = 0; i < NUM_DEVICES; i++)
>  -? ? ? ? ? ? ? ?if (pci_get_vendor(dev) == devices[i].vend &&
>  -? ? ? ? ? ? ? ? ? ? ? ?pci_get_device(dev) == devices[i].dev) {
>  -
>  -? ? ? ? ? ? ? ? ? ? ? ?device_set_desc(dev, "Intel(R) DPDK PCI
>  Device");
>  +? ? ? ?for (i = 0; i < num_detached; i++)
>  +? ? ? ? ? ? ? ?if (pci_get_vendor(dev) ==
>  pci_get_vendor(detached_devices[i]) &&
>  +? ? ? ? ? ? ? ? ? ?pci_get_device(dev) ==
>  pci_get_device(detached_devices[i])) {
>  +? ? ? ? ? ? ? ? ? ? ? ?device_set_desc(dev, "DPDK PCI Device");
>  ? ? ? ? ? ? ? ? ? ? ? ? return BUS_PROBE_SPECIFIC;
>  ? ? ? ? ? ? ? ? }
> 
>When going through the probe stuff, the device vendor and type are used as
>the matching criteria.
> 
>  @@ -256,7 +237,6 @@ static void
>  ?nic_uio_load(void)
>  ?{
>  ? ? ? ? uint32_t bus, device, function;
>  -? ? ? ?int i;
>  ? ? ? ? device_t dev;
>  ? ? ? ? char bdf_str[256];
>  ? ? ? ? char *token, *remaining;
>  @@ -295,17 +275,15 @@ nic_uio_load(void)
>  ? ? ? ? ? ? ? ? if (dev == NULL)
>  ? ? ? ? ? ? ? ? ? ? ? ? continue;
> 
>  -? ? ? ? ? ? ? ?for (i = 0; i < NUM_DEVICES; i++)
>  -? ? ? ? ? ? ? ? ? ? ? ?if (pci_get_vendor(dev) == devices[i].vend &&
>  -? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?pci_get_device(dev) ==
>  devices[i].dev) {
>  -? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?if (num_detached <
>  MAX_DETACHED_DEVICES) {
>  -? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
>  ?printf("nic_uio_load: detaching and storing dev=%p\n", dev);
>  -? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
>  ?detached_devices[num_detached++] = dev;
>  -? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?} else
>  -? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
>  ?printf("nic_uio_load: reached MAX_DETACHED_DEVICES=%d. dev=%p won't be
>  reattached\n",
>  -? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
>  ?MAX_DETACHED_DEVICES, dev);
>  -? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?device_detach(dev);
>  -? ? ? ? ? ? ? ? ? ? ? ?}
>  +? ? ? ? ? ? ? ?if (num_detached < MAX_DETACHED_DEVICES) {
>  +? ? ? ? ? ? ? ? ? ? ? ?printf("nic_uio_load: detaching and storing
>  dev=%p\n",
>  +? ? ? ? ? ? ? ? ? ? ? ? ? ? ? dev);
>  +? ? ? ? ? ? ? ? ? ? ? ?detached_devices[num_detached++] = dev;
>  +? ? ? ? ? ? ? ?} else {
>  +? ? ? ? ? ? ? ? ? ? ? ?printf("nic_uio_load: reached
>  MAX_DETACHED_DEVICES=%d. dev=%p won't be reattached\n",
>  +? ? ? ? ? ? ? ? ? ? ? ? ? ? ? MAX_DETACHED_DEVICES, dev);
>  +? ? ? ? ? ? ? ?}
>  +? ? ? ? ? ? ? ?device_detach(dev);
>  ? ? ? ? }
>  ?}
> 
>But here at init time, the bdfs informations are used to detach the pci
>devices.
>I would say this is safer we have the same criteria in both cases.
>I think that the pci addresses are the best criteria since this is what
>the user gives.
>Don't we have them in the dev pointer ?

It looks like we can get them via pci_get_bus(), pci_get_slot(), and
pci_get_function().  Will add check for these 3 info instead of vendor
and device in probe to make it consistent.

> 
>Btw, with this change, we would then be limited to MAX_DETACHED_DEVICES
>devices even if 128 pci devices looks quite big enough to me.
>This part could be reworked (later).
>--
>David Marchand

Thanks,
Rahul


[dpdk-dev] [PATCH v3 0/3] cxgbe: Fix compilation and enable FreeBSD support for CXGBE PMD

2015-07-21 Thread Rahul Lakkireddy
This series of patches fix compilation and enable CXGBE poll mode driver for
FreeBSD.  The first patch fixes a limitation of nic_uio that only binds to
devices present in rte_pci_dev_ids.h.  The second patch does the actual
compilation fix and enabling of CXGBE PMD for FreeBSD.  The last patch updates
cxgbe documentation to reflect the FreeBSD support for CXGBE PMD.

v3:
- Use checks for bus, slot, and function info instead of vendor and device
  during nic_uio probe for better consistency.

v2:
- Replace "Intel(R) DPDK" with just "DPDK" in device description for nic_uio.

Rahul Lakkireddy (3):
  nic_uio: Fix to allow any device to be bound to nic_uio
  cxgbe: Enable and fix FreeBSD compilation for CXGBE PMD
  doc: Update documentation to reflect FreeBSD support for CXGBE PMD

 config/common_bsdapp|   2 +-
 doc/guides/nics/cxgbe.rst   | 280 ++--
 drivers/net/cxgbe/base/common.h |   2 +-
 drivers/net/cxgbe/base/t4_hw.c  |   6 +-
 drivers/net/cxgbe/cxgbe_compat.h|  12 +-
 drivers/net/cxgbe/cxgbe_main.c  |   4 +-
 drivers/net/cxgbe/sge.c |  10 +-
 lib/librte_eal/bsdapp/nic_uio/nic_uio.c |  54 ++
 8 files changed, 303 insertions(+), 67 deletions(-)

-- 
2.4.1



[dpdk-dev] [PATCH v3 1/3] nic_uio: Fix to allow any device to be bound to nic_uio

2015-07-21 Thread Rahul Lakkireddy
nic_uio requires the pci ids to be present in rte_pci_dev_ids.h in order to
bind the devices to nic_uio.  However, it's better to remove this whitelist of
pci ids, and instead rely on hw.nic_uio.bdfs kenv parameter to allow binding
any device to nic_uio.

Suggested-by: David Marchand 
Signed-off-by: Rahul Lakkireddy 
Signed-off-by: Kumar Sanghvi 
---
v3:
- Use checks for bus, slot, and function info instead of vendor and device
  during nic_uio probe for better consistency.

v2:
- Replace "Intel(R) DPDK" with just "DPDK" in device description for nic_uio.

 lib/librte_eal/bsdapp/nic_uio/nic_uio.c | 54 +++--
 1 file changed, 18 insertions(+), 36 deletions(-)

diff --git a/lib/librte_eal/bsdapp/nic_uio/nic_uio.c 
b/lib/librte_eal/bsdapp/nic_uio/nic_uio.c
index 2354e84..99a4975 100644
--- a/lib/librte_eal/bsdapp/nic_uio/nic_uio.c
+++ b/lib/librte_eal/bsdapp/nic_uio/nic_uio.c
@@ -106,24 +106,6 @@ struct pci_bdf {
uint32_t function;
 };

-
-#define RTE_PCI_DEV_ID_DECL_EM(vend, dev)  {vend, dev},
-#define RTE_PCI_DEV_ID_DECL_IGB(vend, dev) {vend, dev},
-#define RTE_PCI_DEV_ID_DECL_IGBVF(vend, dev)   {vend, dev},
-#define RTE_PCI_DEV_ID_DECL_IXGBE(vend, dev)   {vend, dev},
-#define RTE_PCI_DEV_ID_DECL_IXGBEVF(vend, dev) {vend, dev},
-#define RTE_PCI_DEV_ID_DECL_I40E(vend, dev){vend, dev},
-#define RTE_PCI_DEV_ID_DECL_I40EVF(vend, dev)  {vend, dev},
-#define RTE_PCI_DEV_ID_DECL_VIRTIO(vend, dev)  {vend, dev},
-#define RTE_PCI_DEV_ID_DECL_VMXNET3(vend, dev) {vend, dev},
-#define RTE_PCI_DEV_ID_DECL_ENIC(vend, dev){vend, dev},
-
-const struct device devices[] = {
-#include 
-};
-#define NUM_DEVICES (sizeof(devices)/sizeof(devices[0]))
-
-
 static devclass_t nic_uio_devclass;

 DEFINE_CLASS_0(nic_uio, nic_uio_driver, nic_uio_methods, sizeof(struct 
nic_uio_softc));
@@ -194,12 +176,15 @@ static int
 nic_uio_probe (device_t dev)
 {
int i;
-
-   for (i = 0; i < NUM_DEVICES; i++)
-   if (pci_get_vendor(dev) == devices[i].vend &&
-   pci_get_device(dev) == devices[i].dev) {
-
-   device_set_desc(dev, "Intel(R) DPDK PCI Device");
+   unsigned int bus = pci_get_bus(dev);
+   unsigned int device = pci_get_slot(dev);
+   unsigned int function = pci_get_function(dev);
+
+   for (i = 0; i < num_detached; i++)
+   if (bus == pci_get_bus(detached_devices[i]) &&
+   device == pci_get_slot(detached_devices[i]) &&
+   function == pci_get_function(detached_devices[i])) {
+   device_set_desc(dev, "DPDK PCI Device");
return BUS_PROBE_SPECIFIC;
}

@@ -256,7 +241,6 @@ static void
 nic_uio_load(void)
 {
uint32_t bus, device, function;
-   int i;
device_t dev;
char bdf_str[256];
char *token, *remaining;
@@ -295,17 +279,15 @@ nic_uio_load(void)
if (dev == NULL)
continue;

-   for (i = 0; i < NUM_DEVICES; i++)
-   if (pci_get_vendor(dev) == devices[i].vend &&
-   pci_get_device(dev) == devices[i].dev) {
-   if (num_detached < 
MAX_DETACHED_DEVICES) {
-   printf("nic_uio_load: 
detaching and storing dev=%p\n", dev);
-   
detached_devices[num_detached++] = dev;
-   } else
-   printf("nic_uio_load: 
reached MAX_DETACHED_DEVICES=%d. dev=%p won't be reattached\n",
-   
MAX_DETACHED_DEVICES, dev);
-   device_detach(dev);
-   }
+   if (num_detached < MAX_DETACHED_DEVICES) {
+   printf("nic_uio_load: detaching and storing dev=%p\n",
+  dev);
+   detached_devices[num_detached++] = dev;
+   } else {
+   printf("nic_uio_load: reached MAX_DETACHED_DEVICES=%d. 
dev=%p won't be reattached\n",
+  MAX_DETACHED_DEVICES, dev);
+   }
+   device_detach(dev);
}
 }

-- 
2.4.1



[dpdk-dev] [PATCH v3 2/3] cxgbe: Enable and fix FreeBSD compilation for CXGBE PMD

2015-07-21 Thread Rahul Lakkireddy
Fix "MACRO redefined" and "function redefined" compilation errors in FreeBSD
by adding CXGBE prefix to them.  Also remove reference to a linux header
linux/if_ether.h and use DPDK macros directly.  Finally, enable CXGBE PMD for
FreeBSD.

Signed-off-by: Rahul Lakkireddy 
Signed-off-by: Kumar Sanghvi 
---
v3:
- No changes.

v2:
- No changes.

 config/common_bsdapp |  2 +-
 drivers/net/cxgbe/base/common.h  |  2 +-
 drivers/net/cxgbe/base/t4_hw.c   |  6 +++---
 drivers/net/cxgbe/cxgbe_compat.h | 12 ++--
 drivers/net/cxgbe/cxgbe_main.c   |  4 ++--
 drivers/net/cxgbe/sge.c  | 10 +-
 6 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/config/common_bsdapp b/config/common_bsdapp
index 4e505bf..e96e4a5 100644
--- a/config/common_bsdapp
+++ b/config/common_bsdapp
@@ -217,7 +217,7 @@ CONFIG_RTE_LIBRTE_MLX4_SOFT_COUNTERS=1
 #
 # Compile burst-oriented Chelsio Terminator 10GbE/40GbE (CXGBE) PMD
 #
-CONFIG_RTE_LIBRTE_CXGBE_PMD=n
+CONFIG_RTE_LIBRTE_CXGBE_PMD=y
 CONFIG_RTE_LIBRTE_CXGBE_DEBUG=n
 CONFIG_RTE_LIBRTE_CXGBE_DEBUG_REG=n
 CONFIG_RTE_LIBRTE_CXGBE_DEBUG_MBOX=n
diff --git a/drivers/net/cxgbe/base/common.h b/drivers/net/cxgbe/base/common.h
index 6ddc7d4..cf2e82d 100644
--- a/drivers/net/cxgbe/base/common.h
+++ b/drivers/net/cxgbe/base/common.h
@@ -43,7 +43,7 @@
 extern "C" {
 #endif

-#define PAGE_SIZE RTE_PGSIZE_4K
+#define CXGBE_PAGE_SIZE RTE_PGSIZE_4K

 enum {
MAX_NPORTS = 4, /* max # of ports */
diff --git a/drivers/net/cxgbe/base/t4_hw.c b/drivers/net/cxgbe/base/t4_hw.c
index c57200e..884d2cf 100644
--- a/drivers/net/cxgbe/base/t4_hw.c
+++ b/drivers/net/cxgbe/base/t4_hw.c
@@ -127,7 +127,7 @@ void t4_load_mtus(struct adapter *adap, const unsigned 
short *mtus,

for (i = 0; i < NMTUS; ++i) {
unsigned int mtu = mtus[i];
-   unsigned int log2 = fls(mtu);
+   unsigned int log2 = cxgbe_fls(mtu);

if (!(mtu & ((1 << log2) >> 2))) /* round */
log2--;
@@ -1545,11 +1545,11 @@ int t4_fixup_host_params_compat(struct adapter *adap,
unsigned int cache_line_size,
enum chip_type chip_compat)
 {
-   unsigned int page_shift = fls(page_size) - 1;
+   unsigned int page_shift = cxgbe_fls(page_size) - 1;
unsigned int sge_hps = page_shift - 10;
unsigned int stat_len = cache_line_size > 64 ? 128 : 64;
unsigned int fl_align = cache_line_size < 32 ? 32 : cache_line_size;
-   unsigned int fl_align_log = fls(fl_align) - 1;
+   unsigned int fl_align_log = cxgbe_fls(fl_align) - 1;

t4_write_reg(adap, A_SGE_HOST_PAGE_SIZE,
 V_HOSTPAGESIZEPF0(sge_hps) |
diff --git a/drivers/net/cxgbe/cxgbe_compat.h b/drivers/net/cxgbe/cxgbe_compat.h
index 3b871ee..e68f8f5 100644
--- a/drivers/net/cxgbe/cxgbe_compat.h
+++ b/drivers/net/cxgbe/cxgbe_compat.h
@@ -119,8 +119,8 @@
 #define L1_CACHE_BYTES  BIT(L1_CACHE_SHIFT)

 #define PAGE_SHIFT  12
-#define ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1))
-#define PTR_ALIGN(p, a) ((typeof(p))ALIGN((unsigned long)(p), (a)))
+#define CXGBE_ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1))
+#define PTR_ALIGN(p, a) ((typeof(p))CXGBE_ALIGN((unsigned long)(p), (a)))

 #define VLAN_HLEN 4

@@ -178,7 +178,7 @@ typedef uint64_t  dma_addr_t;
 /*
  * round up val _p to a power of 2 size _s
  */
-#define roundup(_p, _s) (((unsigned long)(_p) + (_s - 1)) & ~(_s - 1))
+#define cxgbe_roundup(_p, _s) (((unsigned long)(_p) + (_s - 1)) & ~(_s - 1))

 #undef container_of
 #define container_of(ptr, type, member) ({ \
@@ -214,13 +214,13 @@ static inline uint8_t hweight32(uint32_t word32)
 } /* weight32 */

 /**
- * fls - find last (most-significant) bit set
+ * cxgbe_fls - find last (most-significant) bit set
  * @x: the word to search
  *
  * This is defined the same way as ffs.
- * Note fls(0) = 0, fls(1) = 1, fls(0x8000) = 32.
+ * Note cxgbe_fls(0) = 0, cxgbe_fls(1) = 1, cxgbe_fls(0x8000) = 32.
  */
-static inline int fls(int x)
+static inline int cxgbe_fls(int x)
 {
return x ? sizeof(x) * 8 - __builtin_clz(x) : 0;
 }
diff --git a/drivers/net/cxgbe/cxgbe_main.c b/drivers/net/cxgbe/cxgbe_main.c
index b879820..3755444 100644
--- a/drivers/net/cxgbe/cxgbe_main.c
+++ b/drivers/net/cxgbe/cxgbe_main.c
@@ -411,7 +411,7 @@ static int adap_init0_tweaks(struct adapter *adapter)
 * Line Size, etc.  The firmware default is for a 4KB Page Size and
 * 64B Cache Line Size ...
 */
-   t4_fixup_host_params_compat(adapter, PAGE_SIZE, L1_CACHE_BYTES,
+   t4_fixup_host_params_compat(adapter, CXGBE_PAGE_SIZE, L1_CACHE_BYTES,
T5_LAST_REV);

/*
@@ -1100,7 +1100,7 @@ int cxgbe_probe(struct adapter *adapter)
qpp = 1 << ((t4_read_reg(adapter,
A_SGE_EGRESS_QUEUE

[dpdk-dev] [PATCH v3 3/3] doc: Update documentation to reflect FreeBSD support for CXGBE PMD

2015-07-21 Thread Rahul Lakkireddy
Update cxgbe documentation to include support for FreeBSD:
1. Add instructions on how to compile CXGBE PMD in FreeBSD.
2. Add instructions on how to flash firmware image on Chelsio T5 cards in
   FreeBSD.
3. Add sample application usage for FreeBSD.
4. Add an extra step to reload kernel module in Linux in order for the new
   firmware to be loaded.
5. Typo fixes.

Signed-off-by: Rahul Lakkireddy 
Signed-off-by: Kumar Sanghvi 
---
v3:
- No changes.

v2:
- No changes.

 doc/guides/nics/cxgbe.rst | 280 +++---
 1 file changed, 267 insertions(+), 13 deletions(-)

diff --git a/doc/guides/nics/cxgbe.rst b/doc/guides/nics/cxgbe.rst
index 7557db0..148cd25 100644
--- a/doc/guides/nics/cxgbe.rst
+++ b/doc/guides/nics/cxgbe.rst
@@ -32,7 +32,8 @@ CXGBE Poll Mode Driver
 ==

 The CXGBE PMD (**librte_pmd_cxgbe**) provides poll mode driver support
-for **Chelsio T5** 10/40 Gbps family of adapters.
+for **Chelsio T5** 10/40 Gbps family of adapters. CXGBE PMD has support
+for the latest Linux and FreeBSD operating systems.

 More information can be found at `Chelsio Communications Official Website
 <http://www.chelsio.com>`_.
@@ -73,10 +74,20 @@ Prerequisites

 - Requires firmware version **1.13.32.0** and higher. Visit
   `Chelsio Download Center <http://service.chelsio.com>`_ to get latest 
firmware
-  bundled with the latest Chelsio Unified Wire package. Installing and loading
-  the latest cxgb4 kernel driver from the Chelsio Unified Wire package should
-  get you the latest firmware. More information can be obtained from the User
-  Guide that is bundled with the Chelsio Unified Wire package.
+  bundled with the latest Chelsio Unified Wire package.
+
+  For Linux, installing and loading the latest cxgb4 kernel driver from the
+  Chelsio Unified Wire package should get you the latest firmware. More
+  information can be obtained from the User Guide that is bundled with the
+  Chelsio Unified Wire package.
+
+  For FreeBSD, the latest firmware obtained from the Chelsio Unified Wire
+  package must be manually flashed via cxgbetool available in FreeBSD source
+  repository.
+
+  Instructions on how to manually flash the firmware are given in section
+  :ref:`linux-installation` for Linux and section :ref:`freebsd-installation`
+  for FreeBSD.

 Pre-Installation Configuration
 --
@@ -111,6 +122,8 @@ enabling debugging options may affect system performance.

   Toggle display of receiving data path run-time check messages.

+.. _driver-compilation:
+
 Driver Compilation
 ~~

@@ -122,11 +135,24 @@ command:
cd 
make config T=x86_64-native-linuxapp-gcc install

-Installation
-
+To compile CXGBE PMD for FreeBSD x86_64 clang target, run the following "gmake"
+command:

-Steps to manually install the latest firmware from the downloaded source files
-are as follows:
+.. code-block:: console
+
+   cd 
+   gmake config T=x86_64-native-bsdapp-clang install
+
+Linux
+-
+
+.. _linux-installation:
+
+Linux Installation
+~~
+
+Steps to manually install the latest firmware from the downloaded Chelsio
+Unified Wire package for Linux operating system are as follows:

 #. Load the kernel module:

@@ -166,6 +192,13 @@ are as follows:

   cxgbtool p1p1 loadfw /src/network/firmware/t5fw-*.bin

+#. Unload and reload the kernel module:
+
+   .. code-block:: console
+
+  modprobe -r cxgb4
+  modprobe cxgb4
+
 #. Verify with ethtool:

.. code-block:: console
@@ -179,10 +212,17 @@ are as follows:
   firmware-version: 1.13.32.0, TP 0.1.4.8

 Sample Application Notes
--
+

 This section demonstrates how to launch **testpmd** with Chelsio T5
-devices managed by librte_pmd_cxgbe.
+devices managed by librte_pmd_cxgbe in Linux operating system.
+
+#. Change to DPDK source directory where the target has been compiled in
+   section :ref:`driver-compilation`:
+
+   .. code-block:: console
+
+  cd 

 #. Load the kernel module:

@@ -253,7 +293,7 @@ devices managed by librte_pmd_cxgbe.

.. note::

-  CXGBE PMD currently only supports the binding of PF4 for Chelsio T5 NICs.
+  Currently, CXGBE PMD only supports the binding of PF4 for Chelsio T5 
NICs.

 #. Start testpmd with basic parameters:

@@ -271,7 +311,221 @@ devices managed by librte_pmd_cxgbe.
   EAL:   PCI memory mapped at 0x7fd7c020
   EAL:   PCI memory mapped at 0x7fd77cdfd000
   EAL:   PCI memory mapped at 0x7fd7c10b7000
-  PMD: rte_cxgbe_pmd: fw: 1.13.33.0, TP: 0.1.4.8
+  PMD: rte_cxgbe_pmd: fw: 1.13.32.0, TP: 0.1.4.8
+  PMD: rte_cxgbe_pmd: Coming up as MASTER: Initializing adapter
+  Interactive-mode selected
+  Configuring Port 0 (socket 0)
+  Port 0: 00:07:43:2D:EA:C0
+  Configuring Port 1 (socket 0)
+  Port 1: 00:07:43:2D:EA:C8
+  Checking link statuses...
+  PMD: rte_cxgbe_pmd: Port0: 

[dpdk-dev] [PATCH v2 00/11] Chelsio Terminator 5 (T5) 10G/40G Poll Mode Driver

2015-06-02 Thread Rahul Lakkireddy
This series of patches add the CXGBE Poll Mode Driver support for Chelsio
Terminator 5 series of 10G/40G adapters.  The CXGBE PMD is split into multiple
patches.  The first patch adds the hardware specific api for all supported
Chelsio T5 adapters and the patches from 2 to 8 add the actual DPDK CXGBE PMD.

More information on the CXGBE PMD can be found in the documentation added by
patch 9.  Also, the CXGBE PMD is enabled for compilation and linking by
patch 10.  Finally, update MAINTAINERS file to claim responsibility for the
CXGBE PMD.

v2:
- Move the driver to drivers/net directory and update all config files and
  commit logs.  Also update MAINTAINERS.
- Break the second patch into more patches; incrementally, adding features to
  the cxgbe poll mode driver.
- Replace bitwise operations in finding last (most significant) bit set with
  gcc's __builtin_clz.
- Fix the return value returned by link update eth_dev operation.
- Few bug fixes and code cleanup.

Rahul Lakkireddy (11):
  cxgbe: add hardware specific api for all supported Chelsio T5 series
adapters.
  cxgbe: add cxgbe poll mode driver.
  cxgbe: add device configuration and RX support for cxgbe PMD.
  cxgbe: add TX support for cxgbe PMD.
  cxgbe: add device related operations for cxgbe PMD.
  cxgbe: add port statistics for cxgbe PMD.
  cxgbe: add link related functions for cxgbe PMD.
  cxgbe: add flow control functions for cxgbe PMD.
  doc: add cxgbe PMD documentation under doc/guides/nics/cxgbe.rst
  config: enable cxgbe PMD for compilation and linking.
  maintainers: claim responsibility for cxgbe PMD.

 MAINTAINERS |5 +
 config/common_linuxapp  |   10 +
 doc/guides/nics/cxgbe.rst   |  209 +++
 doc/guides/nics/index.rst   |1 +
 doc/guides/prog_guide/source_org.rst|1 +
 drivers/net/Makefile|1 +
 drivers/net/cxgbe/Makefile  |   74 +
 drivers/net/cxgbe/base/adapter.h|  565 +++
 drivers/net/cxgbe/base/common.h |  401 +
 drivers/net/cxgbe/base/t4_chip_type.h   |   79 +
 drivers/net/cxgbe/base/t4_hw.c  | 2686 +++
 drivers/net/cxgbe/base/t4_hw.h  |  149 ++
 drivers/net/cxgbe/base/t4_msg.h |  345 
 drivers/net/cxgbe/base/t4_pci_id_tbl.h  |  148 ++
 drivers/net/cxgbe/base/t4_regs.h|  779 +
 drivers/net/cxgbe/base/t4_regs_values.h |  168 ++
 drivers/net/cxgbe/base/t4fw_interface.h | 1730 
 drivers/net/cxgbe/cxgbe.h   |   60 +
 drivers/net/cxgbe/cxgbe_compat.h|  266 +++
 drivers/net/cxgbe/cxgbe_ethdev.c|  802 +
 drivers/net/cxgbe/cxgbe_main.c  | 1207 ++
 drivers/net/cxgbe/sge.c | 2253 ++
 mk/rte.app.mk   |1 +
 23 files changed, 11940 insertions(+)
 create mode 100644 doc/guides/nics/cxgbe.rst
 create mode 100644 drivers/net/cxgbe/Makefile
 create mode 100644 drivers/net/cxgbe/base/adapter.h
 create mode 100644 drivers/net/cxgbe/base/common.h
 create mode 100644 drivers/net/cxgbe/base/t4_chip_type.h
 create mode 100644 drivers/net/cxgbe/base/t4_hw.c
 create mode 100644 drivers/net/cxgbe/base/t4_hw.h
 create mode 100644 drivers/net/cxgbe/base/t4_msg.h
 create mode 100644 drivers/net/cxgbe/base/t4_pci_id_tbl.h
 create mode 100644 drivers/net/cxgbe/base/t4_regs.h
 create mode 100644 drivers/net/cxgbe/base/t4_regs_values.h
 create mode 100644 drivers/net/cxgbe/base/t4fw_interface.h
 create mode 100644 drivers/net/cxgbe/cxgbe.h
 create mode 100644 drivers/net/cxgbe/cxgbe_compat.h
 create mode 100644 drivers/net/cxgbe/cxgbe_ethdev.c
 create mode 100644 drivers/net/cxgbe/cxgbe_main.c
 create mode 100644 drivers/net/cxgbe/sge.c

-- 
2.4.1



[dpdk-dev] [PATCH v2 02/11] cxgbe: add cxgbe poll mode driver.

2015-06-02 Thread Rahul Lakkireddy
Adds cxgbe poll mode driver for DPDK under drivers/net/cxgbe directory. This
patch:

1. Adds the Makefile to compile cxgbe pmd.
2. Registers and initializes the cxgbe pmd driver.

Signed-off-by: Rahul Lakkireddy 
Signed-off-by: Kumar Sanghvi 
---
v2:
- Move files to new directory under drivers/net/cxgbe and update commit log.
- Move eth_dev_ops to separate patches.
- Update cxgbe Makefile to use relative rather than absolute path of pmd.
- Replace bitwise operations in fls() with gcc's __builtin_clz().
- Fix an issue in adap_init0_tweaks() related to rx_dma_offset.

 drivers/net/cxgbe/Makefile   |  74 
 drivers/net/cxgbe/cxgbe.h|  48 +++
 drivers/net/cxgbe/cxgbe_compat.h | 266 +++
 drivers/net/cxgbe/cxgbe_ethdev.c | 169 ++
 drivers/net/cxgbe/cxgbe_main.c   | 706 +++
 drivers/net/cxgbe/sge.c  | 311 +
 6 files changed, 1574 insertions(+)
 create mode 100644 drivers/net/cxgbe/Makefile
 create mode 100644 drivers/net/cxgbe/cxgbe.h
 create mode 100644 drivers/net/cxgbe/cxgbe_compat.h
 create mode 100644 drivers/net/cxgbe/cxgbe_ethdev.c
 create mode 100644 drivers/net/cxgbe/cxgbe_main.c
 create mode 100644 drivers/net/cxgbe/sge.c

diff --git a/drivers/net/cxgbe/Makefile b/drivers/net/cxgbe/Makefile
new file mode 100644
index 000..ac07adb
--- /dev/null
+++ b/drivers/net/cxgbe/Makefile
@@ -0,0 +1,74 @@
+#   BSD LICENSE
+#
+#   Copyright(c) 2014-2015 Chelsio Communications.
+#   All rights reserved.
+#
+#   Redistribution and use in source and binary forms, with or without
+#   modification, are permitted provided that the following conditions
+#   are met:
+#
+# * Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# * 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.
+# * Neither the name of Chelsio Communications nor the names of its
+#   contributors may be used to endorse or promote products derived
+#   from this software without specific prior written permission.
+#
+#   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 $(RTE_SDK)/mk/rte.vars.mk
+
+#
+# library name
+#
+LIB = librte_pmd_cxgbe.a
+
+CFLAGS += -I$(SRCDIR)/base/
+CFLAGS += -I$(SRCDIR)
+CFLAGS += -O3
+CFLAGS += $(WERROR_FLAGS)
+
+ifeq ($(CC), icc)
+#
+# CFLAGS for icc
+#
+CFLAGS_BASE_DRIVER = -wd174 -wd593 -wd869 -wd981 -wd2259
+else
+#
+# CFLAGS for gcc
+#
+ifeq ($(shell test $(GCC_VERSION) -ge 44 && echo 1), 1)
+CFLAGS += -Wno-deprecated
+endif
+CFLAGS_BASE_DRIVER = -Wno-unused-parameter -Wno-unused-value
+CFLAGS_BASE_DRIVER += -Wno-strict-aliasing -Wno-format-extra-args
+
+endif
+
+#
+# all source are stored in SRCS-y
+#
+SRCS-$(CONFIG_RTE_LIBRTE_CXGBE_PMD) += cxgbe_ethdev.c
+SRCS-$(CONFIG_RTE_LIBRTE_CXGBE_PMD) += cxgbe_main.c
+SRCS-$(CONFIG_RTE_LIBRTE_CXGBE_PMD) += sge.c
+SRCS-$(CONFIG_RTE_LIBRTE_CXGBE_PMD) += base/t4_hw.c
+
+# this lib depends upon:
+DEPDIRS-$(CONFIG_RTE_LIBRTE_CXGBE_PMD) += lib/librte_eal lib/librte_ether
+DEPDIRS-$(CONFIG_RTE_LIBRTE_CXGBE_PMD) += lib/librte_mempool lib/librte_mbuf
+DEPDIRS-$(CONFIG_RTE_LIBRTE_CXGBE_PMD) += lib/librte_net lib/librte_malloc
+
+include $(RTE_SDK)/mk/rte.lib.mk
diff --git a/drivers/net/cxgbe/cxgbe.h b/drivers/net/cxgbe/cxgbe.h
new file mode 100644
index 000..44d48dc
--- /dev/null
+++ b/drivers/net/cxgbe/cxgbe.h
@@ -0,0 +1,48 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2014-2015 Chelsio Communications.
+ *   All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in
+ *   the documentation and/or other 

[dpdk-dev] [PATCH v2 03/11] cxgbe: add device configuration and RX support for cxgbe PMD.

2015-06-02 Thread Rahul Lakkireddy
Adds RX support for the cxgbe poll mode driver.  This patch:

1. Adds rx queue related eth_dev_ops.
2. Adds RSS support.
3. Adds dev_configure() and dev_infos_get() eth_dev_ops.
4. Adds rx_pkt_burst for receiving packets.

Signed-off-by: Rahul Lakkireddy 
Signed-off-by: Kumar Sanghvi 
---
v2:
- This patch is a subset of patch 2/5 submitted in v1.
- Cleanup some RX related macros and code.

 drivers/net/cxgbe/cxgbe.h|   6 +
 drivers/net/cxgbe/cxgbe_ethdev.c | 183 
 drivers/net/cxgbe/cxgbe_main.c   | 350 +++
 drivers/net/cxgbe/sge.c  | 915 +++
 4 files changed, 1454 insertions(+)

diff --git a/drivers/net/cxgbe/cxgbe.h b/drivers/net/cxgbe/cxgbe.h
index 44d48dc..90d1db0 100644
--- a/drivers/net/cxgbe/cxgbe.h
+++ b/drivers/net/cxgbe/cxgbe.h
@@ -44,5 +44,11 @@
 #define CXGBE_DEFAULT_RX_DESC_SIZE1024 /* Default RX ring size */

 int cxgbe_probe(struct adapter *adapter);
+void init_rspq(struct adapter *adap, struct sge_rspq *q, unsigned int us,
+  unsigned int cnt, unsigned int size, unsigned int iqe_size);
+int setup_sge_fwevtq(struct adapter *adapter);
+void cfg_queues(struct rte_eth_dev *eth_dev);
+int cfg_queue_count(struct rte_eth_dev *eth_dev);
+int setup_rss(struct port_info *pi);

 #endif /* _CXGBE_H_ */
diff --git a/drivers/net/cxgbe/cxgbe_ethdev.c b/drivers/net/cxgbe/cxgbe_ethdev.c
index 30d39b4..1c69973 100644
--- a/drivers/net/cxgbe/cxgbe_ethdev.c
+++ b/drivers/net/cxgbe/cxgbe_ethdev.c
@@ -85,7 +85,189 @@
  */
 #include "t4_pci_id_tbl.h"

+static uint16_t cxgbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
+   uint16_t nb_pkts)
+{
+   struct sge_eth_rxq *rxq = (struct sge_eth_rxq *)rx_queue;
+   unsigned int work_done;
+
+   CXGBE_DEBUG_RX(adapter, "%s: rxq->rspq.cntxt_id = %u; nb_pkts = %d\n",
+  __func__, rxq->rspq.cntxt_id, nb_pkts);
+
+   if (cxgbe_poll(>rspq, rx_pkts, (unsigned int)nb_pkts, _done))
+   dev_err(adapter, "error in cxgbe poll\n");
+
+   CXGBE_DEBUG_RX(adapter, "%s: work_done = %u\n", __func__, work_done);
+   return work_done;
+}
+
+static void cxgbe_dev_info_get(struct rte_eth_dev *eth_dev,
+  struct rte_eth_dev_info *device_info)
+{
+   struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private);
+   struct adapter *adapter = pi->adapter;
+   int max_queues = adapter->sge.max_ethqsets / adapter->params.nports;
+
+   device_info->min_rx_bufsize = 68; /* XXX: Smallest pkt size */
+   device_info->max_rx_pktlen = 1500; /* XXX: For now we support mtu */
+   device_info->max_rx_queues = max_queues;
+   device_info->max_tx_queues = max_queues;
+   device_info->max_mac_addrs = 1;
+   /* XXX: For now we support one MAC/port */
+   device_info->max_vfs = adapter->params.arch.vfcount;
+   device_info->max_vmdq_pools = 0; /* XXX: For now no support for VMDQ */
+
+   device_info->rx_offload_capa = DEV_RX_OFFLOAD_VLAN_STRIP |
+  DEV_RX_OFFLOAD_IPV4_CKSUM |
+  DEV_RX_OFFLOAD_UDP_CKSUM |
+  DEV_RX_OFFLOAD_TCP_CKSUM;
+
+   device_info->tx_offload_capa = 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;
+
+   device_info->reta_size = pi->rss_size;
+}
+
+static int cxgbe_dev_rx_queue_start(struct rte_eth_dev *eth_dev,
+   uint16_t tx_queue_id);
+static void cxgbe_dev_rx_queue_release(void *q);
+
+static int cxgbe_dev_configure(struct rte_eth_dev *eth_dev)
+{
+   struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private);
+   struct adapter *adapter = pi->adapter;
+   int err;
+
+   CXGBE_FUNC_TRACE();
+
+   if (!(adapter->flags & FW_QUEUE_BOUND)) {
+   err = setup_sge_fwevtq(adapter);
+   if (err)
+   return err;
+   adapter->flags |= FW_QUEUE_BOUND;
+   }
+
+   err = cfg_queue_count(eth_dev);
+   if (err)
+   return err;
+
+   return 0;
+}
+
+static int cxgbe_dev_rx_queue_start(struct rte_eth_dev *eth_dev,
+   uint16_t rx_queue_id)
+{
+   struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private);
+   struct adapter *adap = pi->adapter;
+   struct sge_rspq *q;
+
+   dev_debug(adapter, "%s: pi->port_id = %d; rx_queue_id = %d\n",
+ __func__, pi->port_id, rx_queue_id);
+
+   q = eth_dev-&

[dpdk-dev] [PATCH v2 05/11] cxgbe: add device related operations for cxgbe PMD.

2015-06-02 Thread Rahul Lakkireddy
Adds dev_start(), dev_stop(), and dev_close() eth_dev_ops for cxgbe poll
mode driver.

Signed-off-by: Rahul Lakkireddy 
Signed-off-by: Kumar Sanghvi 
---
v2:
- This patch is a subset of patch 2/5 submitted in v1.
- Few changes related to tx bug fixes.

 drivers/net/cxgbe/cxgbe.h|   4 ++
 drivers/net/cxgbe/cxgbe_ethdev.c | 114 
 drivers/net/cxgbe/cxgbe_main.c   | 139 +++
 drivers/net/cxgbe/sge.c  |  58 
 4 files changed, 315 insertions(+)

diff --git a/drivers/net/cxgbe/cxgbe.h b/drivers/net/cxgbe/cxgbe.h
index 90d1db0..bf08baf 100644
--- a/drivers/net/cxgbe/cxgbe.h
+++ b/drivers/net/cxgbe/cxgbe.h
@@ -44,6 +44,10 @@
 #define CXGBE_DEFAULT_RX_DESC_SIZE1024 /* Default RX ring size */

 int cxgbe_probe(struct adapter *adapter);
+int cxgbe_up(struct adapter *adap);
+int cxgbe_down(struct port_info *pi);
+void cxgbe_close(struct adapter *adapter);
+int link_start(struct port_info *pi);
 void init_rspq(struct adapter *adap, struct sge_rspq *q, unsigned int us,
   unsigned int cnt, unsigned int size, unsigned int iqe_size);
 int setup_sge_fwevtq(struct adapter *adapter);
diff --git a/drivers/net/cxgbe/cxgbe_ethdev.c b/drivers/net/cxgbe/cxgbe_ethdev.c
index b6e17e4..cb100fc 100644
--- a/drivers/net/cxgbe/cxgbe_ethdev.c
+++ b/drivers/net/cxgbe/cxgbe_ethdev.c
@@ -171,6 +171,117 @@ static int cxgbe_dev_rx_queue_start(struct rte_eth_dev 
*eth_dev,
 static void cxgbe_dev_tx_queue_release(void *q);
 static void cxgbe_dev_rx_queue_release(void *q);

+/*
+ * Stop device.
+ */
+static void cxgbe_dev_close(struct rte_eth_dev *eth_dev)
+{
+   struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private);
+   struct adapter *adapter = pi->adapter;
+   int i, dev_down = 0;
+
+   CXGBE_FUNC_TRACE();
+
+   if (!(adapter->flags & FULL_INIT_DONE))
+   return;
+
+   cxgbe_down(pi);
+
+   /*
+*  We clear queues only if both tx and rx path of the port
+*  have been disabled
+*/
+   t4_sge_eth_clear_queues(pi);
+
+   /*  See if all ports are down */
+   for_each_port(adapter, i) {
+   pi = adap2pinfo(adapter, i);
+   /*
+* Skip first port of the adapter since it will be closed
+* by DPDK
+*/
+   if (i == 0)
+   continue;
+   dev_down += (pi->eth_dev->data->dev_started == 0) ? 1 : 0;
+   }
+
+   /* If rest of the ports are stopped, then free up resources */
+   if (dev_down == (adapter->params.nports - 1))
+   cxgbe_close(adapter);
+}
+
+/* Start the device.
+ * It returns 0 on success.
+ */
+static int cxgbe_dev_start(struct rte_eth_dev *eth_dev)
+{
+   struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private);
+   struct adapter *adapter = pi->adapter;
+   int err = 0, i;
+
+   CXGBE_FUNC_TRACE();
+
+   /*
+* If we don't have a connection to the firmware there's nothing we
+* can do.
+*/
+   if (!(adapter->flags & FW_OK)) {
+   err = -ENXIO;
+   goto out;
+   }
+
+   if (!(adapter->flags & FULL_INIT_DONE)) {
+   err = cxgbe_up(adapter);
+   if (err < 0)
+   goto out;
+   }
+
+   err = setup_rss(pi);
+   if (err)
+   goto out;
+
+   for (i = 0; i < pi->n_tx_qsets; i++) {
+   err = cxgbe_dev_tx_queue_start(eth_dev, i);
+   if (err)
+   goto out;
+   }
+
+   for (i = 0; i < pi->n_rx_qsets; i++) {
+   err = cxgbe_dev_rx_queue_start(eth_dev, i);
+   if (err)
+   goto out;
+   }
+
+   err = link_start(pi);
+   if (err)
+   goto out;
+
+out:
+   return err;
+}
+
+/*
+ * Stop device: disable rx and tx functions to allow for reconfiguring.
+ */
+static void cxgbe_dev_stop(struct rte_eth_dev *eth_dev)
+{
+   struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private);
+   struct adapter *adapter = pi->adapter;
+
+   CXGBE_FUNC_TRACE();
+
+   if (!(adapter->flags & FULL_INIT_DONE))
+   return;
+
+   cxgbe_down(pi);
+
+   /*
+*  We clear queues only if both tx and rx path of the port
+*  have been disabled
+*/
+   t4_sge_eth_clear_queues(pi);
+}
+
 static int cxgbe_dev_configure(struct rte_eth_dev *eth_dev)
 {
struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private);
@@ -390,6 +501,9 @@ static void cxgbe_dev_rx_queue_release(void *q)
 }

 static struct eth_dev_ops cxgbe_eth_dev_ops = {
+   .dev_start  = cxgbe_dev_start,
+   .dev_stop   = cxgbe_dev_stop,
+   .dev_close  = cxgbe_

[dpdk-dev] [PATCH v2 06/11] cxgbe: add port statistics for cxgbe PMD.

2015-06-02 Thread Rahul Lakkireddy
Adds stats_get() and stats_reset() eth_dev_ops for cxgbe poll mode driver.

Signed-off-by: Rahul Lakkireddy 
Signed-off-by: Kumar Sanghvi 
---
v2:
- This patch is a subset of patch 2/5 submitted in v1.

 drivers/net/cxgbe/cxgbe.h|  2 +
 drivers/net/cxgbe/cxgbe_ethdev.c | 83 
 drivers/net/cxgbe/cxgbe_main.c   | 11 ++
 3 files changed, 96 insertions(+)

diff --git a/drivers/net/cxgbe/cxgbe.h b/drivers/net/cxgbe/cxgbe.h
index bf08baf..97c37d2 100644
--- a/drivers/net/cxgbe/cxgbe.h
+++ b/drivers/net/cxgbe/cxgbe.h
@@ -47,6 +47,8 @@ int cxgbe_probe(struct adapter *adapter);
 int cxgbe_up(struct adapter *adap);
 int cxgbe_down(struct port_info *pi);
 void cxgbe_close(struct adapter *adapter);
+void cxgbe_stats_get(struct port_info *pi, struct port_stats *stats);
+void cxgbe_stats_reset(struct port_info *pi);
 int link_start(struct port_info *pi);
 void init_rspq(struct adapter *adap, struct sge_rspq *q, unsigned int us,
   unsigned int cnt, unsigned int size, unsigned int iqe_size);
diff --git a/drivers/net/cxgbe/cxgbe_ethdev.c b/drivers/net/cxgbe/cxgbe_ethdev.c
index cb100fc..600a16c 100644
--- a/drivers/net/cxgbe/cxgbe_ethdev.c
+++ b/drivers/net/cxgbe/cxgbe_ethdev.c
@@ -500,6 +500,87 @@ static void cxgbe_dev_rx_queue_release(void *q)
}
 }

+/*
+ * Get port statistics.
+ */
+static void cxgbe_dev_stats_get(struct rte_eth_dev *eth_dev,
+   struct rte_eth_stats *eth_stats)
+{
+   struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private);
+   struct adapter *adapter = pi->adapter;
+   struct sge *s = >sge;
+   struct port_stats ps;
+   unsigned int i;
+
+   cxgbe_stats_get(pi, );
+
+   /* RX Stats */
+   eth_stats->ipackets = ps.rx_frames;
+   eth_stats->ibytes   = ps.rx_octets;
+   eth_stats->imcasts  = ps.rx_mcast_frames;
+   eth_stats->imissed  = ps.rx_ovflow0 + ps.rx_ovflow1 +
+ ps.rx_ovflow2 + ps.rx_ovflow3 +
+ ps.rx_trunc0 + ps.rx_trunc1 +
+ ps.rx_trunc2 + ps.rx_trunc3;
+   eth_stats->ibadcrc  = ps.rx_fcs_err;
+   eth_stats->ibadlen  = ps.rx_jabber + ps.rx_too_long + ps.rx_runt;
+   eth_stats->ierrors  = ps.rx_symbol_err + eth_stats->ibadcrc +
+ eth_stats->ibadlen + ps.rx_len_err +
+ eth_stats->imissed;
+   eth_stats->rx_pause_xon  = ps.rx_pause;
+
+   /* TX Stats */
+   eth_stats->opackets = ps.tx_frames;
+   eth_stats->obytes   = ps.tx_octets;
+   eth_stats->oerrors  = ps.tx_error_frames;
+   eth_stats->tx_pause_xon  = ps.tx_pause;
+
+   for (i = 0; i < pi->n_rx_qsets; i++) {
+   struct sge_eth_rxq *rxq =
+   >ethrxq[pi->first_qset + i];
+
+   eth_stats->q_ipackets[i] = rxq->stats.pkts;
+   eth_stats->q_ibytes[i] = rxq->stats.rx_bytes;
+   }
+
+   for (i = 0; i < pi->n_tx_qsets; i++) {
+   struct sge_eth_txq *txq =
+   >ethtxq[pi->first_qset + i];
+
+   eth_stats->q_opackets[i] = txq->stats.pkts;
+   eth_stats->q_obytes[i] = txq->stats.tx_bytes;
+   eth_stats->q_errors[i] = txq->stats.mapping_err;
+   }
+}
+
+/*
+ * Reset port statistics.
+ */
+static void cxgbe_dev_stats_reset(struct rte_eth_dev *eth_dev)
+{
+   struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private);
+   struct adapter *adapter = pi->adapter;
+   struct sge *s = >sge;
+   unsigned int i;
+
+   cxgbe_stats_reset(pi);
+   for (i = 0; i < pi->n_rx_qsets; i++) {
+   struct sge_eth_rxq *rxq =
+   >ethrxq[pi->first_qset + i];
+
+   rxq->stats.pkts = 0;
+   rxq->stats.rx_bytes = 0;
+   }
+   for (i = 0; i < pi->n_tx_qsets; i++) {
+   struct sge_eth_txq *txq =
+   >ethtxq[pi->first_qset + i];
+
+   txq->stats.pkts = 0;
+   txq->stats.tx_bytes = 0;
+   txq->stats.mapping_err = 0;
+   }
+}
+
 static struct eth_dev_ops cxgbe_eth_dev_ops = {
.dev_start  = cxgbe_dev_start,
.dev_stop   = cxgbe_dev_stop,
@@ -514,6 +595,8 @@ static struct eth_dev_ops cxgbe_eth_dev_ops = {
.rx_queue_start = cxgbe_dev_rx_queue_start,
.rx_queue_stop  = cxgbe_dev_rx_queue_stop,
.rx_queue_release   = cxgbe_dev_rx_queue_release,
+   .stats_get  = cxgbe_dev_stats_get,
+   .stats_reset= cxgbe_dev_stats_reset,
 };

 /*
diff --git a/drivers/net/cxgbe/cxgbe_main.c b/drivers/net/cxgbe/cxgbe_main.c
index 7995d3c..dad0a98 100644
--- a/drivers/net/cxgbe/cxgbe_main.c
+++ b

[dpdk-dev] [PATCH v2 07/11] cxgbe: add link related functions for cxgbe PMD.

2015-06-02 Thread Rahul Lakkireddy
Adds link update, promiscuous and multicast related eth_dev_ops for cxgbe poll
mode driver.

Signed-off-by: Rahul Lakkireddy 
Signed-off-by: Kumar Sanghvi 
---
v2:
- This patch is a subset of patch 2/5 submitted in v1.
- Update cxgbe_dev_link_update() to return correct value.

 drivers/net/cxgbe/cxgbe_ethdev.c | 66 
 1 file changed, 66 insertions(+)

diff --git a/drivers/net/cxgbe/cxgbe_ethdev.c b/drivers/net/cxgbe/cxgbe_ethdev.c
index 600a16c..c0dd5f3 100644
--- a/drivers/net/cxgbe/cxgbe_ethdev.c
+++ b/drivers/net/cxgbe/cxgbe_ethdev.c
@@ -164,6 +164,67 @@ static void cxgbe_dev_info_get(struct rte_eth_dev *eth_dev,
device_info->reta_size = pi->rss_size;
 }

+static void cxgbe_dev_promiscuous_enable(struct rte_eth_dev *eth_dev)
+{
+   struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private);
+   struct adapter *adapter = pi->adapter;
+
+   t4_set_rxmode(adapter, adapter->mbox, pi->viid, -1,
+ 1, -1, 1, -1, false);
+}
+
+static void cxgbe_dev_promiscuous_disable(struct rte_eth_dev *eth_dev)
+{
+   struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private);
+   struct adapter *adapter = pi->adapter;
+
+   t4_set_rxmode(adapter, adapter->mbox, pi->viid, -1,
+ 0, -1, 1, -1, false);
+}
+
+static void cxgbe_dev_allmulticast_enable(struct rte_eth_dev *eth_dev)
+{
+   struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private);
+   struct adapter *adapter = pi->adapter;
+
+   /* TODO: address filters ?? */
+
+   t4_set_rxmode(adapter, adapter->mbox, pi->viid, -1,
+ -1, 1, 1, -1, false);
+}
+
+static void cxgbe_dev_allmulticast_disable(struct rte_eth_dev *eth_dev)
+{
+   struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private);
+   struct adapter *adapter = pi->adapter;
+
+   /* TODO: address filters ?? */
+
+   t4_set_rxmode(adapter, adapter->mbox, pi->viid, -1,
+ -1, 0, 1, -1, false);
+}
+
+static int cxgbe_dev_link_update(struct rte_eth_dev *eth_dev,
+__rte_unused int wait_to_complete)
+{
+   struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private);
+   struct adapter *adapter = pi->adapter;
+   struct sge *s = >sge;
+   struct rte_eth_link *old_link = _dev->data->dev_link;
+   unsigned int work_done, budget = 4;
+
+   cxgbe_poll(>fw_evtq, NULL, budget, _done);
+   if (old_link->link_status == pi->link_cfg.link_ok)
+   return -1;  /* link not changed */
+
+   eth_dev->data->dev_link.link_status = pi->link_cfg.link_ok;
+   eth_dev->data->dev_link.link_duplex = ETH_LINK_FULL_DUPLEX;
+   eth_dev->data->dev_link.link_speed = pi->link_cfg.speed;
+
+   /* link has changed */
+   return 0;
+}
+
 static int cxgbe_dev_tx_queue_start(struct rte_eth_dev *eth_dev,
uint16_t tx_queue_id);
 static int cxgbe_dev_rx_queue_start(struct rte_eth_dev *eth_dev,
@@ -585,8 +646,13 @@ static struct eth_dev_ops cxgbe_eth_dev_ops = {
.dev_start  = cxgbe_dev_start,
.dev_stop   = cxgbe_dev_stop,
.dev_close  = cxgbe_dev_close,
+   .promiscuous_enable = cxgbe_dev_promiscuous_enable,
+   .promiscuous_disable= cxgbe_dev_promiscuous_disable,
+   .allmulticast_enable= cxgbe_dev_allmulticast_enable,
+   .allmulticast_disable   = cxgbe_dev_allmulticast_disable,
.dev_configure  = cxgbe_dev_configure,
.dev_infos_get  = cxgbe_dev_info_get,
+   .link_update= cxgbe_dev_link_update,
.tx_queue_setup = cxgbe_dev_tx_queue_setup,
.tx_queue_start = cxgbe_dev_tx_queue_start,
.tx_queue_stop  = cxgbe_dev_tx_queue_stop,
-- 
2.4.1



[dpdk-dev] [PATCH v2 04/11] cxgbe: add TX support for cxgbe PMD.

2015-06-02 Thread Rahul Lakkireddy
Adds TX support for the cxgbe poll mode driver.  This patch:

1. Adds tx queue related eth_dev_ops.
2. Adds tx_pkt_burst for transmitting packets.

Signed-off-by: Rahul Lakkireddy 
Signed-off-by: Kumar Sanghvi 
---
v2:
- This patch is a subset of patch 2/5 submitted in v1.
- Few bug fixes for tx path.

 drivers/net/cxgbe/cxgbe_ethdev.c | 133 ++
 drivers/net/cxgbe/cxgbe_main.c   |   1 +
 drivers/net/cxgbe/sge.c  | 969 +++
 3 files changed, 1103 insertions(+)

diff --git a/drivers/net/cxgbe/cxgbe_ethdev.c b/drivers/net/cxgbe/cxgbe_ethdev.c
index 1c69973..b6e17e4 100644
--- a/drivers/net/cxgbe/cxgbe_ethdev.c
+++ b/drivers/net/cxgbe/cxgbe_ethdev.c
@@ -85,6 +85,39 @@
  */
 #include "t4_pci_id_tbl.h"

+static uint16_t cxgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
+   uint16_t nb_pkts)
+{
+   struct sge_eth_txq *txq = (struct sge_eth_txq *)tx_queue;
+   uint16_t pkts_sent, pkts_remain;
+   uint16_t total_sent = 0;
+   int ret = 0;
+
+   CXGBE_DEBUG_TX(adapter, "%s: txq = %p; tx_pkts = %p; nb_pkts = %d\n",
+  __func__, txq, tx_pkts, nb_pkts);
+
+   t4_os_lock(>txq_lock);
+   /* free up desc from already completed tx */
+   reclaim_completed_tx(>q);
+   while (total_sent < nb_pkts) {
+   pkts_remain = nb_pkts - total_sent;
+
+   for (pkts_sent = 0; pkts_sent < pkts_remain; pkts_sent++) {
+   ret = t4_eth_xmit(txq, tx_pkts[total_sent + pkts_sent]);
+   if (ret < 0)
+   break;
+   }
+   if (!pkts_sent)
+   break;
+   total_sent += pkts_sent;
+   /* reclaim as much as possible */
+   reclaim_completed_tx(>q);
+   }
+
+   t4_os_unlock(>txq_lock);
+   return total_sent;
+}
+
 static uint16_t cxgbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
uint16_t nb_pkts)
 {
@@ -131,8 +164,11 @@ static void cxgbe_dev_info_get(struct rte_eth_dev *eth_dev,
device_info->reta_size = pi->rss_size;
 }

+static int cxgbe_dev_tx_queue_start(struct rte_eth_dev *eth_dev,
+   uint16_t tx_queue_id);
 static int cxgbe_dev_rx_queue_start(struct rte_eth_dev *eth_dev,
uint16_t tx_queue_id);
+static void cxgbe_dev_tx_queue_release(void *q);
 static void cxgbe_dev_rx_queue_release(void *q);

 static int cxgbe_dev_configure(struct rte_eth_dev *eth_dev)
@@ -157,6 +193,98 @@ static int cxgbe_dev_configure(struct rte_eth_dev *eth_dev)
return 0;
 }

+static int cxgbe_dev_tx_queue_start(struct rte_eth_dev *eth_dev,
+   uint16_t tx_queue_id)
+{
+   struct sge_eth_txq *txq = (struct sge_eth_txq *)
+ (eth_dev->data->tx_queues[tx_queue_id]);
+
+   dev_debug(NULL, "%s: tx_queue_id = %d\n", __func__, tx_queue_id);
+
+   return t4_sge_eth_txq_start(txq);
+}
+
+static int cxgbe_dev_tx_queue_stop(struct rte_eth_dev *eth_dev,
+  uint16_t tx_queue_id)
+{
+   struct sge_eth_txq *txq = (struct sge_eth_txq *)
+ (eth_dev->data->tx_queues[tx_queue_id]);
+
+   dev_debug(NULL, "%s: tx_queue_id = %d\n", __func__, tx_queue_id);
+
+   return t4_sge_eth_txq_stop(txq);
+}
+
+static int cxgbe_dev_tx_queue_setup(struct rte_eth_dev *eth_dev,
+   uint16_t queue_idx, uint16_t nb_desc,
+   unsigned int socket_id,
+   const struct rte_eth_txconf *tx_conf)
+{
+   struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private);
+   struct adapter *adapter = pi->adapter;
+   struct sge *s = >sge;
+   struct sge_eth_txq *txq = >ethtxq[pi->first_qset + queue_idx];
+   int err = 0;
+   unsigned int temp_nb_desc;
+
+   RTE_SET_USED(tx_conf);
+
+   dev_debug(adapter, "%s: eth_dev->data->nb_tx_queues = %d; queue_idx = 
%d; nb_desc = %d; socket_id = %d; pi->first_qset = %u\n",
+ __func__, eth_dev->data->nb_tx_queues, queue_idx, nb_desc,
+ socket_id, pi->first_qset);
+
+   /*  Free up the existing queue  */
+   if (eth_dev->data->tx_queues[queue_idx]) {
+   cxgbe_dev_tx_queue_release(eth_dev->data->tx_queues[queue_idx]);
+   eth_dev->data->tx_queues[queue_idx] = NULL;
+   }
+
+   eth_dev->data->tx_queues[queue_idx] = (void *)txq;
+
+   /* Sanity Checking
+*
+* nb_desc should be > 1023 and <= CXGBE_MAX_RING_DESC_SIZE
+*/
+   temp_nb_desc = nb_desc;
+   if (nb_desc < CXGBE_MIN_RING_DESC_SIZE) {
+

[dpdk-dev] [PATCH v2 08/11] cxgbe: add flow control functions for cxgbe PMD.

2015-06-02 Thread Rahul Lakkireddy
Adds flow control related eth_dev_ops for cxgbe poll mode driver.

Signed-off-by: Rahul Lakkireddy 
Signed-off-by: Kumar Sanghvi 
---
v2:
- This patch is a subset of patch 2/5 submitted in v1.

 drivers/net/cxgbe/cxgbe_ethdev.c | 54 
 1 file changed, 54 insertions(+)

diff --git a/drivers/net/cxgbe/cxgbe_ethdev.c b/drivers/net/cxgbe/cxgbe_ethdev.c
index c0dd5f3..478051a 100644
--- a/drivers/net/cxgbe/cxgbe_ethdev.c
+++ b/drivers/net/cxgbe/cxgbe_ethdev.c
@@ -642,6 +642,58 @@ static void cxgbe_dev_stats_reset(struct rte_eth_dev 
*eth_dev)
}
 }

+static int cxgbe_flow_ctrl_get(struct rte_eth_dev *eth_dev,
+  struct rte_eth_fc_conf *fc_conf)
+{
+   struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private);
+   struct link_config *lc = >link_cfg;
+   int rx_pause, tx_pause;
+
+   fc_conf->autoneg = lc->fc & PAUSE_AUTONEG;
+   rx_pause = lc->fc & PAUSE_RX;
+   tx_pause = lc->fc & PAUSE_TX;
+
+   if (rx_pause && tx_pause)
+   fc_conf->mode = RTE_FC_FULL;
+   else if (rx_pause)
+   fc_conf->mode = RTE_FC_RX_PAUSE;
+   else if (tx_pause)
+   fc_conf->mode = RTE_FC_TX_PAUSE;
+   else
+   fc_conf->mode = RTE_FC_NONE;
+   return 0;
+}
+
+static int cxgbe_flow_ctrl_set(struct rte_eth_dev *eth_dev,
+  struct rte_eth_fc_conf *fc_conf)
+{
+   struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private);
+   struct adapter *adapter = pi->adapter;
+   struct link_config *lc = >link_cfg;
+
+   if (lc->supported & FW_PORT_CAP_ANEG) {
+   if (fc_conf->autoneg)
+   lc->requested_fc |= PAUSE_AUTONEG;
+   else
+   lc->requested_fc &= ~PAUSE_AUTONEG;
+   }
+
+   if (((fc_conf->mode & RTE_FC_FULL) == RTE_FC_FULL) ||
+   (fc_conf->mode & RTE_FC_RX_PAUSE))
+   lc->requested_fc |= PAUSE_RX;
+   else
+   lc->requested_fc &= ~PAUSE_RX;
+
+   if (((fc_conf->mode & RTE_FC_FULL) == RTE_FC_FULL) ||
+   (fc_conf->mode & RTE_FC_TX_PAUSE))
+   lc->requested_fc |= PAUSE_TX;
+   else
+   lc->requested_fc &= ~PAUSE_TX;
+
+   return t4_link_l1cfg(adapter, adapter->mbox, pi->tx_chan,
+>link_cfg);
+}
+
 static struct eth_dev_ops cxgbe_eth_dev_ops = {
.dev_start  = cxgbe_dev_start,
.dev_stop   = cxgbe_dev_stop,
@@ -663,6 +715,8 @@ static struct eth_dev_ops cxgbe_eth_dev_ops = {
.rx_queue_release   = cxgbe_dev_rx_queue_release,
.stats_get  = cxgbe_dev_stats_get,
.stats_reset= cxgbe_dev_stats_reset,
+   .flow_ctrl_get  = cxgbe_flow_ctrl_get,
+   .flow_ctrl_set  = cxgbe_flow_ctrl_set,
 };

 /*
-- 
2.4.1



[dpdk-dev] [PATCH v2 01/11] cxgbe: add hardware specific api for all supported Chelsio T5 series adapters.

2015-06-02 Thread Rahul Lakkireddy
Adds hardware specific api for all the Chelsio T5 adapters under
drivers/net/cxgbe/base directory.

Signed-off-by: Rahul Lakkireddy 
Signed-off-by: Kumar Sanghvi 
---
v2:
- Move files to new directory under drivers/net/cxgbe/base and update commit
  log.
- Few bug fixes related to tx.

 drivers/net/cxgbe/base/adapter.h|  565 +++
 drivers/net/cxgbe/base/common.h |  401 +
 drivers/net/cxgbe/base/t4_chip_type.h   |   79 +
 drivers/net/cxgbe/base/t4_hw.c  | 2686 +++
 drivers/net/cxgbe/base/t4_hw.h  |  149 ++
 drivers/net/cxgbe/base/t4_msg.h |  345 
 drivers/net/cxgbe/base/t4_pci_id_tbl.h  |  148 ++
 drivers/net/cxgbe/base/t4_regs.h|  779 +
 drivers/net/cxgbe/base/t4_regs_values.h |  168 ++
 drivers/net/cxgbe/base/t4fw_interface.h | 1730 
 10 files changed, 7050 insertions(+)
 create mode 100644 drivers/net/cxgbe/base/adapter.h
 create mode 100644 drivers/net/cxgbe/base/common.h
 create mode 100644 drivers/net/cxgbe/base/t4_chip_type.h
 create mode 100644 drivers/net/cxgbe/base/t4_hw.c
 create mode 100644 drivers/net/cxgbe/base/t4_hw.h
 create mode 100644 drivers/net/cxgbe/base/t4_msg.h
 create mode 100644 drivers/net/cxgbe/base/t4_pci_id_tbl.h
 create mode 100644 drivers/net/cxgbe/base/t4_regs.h
 create mode 100644 drivers/net/cxgbe/base/t4_regs_values.h
 create mode 100644 drivers/net/cxgbe/base/t4fw_interface.h

diff --git a/drivers/net/cxgbe/base/adapter.h b/drivers/net/cxgbe/base/adapter.h
new file mode 100644
index 000..0ea1c95
--- /dev/null
+++ b/drivers/net/cxgbe/base/adapter.h
@@ -0,0 +1,565 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2014-2015 Chelsio Communications.
+ *   All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the name of Chelsio Communications nor the names of its
+ *   contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ *   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.
+ */
+
+/* This file should not be included directly.  Include common.h instead. */
+
+#ifndef __T4_ADAPTER_H__
+#define __T4_ADAPTER_H__
+
+#include 
+
+#include "cxgbe_compat.h"
+#include "t4_regs_values.h"
+
+enum {
+   MAX_ETH_QSETS = 64,   /* # of Ethernet Tx/Rx queue sets */
+};
+
+struct adapter;
+struct sge_rspq;
+
+enum {
+   PORT_RSS_DONE = (1 << 0),
+};
+
+struct port_info {
+   struct adapter *adapter;/* adapter that this port belongs to */
+   struct rte_eth_dev *eth_dev;/* associated rte eth device */
+   struct port_stats stats_base;   /* port statistics base */
+   struct link_config link_cfg;/* link configuration info */
+
+   unsigned long flags;/* port related flags */
+   short int xact_addr_filt;   /* index of exact MAC address filter */
+
+   u16viid;/* associated virtual interface id */
+   s8 mdio_addr;   /* address of the PHY */
+   u8 port_type;   /* firmware port type */
+   u8 mod_type;/* firmware module type */
+   u8 port_id; /* physical port ID */
+   u8 tx_chan; /* associated channel */
+
+   u8 n_rx_qsets;  /* # of rx qsets */
+   u8 n_tx_qsets;  /* # of tx qsets */
+   u8 first_qset;  /* index of first qset */
+
+   u16*rss;/* rss table */
+   u8 rss_mode;/* rss mode */
+   u16rss_size;/* size of VI's

[dpdk-dev] [PATCH v2 09/11] doc: add cxgbe PMD documentation under doc/guides/nics/cxgbe.rst

2015-06-02 Thread Rahul Lakkireddy
Adds cxgbe poll mode driver documentation under the usual doc/guides/nics/
directory with the rest of the drivers.  The documentation covers cxgbe
implementation details, features and limitations, prerequisites, configuration,
and a sample application usage.

Signed-off-by: Rahul Lakkireddy 
Signed-off-by: Kumar Sanghvi 
---
v2:
- Move cxgbe entry to Drivers section in source_org.rst.
- Order the cxgbe entry alphabetically in index.rst.

 doc/guides/nics/cxgbe.rst| 209 +++
 doc/guides/nics/index.rst|   1 +
 doc/guides/prog_guide/source_org.rst |   1 +
 3 files changed, 211 insertions(+)
 create mode 100644 doc/guides/nics/cxgbe.rst

diff --git a/doc/guides/nics/cxgbe.rst b/doc/guides/nics/cxgbe.rst
new file mode 100644
index 000..54a019d
--- /dev/null
+++ b/doc/guides/nics/cxgbe.rst
@@ -0,0 +1,209 @@
+..  BSD LICENSE
+Copyright 2015 Chelsio Communications.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+* Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+* 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.
+* Neither the name of Chelsio Communications nor the names of its
+contributors may be used to endorse or promote products derived
+from this software without specific prior written permission.
+
+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.
+
+CXGBE Poll Mode Driver
+==
+
+The CXGBE PMD (**librte_pmd_cxgbe**) provides poll mode driver support
+for **Chelsio T5** 10/40 Gbps family of adapters.
+
+More information can be found at `Chelsio Communications
+<http://www.chelsio.com>`_.
+
+Features
+
+
+CXGBE PMD has the support for:
+
+- Multiple queues for TX and RX.
+- Receiver Side Steering (RSS).
+- VLAN filtering.
+- Checksum offload.
+- Promiscuous mode.
+- All multicast mode.
+- Port hardware statistics.
+
+Limitations
+---
+
+The Chelsio T5 devices provide two/four ports but expose a single PCI bus
+address, thus, librte_pmd_cxgbe registers itself as a
+PCI driver that allocates one Ethernet device per detected port.
+
+For this reason, one cannot white/blacklist a single port without also
+white/blacklisting the others on the same device.
+
+Configuration
+-
+
+Compiling CXGBE PMD
+~~~
+
+These options can be modified in the ``.config`` file.
+
+- ``CONFIG_RTE_LIBRTE_CXGBE_PMD`` (default **y**)
+
+  Toggle compilation of librte_pmd_cxgbe driver.
+
+- ``CONFIG_RTE_LIBRTE_CXGBE_DEBUG`` (default **n**)
+
+  Toggle debugging code. Enabling this option adds additional generic debugging
+  messages at the cost of lower performance.
+
+- ``CONFIG_RTE_LIBRTE_CXGBE_DEBUG_REG`` (default **n**)
+
+  Toggle debugging code. Enabling this option adds additional registers related
+  run-time checks and debugging messages at the cost of lower performance.
+
+- ``CONFIG_RTE_LIBRTE_CXGBE_DEBUG_MBOX`` (default **n**)
+
+  Toggle debugging code. Enabling this option adds additional firmware mailbox
+  related run-time checks and debugging messages at the cost of lower
+  performance.
+
+- ``CONFIG_RTE_LIBRTE_CXGBE_DEBUG_TX`` (default **n**)
+
+  Toggle debugging code. Enabling this option adds additional transmission data
+  path run-time checks and debugging messages at the cost of lower performance.
+
+- ``CONFIG_RTE_LIBRTE_CXGBE_DEBUG_RX`` (default **n**)
+
+  Toggle debugging code. Enabling this option adds additional receiving data
+  path run-time checks and debugging messages at the cost of lower performance.
+
+Prerequisites
+-
+
+- Requires firmware version **1.13.32.0** and higher. Visit
+  `Chelsio Communications <http://www.chelsio.com>`_ to get latest firmware.
+
+Sample Application Notes
+-
+
+This section demonstrates how to launch **testpmd** with Chels

[dpdk-dev] [PATCH v2 10/11] config: enable cxgbe PMD for compilation and linking.

2015-06-02 Thread Rahul Lakkireddy
Changes to:
1. config/common_linuxapp to add macros for cxgbe pmd.
2. drivers/net/Makefile to add cxgbe pmd to the compile list.
3. mk/rte.app.mk to add cxgbe pmd to link.

Signed-off-by: Rahul Lakkireddy 
Signed-off-by: Kumar Sanghvi 
---
v2:
- Move changes from lib/Makefile to drivers/net/Makefile and update commit
  log.
- Order the cxgbe entry alphabetically in mk/rte.app.mk.

 config/common_linuxapp | 10 ++
 drivers/net/Makefile   |  1 +
 mk/rte.app.mk  |  1 +
 3 files changed, 12 insertions(+)

diff --git a/config/common_linuxapp b/config/common_linuxapp
index 0078dc9..dfafd45 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -208,6 +208,16 @@ CONFIG_RTE_LIBRTE_MLX4_TX_MP_CACHE=8
 CONFIG_RTE_LIBRTE_MLX4_SOFT_COUNTERS=1

 #
+# Compile burst-oriented Chelsio Terminator 10GbE/40GbE (CXGBE) PMD
+#
+CONFIG_RTE_LIBRTE_CXGBE_PMD=y
+CONFIG_RTE_LIBRTE_CXGBE_DEBUG=n
+CONFIG_RTE_LIBRTE_CXGBE_DEBUG_REG=n
+CONFIG_RTE_LIBRTE_CXGBE_DEBUG_MBOX=n
+CONFIG_RTE_LIBRTE_CXGBE_DEBUG_TX=n
+CONFIG_RTE_LIBRTE_CXGBE_DEBUG_RX=n
+
+#
 # Compile burst-oriented Cisco ENIC PMD driver
 #
 CONFIG_RTE_LIBRTE_ENIC_PMD=y
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index 1e6648a..644cacb 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -33,6 +33,7 @@ include $(RTE_SDK)/mk/rte.vars.mk

 DIRS-$(CONFIG_RTE_LIBRTE_PMD_AF_PACKET) += af_packet
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += bonding
+DIRS-$(CONFIG_RTE_LIBRTE_CXGBE_PMD) += cxgbe
 DIRS-$(CONFIG_RTE_LIBRTE_E1000_PMD) += e1000
 DIRS-$(CONFIG_RTE_LIBRTE_ENIC_PMD) += enic
 DIRS-$(CONFIG_RTE_LIBRTE_FM10K_PMD) += fm10k
diff --git a/mk/rte.app.mk b/mk/rte.app.mk
index 1a2043a..bba6ddc 100644
--- a/mk/rte.app.mk
+++ b/mk/rte.app.mk
@@ -122,6 +122,7 @@ ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),n)

 _LDLIBS-$(CONFIG_RTE_LIBRTE_VMXNET3_PMD)+= -lrte_pmd_vmxnet3_uio
 _LDLIBS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += -lrte_pmd_virtio
+_LDLIBS-$(CONFIG_RTE_LIBRTE_CXGBE_PMD)  += -lrte_pmd_cxgbe
 _LDLIBS-$(CONFIG_RTE_LIBRTE_ENIC_PMD)   += -lrte_pmd_enic
 _LDLIBS-$(CONFIG_RTE_LIBRTE_I40E_PMD)   += -lrte_pmd_i40e
 _LDLIBS-$(CONFIG_RTE_LIBRTE_FM10K_PMD)  += -lrte_pmd_fm10k
-- 
2.4.1



[dpdk-dev] [PATCH v2 11/11] maintainers: claim responsibility for cxgbe PMD.

2015-06-02 Thread Rahul Lakkireddy
Update MAINTAINERS file to claim responsibility for the cxgbe PMD.

Signed-off-by: Rahul Lakkireddy 
Signed-off-by: Kumar Sanghvi 
---
v2:
- Replace the old cxgbe directory entry with the new entry and order it
  alphabetically.

 MAINTAINERS | 5 +
 1 file changed, 5 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 9362c19..1ec5117 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -210,6 +210,11 @@ Linux AF_PACKET
 M: John W. Linville 
 F: drivers/net/af_packet/

+Chelsio cxgbe
+M: Rahul Lakkireddy 
+F: drivers/net/cxgbe/
+F: doc/guides/nics/cxgbe.rst
+
 Cisco enic
 F: drivers/net/enic/

-- 
2.4.1



[dpdk-dev] [PATCH v2 02/11] cxgbe: add cxgbe poll mode driver.

2015-06-18 Thread Rahul Lakkireddy
Hi Thomas,

On Wed, Jun 17, 2015 at 14:30:55 +0200, Thomas Monjalon wrote:
> It doesn't build as a shared library.
> Please add EXPORT_MAP and LIBABIVER to the Makefile.

Will fix this in v3.

> It would be easier to test if build config was merged in this patch,
> with the Makefile.
> 
> Please merge also the maintainer infos.
> 

Will merge build config and maintainers with the Makefile patch

> 2015-06-01 23:00, Rahul Lakkireddy:
> > +#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))
> 
> RTE_DIM may be used

Will fix this in v3.

Thanks,
Rahul


[dpdk-dev] [PATCH v3 1/9] cxgbe: add hardware specific api for all supported Chelsio T5 series adapters.

2015-06-18 Thread Rahul Lakkireddy
Adds hardware specific api for all the Chelsio T5 adapters under
drivers/net/cxgbe/base directory.

Signed-off-by: Rahul Lakkireddy 
Signed-off-by: Kumar Sanghvi 
---
v3:
- No changes

v2:
- Move files to new directory under drivers/net/cxgbe/base and update commit
  log.
- Few bug fixes related to tx.

 drivers/net/cxgbe/base/adapter.h|  565 +++
 drivers/net/cxgbe/base/common.h |  401 +
 drivers/net/cxgbe/base/t4_chip_type.h   |   79 +
 drivers/net/cxgbe/base/t4_hw.c  | 2686 +++
 drivers/net/cxgbe/base/t4_hw.h  |  149 ++
 drivers/net/cxgbe/base/t4_msg.h |  345 
 drivers/net/cxgbe/base/t4_pci_id_tbl.h  |  148 ++
 drivers/net/cxgbe/base/t4_regs.h|  779 +
 drivers/net/cxgbe/base/t4_regs_values.h |  168 ++
 drivers/net/cxgbe/base/t4fw_interface.h | 1730 
 10 files changed, 7050 insertions(+)
 create mode 100644 drivers/net/cxgbe/base/adapter.h
 create mode 100644 drivers/net/cxgbe/base/common.h
 create mode 100644 drivers/net/cxgbe/base/t4_chip_type.h
 create mode 100644 drivers/net/cxgbe/base/t4_hw.c
 create mode 100644 drivers/net/cxgbe/base/t4_hw.h
 create mode 100644 drivers/net/cxgbe/base/t4_msg.h
 create mode 100644 drivers/net/cxgbe/base/t4_pci_id_tbl.h
 create mode 100644 drivers/net/cxgbe/base/t4_regs.h
 create mode 100644 drivers/net/cxgbe/base/t4_regs_values.h
 create mode 100644 drivers/net/cxgbe/base/t4fw_interface.h

diff --git a/drivers/net/cxgbe/base/adapter.h b/drivers/net/cxgbe/base/adapter.h
new file mode 100644
index 000..0ea1c95
--- /dev/null
+++ b/drivers/net/cxgbe/base/adapter.h
@@ -0,0 +1,565 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2014-2015 Chelsio Communications.
+ *   All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the name of Chelsio Communications nor the names of its
+ *   contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ *   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.
+ */
+
+/* This file should not be included directly.  Include common.h instead. */
+
+#ifndef __T4_ADAPTER_H__
+#define __T4_ADAPTER_H__
+
+#include 
+
+#include "cxgbe_compat.h"
+#include "t4_regs_values.h"
+
+enum {
+   MAX_ETH_QSETS = 64,   /* # of Ethernet Tx/Rx queue sets */
+};
+
+struct adapter;
+struct sge_rspq;
+
+enum {
+   PORT_RSS_DONE = (1 << 0),
+};
+
+struct port_info {
+   struct adapter *adapter;/* adapter that this port belongs to */
+   struct rte_eth_dev *eth_dev;/* associated rte eth device */
+   struct port_stats stats_base;   /* port statistics base */
+   struct link_config link_cfg;/* link configuration info */
+
+   unsigned long flags;/* port related flags */
+   short int xact_addr_filt;   /* index of exact MAC address filter */
+
+   u16viid;/* associated virtual interface id */
+   s8 mdio_addr;   /* address of the PHY */
+   u8 port_type;   /* firmware port type */
+   u8 mod_type;/* firmware module type */
+   u8 port_id; /* physical port ID */
+   u8 tx_chan; /* associated channel */
+
+   u8 n_rx_qsets;  /* # of rx qsets */
+   u8 n_tx_qsets;  /* # of tx qsets */
+   u8 first_qset;  /* index of first qset */
+
+   u16*rss;/* rss table */
+   u8 rss_mode;/* rss mode */
+   u16rss_size;   

[dpdk-dev] [PATCH v3 2/9] cxgbe: add cxgbe poll mode driver.

2015-06-18 Thread Rahul Lakkireddy
Adds cxgbe poll mode driver for DPDK under drivers/net/cxgbe directory. This
patch:

1. Adds the Makefile to compile cxgbe pmd.
2. Registers and initializes the cxgbe pmd driver.

Enable cxgbe PMD for compilation and linking with changes to:
1. config/common_linuxapp to add macros for cxgbe pmd.
2. drivers/net/Makefile to add cxgbe pmd to the compile list.
3. mk/rte.app.mk to add cxgbe pmd to link.

Update MAINTAINERS file to claim responsibility for the cxgbe PMD.

Signed-off-by: Rahul Lakkireddy 
Signed-off-by: Kumar Sanghvi 
---
v3:
- Merge patches 10 and 11 with this patch to enable compilation and update
  MAINTAINERS.  Also, update commit log.
- Add rte_pmd_cxgbe_version.map and add EXPORT_MAP and LIBABIVER to cxgbe
  Makefile.
- Use RTE_DIM macro for calculating ARRAY_SIZE.

v2:
- Move files to new directory under drivers/net/cxgbe and update commit log.
- Move eth_dev_ops to separate patches.
- Update cxgbe Makefile to use relative rather than absolute path of pmd.
- Replace bitwise operations in fls() with gcc's __builtin_clz().
- Fix an issue in adap_init0_tweaks() related to rx_dma_offset.

 MAINTAINERS |   5 +
 config/common_linuxapp  |  10 +
 drivers/net/Makefile|   1 +
 drivers/net/cxgbe/Makefile  |  78 +++
 drivers/net/cxgbe/cxgbe.h   |  48 ++
 drivers/net/cxgbe/cxgbe_compat.h| 266 +++
 drivers/net/cxgbe/cxgbe_ethdev.c| 169 +++
 drivers/net/cxgbe/cxgbe_main.c  | 706 
 drivers/net/cxgbe/rte_pmd_cxgbe_version.map |   4 +
 drivers/net/cxgbe/sge.c | 311 
 mk/rte.app.mk   |   1 +
 11 files changed, 1599 insertions(+)
 create mode 100644 drivers/net/cxgbe/Makefile
 create mode 100644 drivers/net/cxgbe/cxgbe.h
 create mode 100644 drivers/net/cxgbe/cxgbe_compat.h
 create mode 100644 drivers/net/cxgbe/cxgbe_ethdev.c
 create mode 100644 drivers/net/cxgbe/cxgbe_main.c
 create mode 100644 drivers/net/cxgbe/rte_pmd_cxgbe_version.map
 create mode 100644 drivers/net/cxgbe/sge.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 9362c19..1ec5117 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -210,6 +210,11 @@ Linux AF_PACKET
 M: John W. Linville 
 F: drivers/net/af_packet/

+Chelsio cxgbe
+M: Rahul Lakkireddy 
+F: drivers/net/cxgbe/
+F: doc/guides/nics/cxgbe.rst
+
 Cisco enic
 F: drivers/net/enic/

diff --git a/config/common_linuxapp b/config/common_linuxapp
index 5deb55a..22a6d4e 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -208,6 +208,16 @@ CONFIG_RTE_LIBRTE_MLX4_TX_MP_CACHE=8
 CONFIG_RTE_LIBRTE_MLX4_SOFT_COUNTERS=1

 #
+# Compile burst-oriented Chelsio Terminator 10GbE/40GbE (CXGBE) PMD
+#
+CONFIG_RTE_LIBRTE_CXGBE_PMD=y
+CONFIG_RTE_LIBRTE_CXGBE_DEBUG=n
+CONFIG_RTE_LIBRTE_CXGBE_DEBUG_REG=n
+CONFIG_RTE_LIBRTE_CXGBE_DEBUG_MBOX=n
+CONFIG_RTE_LIBRTE_CXGBE_DEBUG_TX=n
+CONFIG_RTE_LIBRTE_CXGBE_DEBUG_RX=n
+
+#
 # Compile burst-oriented Cisco ENIC PMD driver
 #
 CONFIG_RTE_LIBRTE_ENIC_PMD=y
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index 1e6648a..644cacb 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -33,6 +33,7 @@ include $(RTE_SDK)/mk/rte.vars.mk

 DIRS-$(CONFIG_RTE_LIBRTE_PMD_AF_PACKET) += af_packet
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += bonding
+DIRS-$(CONFIG_RTE_LIBRTE_CXGBE_PMD) += cxgbe
 DIRS-$(CONFIG_RTE_LIBRTE_E1000_PMD) += e1000
 DIRS-$(CONFIG_RTE_LIBRTE_ENIC_PMD) += enic
 DIRS-$(CONFIG_RTE_LIBRTE_FM10K_PMD) += fm10k
diff --git a/drivers/net/cxgbe/Makefile b/drivers/net/cxgbe/Makefile
new file mode 100644
index 000..4dfc6b0
--- /dev/null
+++ b/drivers/net/cxgbe/Makefile
@@ -0,0 +1,78 @@
+#   BSD LICENSE
+#
+#   Copyright(c) 2014-2015 Chelsio Communications.
+#   All rights reserved.
+#
+#   Redistribution and use in source and binary forms, with or without
+#   modification, are permitted provided that the following conditions
+#   are met:
+#
+# * Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# * 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.
+# * Neither the name of Chelsio Communications nor the names of its
+#   contributors may be used to endorse or promote products derived
+#   from this software without specific prior written permission.
+#
+#   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,
+#

[dpdk-dev] [PATCH v3 3/9] cxgbe: add device configuration and RX support for cxgbe PMD.

2015-06-18 Thread Rahul Lakkireddy
Adds RX support for the cxgbe poll mode driver.  This patch:

1. Adds rx queue related eth_dev_ops.
2. Adds RSS support.
3. Adds dev_configure() and dev_infos_get() eth_dev_ops.
4. Adds rx_pkt_burst for receiving packets.

Signed-off-by: Rahul Lakkireddy 
Signed-off-by: Kumar Sanghvi 
---
v3:
- No changes.

v2:
- This patch is a subset of patch 2/5 submitted in v1.
- Cleanup some RX related macros and code.

 drivers/net/cxgbe/cxgbe.h|   6 +
 drivers/net/cxgbe/cxgbe_ethdev.c | 183 
 drivers/net/cxgbe/cxgbe_main.c   | 350 +++
 drivers/net/cxgbe/sge.c  | 915 +++
 4 files changed, 1454 insertions(+)

diff --git a/drivers/net/cxgbe/cxgbe.h b/drivers/net/cxgbe/cxgbe.h
index 44d48dc..90d1db0 100644
--- a/drivers/net/cxgbe/cxgbe.h
+++ b/drivers/net/cxgbe/cxgbe.h
@@ -44,5 +44,11 @@
 #define CXGBE_DEFAULT_RX_DESC_SIZE1024 /* Default RX ring size */

 int cxgbe_probe(struct adapter *adapter);
+void init_rspq(struct adapter *adap, struct sge_rspq *q, unsigned int us,
+  unsigned int cnt, unsigned int size, unsigned int iqe_size);
+int setup_sge_fwevtq(struct adapter *adapter);
+void cfg_queues(struct rte_eth_dev *eth_dev);
+int cfg_queue_count(struct rte_eth_dev *eth_dev);
+int setup_rss(struct port_info *pi);

 #endif /* _CXGBE_H_ */
diff --git a/drivers/net/cxgbe/cxgbe_ethdev.c b/drivers/net/cxgbe/cxgbe_ethdev.c
index 30d39b4..1c69973 100644
--- a/drivers/net/cxgbe/cxgbe_ethdev.c
+++ b/drivers/net/cxgbe/cxgbe_ethdev.c
@@ -85,7 +85,189 @@
  */
 #include "t4_pci_id_tbl.h"

+static uint16_t cxgbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
+   uint16_t nb_pkts)
+{
+   struct sge_eth_rxq *rxq = (struct sge_eth_rxq *)rx_queue;
+   unsigned int work_done;
+
+   CXGBE_DEBUG_RX(adapter, "%s: rxq->rspq.cntxt_id = %u; nb_pkts = %d\n",
+  __func__, rxq->rspq.cntxt_id, nb_pkts);
+
+   if (cxgbe_poll(>rspq, rx_pkts, (unsigned int)nb_pkts, _done))
+   dev_err(adapter, "error in cxgbe poll\n");
+
+   CXGBE_DEBUG_RX(adapter, "%s: work_done = %u\n", __func__, work_done);
+   return work_done;
+}
+
+static void cxgbe_dev_info_get(struct rte_eth_dev *eth_dev,
+  struct rte_eth_dev_info *device_info)
+{
+   struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private);
+   struct adapter *adapter = pi->adapter;
+   int max_queues = adapter->sge.max_ethqsets / adapter->params.nports;
+
+   device_info->min_rx_bufsize = 68; /* XXX: Smallest pkt size */
+   device_info->max_rx_pktlen = 1500; /* XXX: For now we support mtu */
+   device_info->max_rx_queues = max_queues;
+   device_info->max_tx_queues = max_queues;
+   device_info->max_mac_addrs = 1;
+   /* XXX: For now we support one MAC/port */
+   device_info->max_vfs = adapter->params.arch.vfcount;
+   device_info->max_vmdq_pools = 0; /* XXX: For now no support for VMDQ */
+
+   device_info->rx_offload_capa = DEV_RX_OFFLOAD_VLAN_STRIP |
+  DEV_RX_OFFLOAD_IPV4_CKSUM |
+  DEV_RX_OFFLOAD_UDP_CKSUM |
+  DEV_RX_OFFLOAD_TCP_CKSUM;
+
+   device_info->tx_offload_capa = 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;
+
+   device_info->reta_size = pi->rss_size;
+}
+
+static int cxgbe_dev_rx_queue_start(struct rte_eth_dev *eth_dev,
+   uint16_t tx_queue_id);
+static void cxgbe_dev_rx_queue_release(void *q);
+
+static int cxgbe_dev_configure(struct rte_eth_dev *eth_dev)
+{
+   struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private);
+   struct adapter *adapter = pi->adapter;
+   int err;
+
+   CXGBE_FUNC_TRACE();
+
+   if (!(adapter->flags & FW_QUEUE_BOUND)) {
+   err = setup_sge_fwevtq(adapter);
+   if (err)
+   return err;
+   adapter->flags |= FW_QUEUE_BOUND;
+   }
+
+   err = cfg_queue_count(eth_dev);
+   if (err)
+   return err;
+
+   return 0;
+}
+
+static int cxgbe_dev_rx_queue_start(struct rte_eth_dev *eth_dev,
+   uint16_t rx_queue_id)
+{
+   struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private);
+   struct adapter *adap = pi->adapter;
+   struct sge_rspq *q;
+
+   dev_debug(adapter, "%s: pi->port_id = %d; rx_queue_id = %d\n",
+ __func__, pi->port_id, rx_queue_id);
+
+   q = eth_dev-&

[dpdk-dev] [PATCH v3 5/9] cxgbe: add device related operations for cxgbe PMD.

2015-06-18 Thread Rahul Lakkireddy
Adds dev_start(), dev_stop(), and dev_close() eth_dev_ops for cxgbe poll
mode driver.

Signed-off-by: Rahul Lakkireddy 
Signed-off-by: Kumar Sanghvi 
---
v3:
- No changes.

v2:
- This patch is a subset of patch 2/5 submitted in v1.
- Few changes related to tx bug fixes.

 drivers/net/cxgbe/cxgbe.h|   4 ++
 drivers/net/cxgbe/cxgbe_ethdev.c | 114 
 drivers/net/cxgbe/cxgbe_main.c   | 139 +++
 drivers/net/cxgbe/sge.c  |  58 
 4 files changed, 315 insertions(+)

diff --git a/drivers/net/cxgbe/cxgbe.h b/drivers/net/cxgbe/cxgbe.h
index 90d1db0..bf08baf 100644
--- a/drivers/net/cxgbe/cxgbe.h
+++ b/drivers/net/cxgbe/cxgbe.h
@@ -44,6 +44,10 @@
 #define CXGBE_DEFAULT_RX_DESC_SIZE1024 /* Default RX ring size */

 int cxgbe_probe(struct adapter *adapter);
+int cxgbe_up(struct adapter *adap);
+int cxgbe_down(struct port_info *pi);
+void cxgbe_close(struct adapter *adapter);
+int link_start(struct port_info *pi);
 void init_rspq(struct adapter *adap, struct sge_rspq *q, unsigned int us,
   unsigned int cnt, unsigned int size, unsigned int iqe_size);
 int setup_sge_fwevtq(struct adapter *adapter);
diff --git a/drivers/net/cxgbe/cxgbe_ethdev.c b/drivers/net/cxgbe/cxgbe_ethdev.c
index b6e17e4..cb100fc 100644
--- a/drivers/net/cxgbe/cxgbe_ethdev.c
+++ b/drivers/net/cxgbe/cxgbe_ethdev.c
@@ -171,6 +171,117 @@ static int cxgbe_dev_rx_queue_start(struct rte_eth_dev 
*eth_dev,
 static void cxgbe_dev_tx_queue_release(void *q);
 static void cxgbe_dev_rx_queue_release(void *q);

+/*
+ * Stop device.
+ */
+static void cxgbe_dev_close(struct rte_eth_dev *eth_dev)
+{
+   struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private);
+   struct adapter *adapter = pi->adapter;
+   int i, dev_down = 0;
+
+   CXGBE_FUNC_TRACE();
+
+   if (!(adapter->flags & FULL_INIT_DONE))
+   return;
+
+   cxgbe_down(pi);
+
+   /*
+*  We clear queues only if both tx and rx path of the port
+*  have been disabled
+*/
+   t4_sge_eth_clear_queues(pi);
+
+   /*  See if all ports are down */
+   for_each_port(adapter, i) {
+   pi = adap2pinfo(adapter, i);
+   /*
+* Skip first port of the adapter since it will be closed
+* by DPDK
+*/
+   if (i == 0)
+   continue;
+   dev_down += (pi->eth_dev->data->dev_started == 0) ? 1 : 0;
+   }
+
+   /* If rest of the ports are stopped, then free up resources */
+   if (dev_down == (adapter->params.nports - 1))
+   cxgbe_close(adapter);
+}
+
+/* Start the device.
+ * It returns 0 on success.
+ */
+static int cxgbe_dev_start(struct rte_eth_dev *eth_dev)
+{
+   struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private);
+   struct adapter *adapter = pi->adapter;
+   int err = 0, i;
+
+   CXGBE_FUNC_TRACE();
+
+   /*
+* If we don't have a connection to the firmware there's nothing we
+* can do.
+*/
+   if (!(adapter->flags & FW_OK)) {
+   err = -ENXIO;
+   goto out;
+   }
+
+   if (!(adapter->flags & FULL_INIT_DONE)) {
+   err = cxgbe_up(adapter);
+   if (err < 0)
+   goto out;
+   }
+
+   err = setup_rss(pi);
+   if (err)
+   goto out;
+
+   for (i = 0; i < pi->n_tx_qsets; i++) {
+   err = cxgbe_dev_tx_queue_start(eth_dev, i);
+   if (err)
+   goto out;
+   }
+
+   for (i = 0; i < pi->n_rx_qsets; i++) {
+   err = cxgbe_dev_rx_queue_start(eth_dev, i);
+   if (err)
+   goto out;
+   }
+
+   err = link_start(pi);
+   if (err)
+   goto out;
+
+out:
+   return err;
+}
+
+/*
+ * Stop device: disable rx and tx functions to allow for reconfiguring.
+ */
+static void cxgbe_dev_stop(struct rte_eth_dev *eth_dev)
+{
+   struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private);
+   struct adapter *adapter = pi->adapter;
+
+   CXGBE_FUNC_TRACE();
+
+   if (!(adapter->flags & FULL_INIT_DONE))
+   return;
+
+   cxgbe_down(pi);
+
+   /*
+*  We clear queues only if both tx and rx path of the port
+*  have been disabled
+*/
+   t4_sge_eth_clear_queues(pi);
+}
+
 static int cxgbe_dev_configure(struct rte_eth_dev *eth_dev)
 {
struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private);
@@ -390,6 +501,9 @@ static void cxgbe_dev_rx_queue_release(void *q)
 }

 static struct eth_dev_ops cxgbe_eth_dev_ops = {
+   .dev_start  = cxgbe_dev_start,
+   .dev_stop   = cxgbe_dev_stop,
+   .dev_clo

[dpdk-dev] [PATCH v3 7/9] cxgbe: add link related functions for cxgbe PMD.

2015-06-18 Thread Rahul Lakkireddy
Adds link update, promiscuous and multicast related eth_dev_ops for cxgbe poll
mode driver.

Signed-off-by: Rahul Lakkireddy 
Signed-off-by: Kumar Sanghvi 
---
v3:
- No changes.

v2:
- This patch is a subset of patch 2/5 submitted in v1.
- Update cxgbe_dev_link_update() to return correct value.

 drivers/net/cxgbe/cxgbe_ethdev.c | 66 
 1 file changed, 66 insertions(+)

diff --git a/drivers/net/cxgbe/cxgbe_ethdev.c b/drivers/net/cxgbe/cxgbe_ethdev.c
index 600a16c..c0dd5f3 100644
--- a/drivers/net/cxgbe/cxgbe_ethdev.c
+++ b/drivers/net/cxgbe/cxgbe_ethdev.c
@@ -164,6 +164,67 @@ static void cxgbe_dev_info_get(struct rte_eth_dev *eth_dev,
device_info->reta_size = pi->rss_size;
 }

+static void cxgbe_dev_promiscuous_enable(struct rte_eth_dev *eth_dev)
+{
+   struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private);
+   struct adapter *adapter = pi->adapter;
+
+   t4_set_rxmode(adapter, adapter->mbox, pi->viid, -1,
+ 1, -1, 1, -1, false);
+}
+
+static void cxgbe_dev_promiscuous_disable(struct rte_eth_dev *eth_dev)
+{
+   struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private);
+   struct adapter *adapter = pi->adapter;
+
+   t4_set_rxmode(adapter, adapter->mbox, pi->viid, -1,
+ 0, -1, 1, -1, false);
+}
+
+static void cxgbe_dev_allmulticast_enable(struct rte_eth_dev *eth_dev)
+{
+   struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private);
+   struct adapter *adapter = pi->adapter;
+
+   /* TODO: address filters ?? */
+
+   t4_set_rxmode(adapter, adapter->mbox, pi->viid, -1,
+ -1, 1, 1, -1, false);
+}
+
+static void cxgbe_dev_allmulticast_disable(struct rte_eth_dev *eth_dev)
+{
+   struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private);
+   struct adapter *adapter = pi->adapter;
+
+   /* TODO: address filters ?? */
+
+   t4_set_rxmode(adapter, adapter->mbox, pi->viid, -1,
+ -1, 0, 1, -1, false);
+}
+
+static int cxgbe_dev_link_update(struct rte_eth_dev *eth_dev,
+__rte_unused int wait_to_complete)
+{
+   struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private);
+   struct adapter *adapter = pi->adapter;
+   struct sge *s = >sge;
+   struct rte_eth_link *old_link = _dev->data->dev_link;
+   unsigned int work_done, budget = 4;
+
+   cxgbe_poll(>fw_evtq, NULL, budget, _done);
+   if (old_link->link_status == pi->link_cfg.link_ok)
+   return -1;  /* link not changed */
+
+   eth_dev->data->dev_link.link_status = pi->link_cfg.link_ok;
+   eth_dev->data->dev_link.link_duplex = ETH_LINK_FULL_DUPLEX;
+   eth_dev->data->dev_link.link_speed = pi->link_cfg.speed;
+
+   /* link has changed */
+   return 0;
+}
+
 static int cxgbe_dev_tx_queue_start(struct rte_eth_dev *eth_dev,
uint16_t tx_queue_id);
 static int cxgbe_dev_rx_queue_start(struct rte_eth_dev *eth_dev,
@@ -585,8 +646,13 @@ static struct eth_dev_ops cxgbe_eth_dev_ops = {
.dev_start  = cxgbe_dev_start,
.dev_stop   = cxgbe_dev_stop,
.dev_close  = cxgbe_dev_close,
+   .promiscuous_enable = cxgbe_dev_promiscuous_enable,
+   .promiscuous_disable= cxgbe_dev_promiscuous_disable,
+   .allmulticast_enable= cxgbe_dev_allmulticast_enable,
+   .allmulticast_disable   = cxgbe_dev_allmulticast_disable,
.dev_configure  = cxgbe_dev_configure,
.dev_infos_get  = cxgbe_dev_info_get,
+   .link_update= cxgbe_dev_link_update,
.tx_queue_setup = cxgbe_dev_tx_queue_setup,
.tx_queue_start = cxgbe_dev_tx_queue_start,
.tx_queue_stop  = cxgbe_dev_tx_queue_stop,
-- 
2.4.1



[dpdk-dev] [PATCH v3 6/9] cxgbe: add port statistics for cxgbe PMD.

2015-06-18 Thread Rahul Lakkireddy
Adds stats_get() and stats_reset() eth_dev_ops for cxgbe poll mode driver.

Signed-off-by: Rahul Lakkireddy 
Signed-off-by: Kumar Sanghvi 
---
v3:
- No changes.

v2:
- This patch is a subset of patch 2/5 submitted in v1.

 drivers/net/cxgbe/cxgbe.h|  2 +
 drivers/net/cxgbe/cxgbe_ethdev.c | 83 
 drivers/net/cxgbe/cxgbe_main.c   | 11 ++
 3 files changed, 96 insertions(+)

diff --git a/drivers/net/cxgbe/cxgbe.h b/drivers/net/cxgbe/cxgbe.h
index bf08baf..97c37d2 100644
--- a/drivers/net/cxgbe/cxgbe.h
+++ b/drivers/net/cxgbe/cxgbe.h
@@ -47,6 +47,8 @@ int cxgbe_probe(struct adapter *adapter);
 int cxgbe_up(struct adapter *adap);
 int cxgbe_down(struct port_info *pi);
 void cxgbe_close(struct adapter *adapter);
+void cxgbe_stats_get(struct port_info *pi, struct port_stats *stats);
+void cxgbe_stats_reset(struct port_info *pi);
 int link_start(struct port_info *pi);
 void init_rspq(struct adapter *adap, struct sge_rspq *q, unsigned int us,
   unsigned int cnt, unsigned int size, unsigned int iqe_size);
diff --git a/drivers/net/cxgbe/cxgbe_ethdev.c b/drivers/net/cxgbe/cxgbe_ethdev.c
index cb100fc..600a16c 100644
--- a/drivers/net/cxgbe/cxgbe_ethdev.c
+++ b/drivers/net/cxgbe/cxgbe_ethdev.c
@@ -500,6 +500,87 @@ static void cxgbe_dev_rx_queue_release(void *q)
}
 }

+/*
+ * Get port statistics.
+ */
+static void cxgbe_dev_stats_get(struct rte_eth_dev *eth_dev,
+   struct rte_eth_stats *eth_stats)
+{
+   struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private);
+   struct adapter *adapter = pi->adapter;
+   struct sge *s = >sge;
+   struct port_stats ps;
+   unsigned int i;
+
+   cxgbe_stats_get(pi, );
+
+   /* RX Stats */
+   eth_stats->ipackets = ps.rx_frames;
+   eth_stats->ibytes   = ps.rx_octets;
+   eth_stats->imcasts  = ps.rx_mcast_frames;
+   eth_stats->imissed  = ps.rx_ovflow0 + ps.rx_ovflow1 +
+ ps.rx_ovflow2 + ps.rx_ovflow3 +
+ ps.rx_trunc0 + ps.rx_trunc1 +
+ ps.rx_trunc2 + ps.rx_trunc3;
+   eth_stats->ibadcrc  = ps.rx_fcs_err;
+   eth_stats->ibadlen  = ps.rx_jabber + ps.rx_too_long + ps.rx_runt;
+   eth_stats->ierrors  = ps.rx_symbol_err + eth_stats->ibadcrc +
+ eth_stats->ibadlen + ps.rx_len_err +
+ eth_stats->imissed;
+   eth_stats->rx_pause_xon  = ps.rx_pause;
+
+   /* TX Stats */
+   eth_stats->opackets = ps.tx_frames;
+   eth_stats->obytes   = ps.tx_octets;
+   eth_stats->oerrors  = ps.tx_error_frames;
+   eth_stats->tx_pause_xon  = ps.tx_pause;
+
+   for (i = 0; i < pi->n_rx_qsets; i++) {
+   struct sge_eth_rxq *rxq =
+   >ethrxq[pi->first_qset + i];
+
+   eth_stats->q_ipackets[i] = rxq->stats.pkts;
+   eth_stats->q_ibytes[i] = rxq->stats.rx_bytes;
+   }
+
+   for (i = 0; i < pi->n_tx_qsets; i++) {
+   struct sge_eth_txq *txq =
+   >ethtxq[pi->first_qset + i];
+
+   eth_stats->q_opackets[i] = txq->stats.pkts;
+   eth_stats->q_obytes[i] = txq->stats.tx_bytes;
+   eth_stats->q_errors[i] = txq->stats.mapping_err;
+   }
+}
+
+/*
+ * Reset port statistics.
+ */
+static void cxgbe_dev_stats_reset(struct rte_eth_dev *eth_dev)
+{
+   struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private);
+   struct adapter *adapter = pi->adapter;
+   struct sge *s = >sge;
+   unsigned int i;
+
+   cxgbe_stats_reset(pi);
+   for (i = 0; i < pi->n_rx_qsets; i++) {
+   struct sge_eth_rxq *rxq =
+   >ethrxq[pi->first_qset + i];
+
+   rxq->stats.pkts = 0;
+   rxq->stats.rx_bytes = 0;
+   }
+   for (i = 0; i < pi->n_tx_qsets; i++) {
+   struct sge_eth_txq *txq =
+   >ethtxq[pi->first_qset + i];
+
+   txq->stats.pkts = 0;
+   txq->stats.tx_bytes = 0;
+   txq->stats.mapping_err = 0;
+   }
+}
+
 static struct eth_dev_ops cxgbe_eth_dev_ops = {
.dev_start  = cxgbe_dev_start,
.dev_stop   = cxgbe_dev_stop,
@@ -514,6 +595,8 @@ static struct eth_dev_ops cxgbe_eth_dev_ops = {
.rx_queue_start = cxgbe_dev_rx_queue_start,
.rx_queue_stop  = cxgbe_dev_rx_queue_stop,
.rx_queue_release   = cxgbe_dev_rx_queue_release,
+   .stats_get  = cxgbe_dev_stats_get,
+   .stats_reset= cxgbe_dev_stats_reset,
 };

 /*
diff --git a/drivers/net/cxgbe/cxgbe_main.c b/drivers/net/cxgbe/cxgbe_main.c
index 7995d3c..dad0a98 100644
--- a/drivers/net/cx

[dpdk-dev] [PATCH v3 9/9] doc: add cxgbe PMD documentation under doc/guides/nics/cxgbe.rst

2015-06-18 Thread Rahul Lakkireddy
Adds cxgbe poll mode driver documentation under the usual doc/guides/nics/
directory with the rest of the drivers.  The documentation covers cxgbe
implementation details, features and limitations, prerequisites, configuration,
and a sample application usage.

Signed-off-by: Rahul Lakkireddy 
Signed-off-by: Kumar Sanghvi 
---
v3:
- No changes.

v2:
- Move cxgbe entry to Drivers section in source_org.rst.
- Order the cxgbe entry alphabetically in index.rst.

 doc/guides/nics/cxgbe.rst| 209 +++
 doc/guides/nics/index.rst|   1 +
 doc/guides/prog_guide/source_org.rst |   1 +
 3 files changed, 211 insertions(+)
 create mode 100644 doc/guides/nics/cxgbe.rst

diff --git a/doc/guides/nics/cxgbe.rst b/doc/guides/nics/cxgbe.rst
new file mode 100644
index 000..54a019d
--- /dev/null
+++ b/doc/guides/nics/cxgbe.rst
@@ -0,0 +1,209 @@
+..  BSD LICENSE
+Copyright 2015 Chelsio Communications.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+* Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+* 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.
+* Neither the name of Chelsio Communications nor the names of its
+contributors may be used to endorse or promote products derived
+from this software without specific prior written permission.
+
+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.
+
+CXGBE Poll Mode Driver
+==
+
+The CXGBE PMD (**librte_pmd_cxgbe**) provides poll mode driver support
+for **Chelsio T5** 10/40 Gbps family of adapters.
+
+More information can be found at `Chelsio Communications
+<http://www.chelsio.com>`_.
+
+Features
+
+
+CXGBE PMD has the support for:
+
+- Multiple queues for TX and RX.
+- Receiver Side Steering (RSS).
+- VLAN filtering.
+- Checksum offload.
+- Promiscuous mode.
+- All multicast mode.
+- Port hardware statistics.
+
+Limitations
+---
+
+The Chelsio T5 devices provide two/four ports but expose a single PCI bus
+address, thus, librte_pmd_cxgbe registers itself as a
+PCI driver that allocates one Ethernet device per detected port.
+
+For this reason, one cannot white/blacklist a single port without also
+white/blacklisting the others on the same device.
+
+Configuration
+-
+
+Compiling CXGBE PMD
+~~~
+
+These options can be modified in the ``.config`` file.
+
+- ``CONFIG_RTE_LIBRTE_CXGBE_PMD`` (default **y**)
+
+  Toggle compilation of librte_pmd_cxgbe driver.
+
+- ``CONFIG_RTE_LIBRTE_CXGBE_DEBUG`` (default **n**)
+
+  Toggle debugging code. Enabling this option adds additional generic debugging
+  messages at the cost of lower performance.
+
+- ``CONFIG_RTE_LIBRTE_CXGBE_DEBUG_REG`` (default **n**)
+
+  Toggle debugging code. Enabling this option adds additional registers related
+  run-time checks and debugging messages at the cost of lower performance.
+
+- ``CONFIG_RTE_LIBRTE_CXGBE_DEBUG_MBOX`` (default **n**)
+
+  Toggle debugging code. Enabling this option adds additional firmware mailbox
+  related run-time checks and debugging messages at the cost of lower
+  performance.
+
+- ``CONFIG_RTE_LIBRTE_CXGBE_DEBUG_TX`` (default **n**)
+
+  Toggle debugging code. Enabling this option adds additional transmission data
+  path run-time checks and debugging messages at the cost of lower performance.
+
+- ``CONFIG_RTE_LIBRTE_CXGBE_DEBUG_RX`` (default **n**)
+
+  Toggle debugging code. Enabling this option adds additional receiving data
+  path run-time checks and debugging messages at the cost of lower performance.
+
+Prerequisites
+-
+
+- Requires firmware version **1.13.32.0** and higher. Visit
+  `Chelsio Communications <http://www.chelsio.com>`_ to get latest firmware.
+
+Sample Application Notes
+-
+
+This section demonstrates how to launch **testpmd** wi

[dpdk-dev] [PATCH v3 8/9] cxgbe: add flow control functions for cxgbe PMD.

2015-06-18 Thread Rahul Lakkireddy
Adds flow control related eth_dev_ops for cxgbe poll mode driver.

Signed-off-by: Rahul Lakkireddy 
Signed-off-by: Kumar Sanghvi 
---
v3:
- No changes.

v2:
- This patch is a subset of patch 2/5 submitted in v1.

 drivers/net/cxgbe/cxgbe_ethdev.c | 54 
 1 file changed, 54 insertions(+)

diff --git a/drivers/net/cxgbe/cxgbe_ethdev.c b/drivers/net/cxgbe/cxgbe_ethdev.c
index c0dd5f3..478051a 100644
--- a/drivers/net/cxgbe/cxgbe_ethdev.c
+++ b/drivers/net/cxgbe/cxgbe_ethdev.c
@@ -642,6 +642,58 @@ static void cxgbe_dev_stats_reset(struct rte_eth_dev 
*eth_dev)
}
 }

+static int cxgbe_flow_ctrl_get(struct rte_eth_dev *eth_dev,
+  struct rte_eth_fc_conf *fc_conf)
+{
+   struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private);
+   struct link_config *lc = >link_cfg;
+   int rx_pause, tx_pause;
+
+   fc_conf->autoneg = lc->fc & PAUSE_AUTONEG;
+   rx_pause = lc->fc & PAUSE_RX;
+   tx_pause = lc->fc & PAUSE_TX;
+
+   if (rx_pause && tx_pause)
+   fc_conf->mode = RTE_FC_FULL;
+   else if (rx_pause)
+   fc_conf->mode = RTE_FC_RX_PAUSE;
+   else if (tx_pause)
+   fc_conf->mode = RTE_FC_TX_PAUSE;
+   else
+   fc_conf->mode = RTE_FC_NONE;
+   return 0;
+}
+
+static int cxgbe_flow_ctrl_set(struct rte_eth_dev *eth_dev,
+  struct rte_eth_fc_conf *fc_conf)
+{
+   struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private);
+   struct adapter *adapter = pi->adapter;
+   struct link_config *lc = >link_cfg;
+
+   if (lc->supported & FW_PORT_CAP_ANEG) {
+   if (fc_conf->autoneg)
+   lc->requested_fc |= PAUSE_AUTONEG;
+   else
+   lc->requested_fc &= ~PAUSE_AUTONEG;
+   }
+
+   if (((fc_conf->mode & RTE_FC_FULL) == RTE_FC_FULL) ||
+   (fc_conf->mode & RTE_FC_RX_PAUSE))
+   lc->requested_fc |= PAUSE_RX;
+   else
+   lc->requested_fc &= ~PAUSE_RX;
+
+   if (((fc_conf->mode & RTE_FC_FULL) == RTE_FC_FULL) ||
+   (fc_conf->mode & RTE_FC_TX_PAUSE))
+   lc->requested_fc |= PAUSE_TX;
+   else
+   lc->requested_fc &= ~PAUSE_TX;
+
+   return t4_link_l1cfg(adapter, adapter->mbox, pi->tx_chan,
+>link_cfg);
+}
+
 static struct eth_dev_ops cxgbe_eth_dev_ops = {
.dev_start  = cxgbe_dev_start,
.dev_stop   = cxgbe_dev_stop,
@@ -663,6 +715,8 @@ static struct eth_dev_ops cxgbe_eth_dev_ops = {
.rx_queue_release   = cxgbe_dev_rx_queue_release,
.stats_get  = cxgbe_dev_stats_get,
.stats_reset= cxgbe_dev_stats_reset,
+   .flow_ctrl_get  = cxgbe_flow_ctrl_get,
+   .flow_ctrl_set  = cxgbe_flow_ctrl_set,
 };

 /*
-- 
2.4.1



[dpdk-dev] [PATCH] vfio: Fix overflow while assigning vfio BAR region offset and size

2015-06-18 Thread Rahul Lakkireddy
Hi Thomas,

On Wed, Jun 17, 2015 at 14:09:35 +0200, Thomas Monjalon wrote:
> Hi Rahul,
> 
> 2015-06-16 19:46, Rahul Lakkireddy:
> > After the commit-id 90a1633b2 (eal/linux: allow to map BARs with MSI-X 
> > tables),
> 
> Please show this information before the Signed-off-by lines:
> Fixes: 90a1633b2347 ("eal/linux: allow to map BARs with MSI-X tables")
> generated with this git alias:
> fixline = log -1 --abbrev=12 --format='Fixes: %h (\"%s\")'
> 

Ok. I'll add it in v2.

> > VFIO stopped working. On further debug, found that although BAR region
> 
> I suppose the whole VFIO didn't stopped working.
> Please precise the conditions of the failures (large offset, etc).

When using vfio, the probe fails over Chelsio T5 after commit-id 90a1633b2
(eal/linux: allow to map BARs with MSI-X tables). While debugging further, found
that the region offset for BAR 2 returned by VFIO is too large to fit in 
uint32_t.
Also, before the above commit, the region offset was passed to mmap as it is 
and so
VFIO is working fine before the above commit.

> 
> > offset and size from vfio are read as u64, they are truncated when assigned 
> > to
> > uint32_t variables resulting in wrong offset being passed for mmap.
> > 
> > The fix is to use uint64_t for offset and size.
> 
> Unfortunately, it doesn't build for 32-bit target.

I tried on RHEL-6.0 32-bit with T=i686-native-linuxapp-gcc and it built fine.
So, am I missing something here or some option may be?
I will also try out on newer distro like ubuntu 32-bit and confirm.


Thanks,
Rahul.


[dpdk-dev] Query on Filtering Support in DPDK

2015-12-02 Thread Rahul Lakkireddy
Hi Thomas,

On Monday, November 11/30/15, 2015 at 05:43:18 -0800, Thomas Monjalon wrote:
> Hi,
> 
> 2015-11-30 18:19, Rahul Lakkireddy:
> > 1. Add a new action 'switch' that will:
> >* Allow re-direction to different ports in hardware.
> > 
> >Also, for such a rule, additionally support below:
> > 
> >* Allow source mac/destination mac and vlan header re-writing to be
> >  done by the hardware.
> > 
> >* Allow re-write of TCP/IP headers to perform NAT in hardware.
> > 
> > 2. Add ability to mask individual fields at a particular layer for each
> >filter in flow_director. For example, mask all ip packets coming from
> >a particular subnet mask and particular range of l4 ports for each
> >filter rule.
> > 
> > We would like to get some suggestions on how to proceed with adding the
> > above features.
> 
> You need to identify which API must change and what will be the ABI changes.
> Then please send a deprecation notice before December 11 in order to be part
> of the 2.2 release notes.

I am currently identifying the various API changes to support this and
also the ABI changes if any.

> 
> If you have some RFC patches to send (at least the API changes), it would be
> a good discussion start.

I will try to post some RFC patches in 3-4 days time to get more
inputs/reviews on the approach.

Thanks,
Rahul.


[dpdk-dev] [PATCH] cxgbe: explictly mark this as pci_driver

2015-12-03 Thread Rahul Lakkireddy
On Wednesday, December 12/02/15, 2015 at 14:16:18 -0800, Stephen Hemminger 
wrote:
> The upcoming Hyper-V driver converts the pci_drv element
> in struct eth_driver to a union.  When vmbus is added the
> pci_drv needs to be explicit. Easier to fix the issue
> ahead of time.
> 
> This is backwards compatiable with previous code.
> 
> Signed-off-by: Stephen Hemminger 
> ---
>  drivers/net/cxgbe/cxgbe_ethdev.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/cxgbe/cxgbe_ethdev.c 
> b/drivers/net/cxgbe/cxgbe_ethdev.c
> index ec5d22b..97ef152 100644
> --- a/drivers/net/cxgbe/cxgbe_ethdev.c
> +++ b/drivers/net/cxgbe/cxgbe_ethdev.c
> @@ -847,7 +847,7 @@ out_free_adapter:
>  }
>  
>  static struct eth_driver rte_cxgbe_pmd = {
> - {
> + .pci_drv = {
>   .name = "rte_cxgbe_pmd",
>   .id_table = cxgb4_pci_tbl,
>   .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
> -- 
> 2.1.4
> 

Acked-by: Rahul Lakkireddy 


[dpdk-dev] [RFC 0/3] ethdev: Enhancements to flow director filter

2015-12-10 Thread Rahul Lakkireddy
This RFC series of patches attempt to extend the flow director filter to
add support for Chelsio T5 hardware filtering capabilities.

Chelsio T5 supports carrying out filtering in hardware which supports 3
actions to carry out on a packet which hit a filter viz.

1. Action Pass - Packets hitting a filter rule can be directed to a
   particular RXQ.

2. Action Drop - Packets hitting a filter rule are dropped in h/w.

3. Action Switch - Packets hitting a filter rule can be switched in h/w
   from one port to another, without involvement of host.  Also, the
   action Switch also supports rewrite of src-mac/dst-mac headers as
   well as rewrite of vlan headers.  It also supports rewrite of IP
   headers and thereby, supports NAT (Network Address Translation)
   in h/w.

Also, each filter rule can optionally support specifying a mask value
i.e. it's possible to create a filter rule for an entire subnet of IP
addresses or a range of tcp/udp ports, etc.

Patch 1 does the following:
- Adds an additional flow rte_eth_pkt_filter_flow which encapsulates
  ingress ports, l2 payload, vlan and ntuples.
- Adds an additional mask for the flow to allow range of values to be
  matched.
- Adds a new behavior 'switch'.
- Adds behavior arguments that can be passed when a particular behavior
  is taken.  For ex: in case of action 'switch', pass additional 4-tuple
  to allow rewriting src/dst ip and port addresses to support NAT'ing.

Patch 2 shows testpmd command line example to support packet filter
flow.

Patch 3 announces ABI change for filtering support.

The patch series has been compile tested on all x86 gcc targets and the
current fdir filter supported drivers seem to return appropriate error
codes when this new flow type and the new action are not supported and
hence are not affected.

Posting this series mainly for discussion on API change. Once this is
agreeable then, I will post the cxgbe PMD changes to use the new API.

Rahul Lakkireddy (3):
  ethdev: add packet filter flow and new behavior switch to fdir
  testpmd: add an example to show packet filter flow
  doc: announce ABI change for filtering support

 app/test-pmd/cmdline.c   | 435 ++-
 doc/guides/rel_notes/deprecation.rst |   6 +
 lib/librte_ether/rte_eth_ctrl.h  | 112 -
 3 files changed, 544 insertions(+), 9 deletions(-)

-- 
2.5.3



[dpdk-dev] [RFC 1/3] ethdev: add packet filter flow and new behavior switch to fdir

2015-12-10 Thread Rahul Lakkireddy
Add a new packet filter flow that allows filtering a packet based on
matching ingress port, ethertype, vlan, ip, and tcp/udp fields, i.e.
matching based on any or all fields at the same time.

Add the ability to provide masks for fields in flow to allow range of
values.

Add a new vlan flow containing inner and outer vlan to match. Add tos
and proto fields that can be matched for ipv4_flow.

Add a new behavior switch.

Add the ability to provide behavior arguments to allow insert/deletion
of matched fields in the flow.  Useful when rewriting matched fields
with new values.  Adds arguments for port, mac, vlan, and nat.
Ex: allows to provide new ip and port addresses to rewrite the fields
of packets matching a filter rule before NAT'ing.

Signed-off-by: Rahul Lakkireddy 
Signed-off-by: Kumar Sanghvi 
---
 lib/librte_ether/rte_eth_ctrl.h | 112 +++-
 1 file changed, 111 insertions(+), 1 deletion(-)

diff --git a/lib/librte_ether/rte_eth_ctrl.h b/lib/librte_ether/rte_eth_ctrl.h
index ce224ad..a2e770c 100644
--- a/lib/librte_ether/rte_eth_ctrl.h
+++ b/lib/librte_ether/rte_eth_ctrl.h
@@ -74,7 +74,11 @@ extern "C" {
 #define RTE_ETH_FLOW_IPV6_EX15
 #define RTE_ETH_FLOW_IPV6_TCP_EX16
 #define RTE_ETH_FLOW_IPV6_UDP_EX17
-#define RTE_ETH_FLOW_MAX18
+#define RTE_ETH_FLOW_PKT_FILTER_IPV4_TCP 18
+#define RTE_ETH_FLOW_PKT_FILTER_IPV4_UDP 19
+#define RTE_ETH_FLOW_PKT_FILTER_IPV6_TCP 20
+#define RTE_ETH_FLOW_PKT_FILTER_IPV6_UDP 21
+#define RTE_ETH_FLOW_MAX22

 /**
  * Feature filter types
@@ -407,6 +411,8 @@ struct rte_eth_l2_flow {
 struct rte_eth_ipv4_flow {
uint32_t src_ip;  /**< IPv4 source address to match. */
uint32_t dst_ip;  /**< IPv4 destination address to match. */
+   uint8_t tos;  /**< IPV4 type of service to match. */
+   uint8_t proto;/**< IPV4 proto to match. */
 };

 /**
@@ -500,6 +506,43 @@ struct rte_eth_tunnel_flow {
 };

 /**
+ * A structure used to define the input for vlan flow.
+ */
+struct rte_eth_vlan_flow {
+   uint16_t inner_vlan;  /**< Inner vlan field to match. */
+   uint16_t outer_vlan;  /**< Outer vlan field to match. */
+};
+
+/**
+ * A union used to define the input for N-Tuple flow
+ */
+union rte_eth_ntuple_flow {
+   struct rte_eth_tcpv4_flow  tcp4;
+   struct rte_eth_udpv4_flow  udp4;
+   struct rte_eth_tcpv6_flow  tcp6;
+   struct rte_eth_udpv6_flow  udp6;
+};
+
+/**
+ * A structure used to define the input for packet filter.
+ */
+struct rte_eth_pkt_filter {
+   uint8_t port_id; /**< Port id to match. */
+   struct rte_eth_l2_flowl2_flow;   /**< L2 flow fields to match. */
+   struct rte_eth_vlan_flow  vlan_flow; /**< Vlan flow fields to match. */
+   union rte_eth_ntuple_flow ntuple_flow;
+   /**< N-tuple flow fields to match. */
+};
+
+/**
+ * A structure used to define the input for packet filter flow.
+ */
+struct rte_eth_pkt_filter_flow {
+   struct rte_eth_pkt_filter pkt;  /**< Packet fields to match. */
+   struct rte_eth_pkt_filter mask; /**< Mask for matched fields. */
+};
+
+/**
  * An union contains the inputs for all types of flow
  */
 union rte_eth_fdir_flow {
@@ -514,6 +557,7 @@ union rte_eth_fdir_flow {
struct rte_eth_ipv6_flow   ipv6_flow;
struct rte_eth_mac_vlan_flow mac_vlan_flow;
struct rte_eth_tunnel_flow   tunnel_flow;
+   struct rte_eth_pkt_filter_flow pkt_filter_flow;
 };

 /**
@@ -545,6 +589,7 @@ enum rte_eth_fdir_behavior {
RTE_ETH_FDIR_ACCEPT = 0,
RTE_ETH_FDIR_REJECT,
RTE_ETH_FDIR_PASSTHRU,
+   RTE_ETH_FDIR_SWITCH,
 };

 /**
@@ -559,6 +604,69 @@ enum rte_eth_fdir_status {
 };

 /**
+ * Behavior sub operations on fields in matched flows.
+ */
+enum rte_eth_fdir_behavior_sub_op {
+   RTE_FDIR_BEHAVIOR_SUB_OP_UNKNOWN = 0,
+   RTE_FDIR_BEHAVIOR_SUB_OP_INSERT,
+   /**< Add/rewrite fields in matched flows */
+   RTE_FDIR_BEHAVIOR_SUB_OP_DELETE,
+   /**< Delete/reset fields in matched flows */
+};
+
+/**
+ * A structure used to define the input for passing port arguments for
+ * behavior taken.
+ */
+struct rte_eth_behavior_arg_port {
+   enum rte_eth_fdir_behavior_sub_op op; /**< Sub operation to do */
+   uint8_t port_id;  /**< Physical port to redirect */
+};
+
+/**
+ * A structure used to define the input for passing mac arguments for
+ * behavior taken.
+ */
+struct rte_eth_behavior_arg_mac {
+   enum rte_eth_fdir_behavior_sub_op op; /**< Sub operation to do */
+   struct ether_addr src_mac;/**< SRC Ethernet Address to rewirte. */
+   struct ether_addr dst_mac;/**< DST Ethernet Address to rewrite. */
+};
+
+/**
+ * A structure used to define the input for passing vlan arguments for
+ * behavior taken.
+ */
+struct rte_eth_behavior_arg_vlan {
+  

[dpdk-dev] [RFC 2/3] testpmd: add an example to show packet filter flow

2015-12-10 Thread Rahul Lakkireddy
Extend the existing flow_director_filter to add support for packet
filter flow.  Also shows how to pass the extra behavior arguments
to rewrite fields in matched filter rules.

Signed-off-by: Rahul Lakkireddy 
Signed-off-by: Kumar Sanghvi 
---
 app/test-pmd/cmdline.c | 435 -
 1 file changed, 427 insertions(+), 8 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 73298c9..488eddc 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -641,7 +641,7 @@ static void cmd_help_long_parsed(void *parsed_result,
" flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
" src (src_ip_address) dst (dst_ip_address)"
" vlan (vlan_value) flexbytes (flexbytes_value)"
-   " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
+   " (drop|fwd|switch) pf|vf(vf_id) queue (queue_id)"
" fd_id (fd_id_value)\n"
"Add/Del an IP type flow director filter.\n\n"

@@ -650,7 +650,7 @@ static void cmd_help_long_parsed(void *parsed_result,
" src (src_ip_address) (src_port)"
" dst (dst_ip_address) (dst_port)"
" vlan (vlan_value) flexbytes (flexbytes_value)"
-   " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
+   " (drop|fwd|switch) pf|vf(vf_id) queue (queue_id)"
" fd_id (fd_id_value)\n"
"Add/Del an UDP/TCP type flow director filter.\n\n"

@@ -659,16 +659,37 @@ static void cmd_help_long_parsed(void *parsed_result,
" src (src_ip_address) (src_port)"
" dst (dst_ip_address) (dst_port)"
" tag (verification_tag) vlan (vlan_value)"
-   " flexbytes (flexbytes_value) (drop|fwd)"
+   " flexbytes (flexbytes_value) (drop|fwd|switch)"
" pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
"Add/Del a SCTP type flow director filter.\n\n"

"flow_director_filter (port_id) mode IP 
(add|del|update)"
" flow l2_payload ether (ethertype)"
-   " flexbytes (flexbytes_value) (drop|fwd)"
+   " flexbytes (flexbytes_value) (drop|fwd|switch)"
" pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
"Add/Del a l2 payload type flow director 
filter.\n\n"

+   "flow_director_filter (port_id) mode IP 
(add|del|update)"
+   " flow (ipv4-tcp-pkt-filter|ipv4-udp-pkt-filter|"
+   " ipv6-tcp-pkt-filter|ipv6-udp-pkt-filter)"
+   " ingress-port (port_id) (port_id_mask)"
+   " ether (ethertype) (ethertype_mask)"
+   " inner-vlan (inner_vlan_value) (inner_vlan_mask)"
+   " outer-vlan (outer_vlan_value) (outer_vlan_mask)"
+   " tos (tos_value) (tos_mask)"
+   " proto (proto_value) (proto_mask)"
+   " src (src_ip) (src_ip_mask) (src_port) (src_port_mask)"
+   " dst (dst_ip) (dst_ip_mask) (dst_port) (dst_port_mask)"
+   " flexbytes (flexbytes_value) (drop|fwd|switch)"
+   " pf|vf(vf_id) queue (queue_id)"
+   " port-arg none|port-redirect (dst-port-id)"
+   " mac-arg none|mac-rewrite (src-mac) (dst-mac)"
+   " vlan-arg none|vlan-rewrite|vlan-del (vlan_value)"
+   " nat-arg none|nat-rewrite"
+   " src (src_ip) (src_port) dst (dst_ip) (dst_port)"
+   " fd_id (fd_id_value)\n"
+   "Add/Del a packet filter type flow director 
filter.\n\n"
+
"flow_director_filter (port_id) mode MAC-VLAN 
(add|del|update)"
" mac (mac_address) vlan (vlan_value)"
" flexbytes (flexbytes_value) (drop|fwd)"
@@ -7973,14 +7994,34 @@ struct cmd_flow_director_result {
cmdline_fixed_string_t ops;
cmdline_fixed_string_t flow;
cmdline_fixed_string_t flow_type;
+   cmdline_fixed_string_t iport;
+   uint8_t iport_id;
+   

[dpdk-dev] [RFC 3/3] doc: announce ABI change for filtering support

2015-12-10 Thread Rahul Lakkireddy
Current filtering support will be enhanced to accommodate support
for Chelsio T5 hardware filtering support.

Signed-off-by: Rahul Lakkireddy 
Signed-off-by: Kumar Sanghvi 
---
 doc/guides/rel_notes/deprecation.rst | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/doc/guides/rel_notes/deprecation.rst 
b/doc/guides/rel_notes/deprecation.rst
index 1c7ab01..ca43b16 100644
--- a/doc/guides/rel_notes/deprecation.rst
+++ b/doc/guides/rel_notes/deprecation.rst
@@ -19,3 +19,9 @@ Deprecation Notices
   and table action handlers will be updated:
   the pipeline parameter will be added, the packets mask parameter will be
   either removed (for input port action handler) or made input-only.
+
+* The filtering support will be changed to add a new packet filter
+  flow, add a new behavior 'switch', add an ability to add mask
+  for fields in each filter rule, and add an ability to pass extra
+  arguments for the behavior taken to allow rewriting matched fields
+  in filter rule.
-- 
2.5.3



[dpdk-dev] [RFC 1/3] ethdev: add packet filter flow and new behavior switch to fdir

2015-12-11 Thread Rahul Lakkireddy
Hi Andrey,

On Thursday, December 12/10/15, 2015 at 07:46:42 -0800, Chilikin, Andrey wrote:
> Hi Rahul,
> 
> If ABI for fdir is going to be changed should we then take more general 
> approach to accommodate other NICs as well? For example,  for 
> "rte_eth_ipv4_flow" you have "tos" and "proto" fields added, but "ttl" was 
> left out of scope. I believe that "rte_eth_udpv6_flow" should be compatible 
> with new IPv4 structure, so "flow label", "tc", "next header" and "hop limit" 
> to be added as well as other NICs might have support for fdir rules for all 
> these fields.
> 

I agree.

I'll wait for some more review comments if there are any and then post a
v2 RFC series with above changes.

Thanks,
Rahul


[dpdk-dev] [PATCH] cxgbe: fix unnecessary check for freelist existence while freeing rxq

2015-12-11 Thread Rahul Lakkireddy
When refilling freelists for the first time and if it fails, the rxq
is freed and returns ENOMEM. There is a check while freeing hardware rxq
to pass freelist context id if the freelist exists or 0x otherwise.
The error path is only reached if freelist exists. So, fix is to remove
the useless check for freelist existence.

Thanks to John McNamara  for reporting it.

Coverity issue: 107108
Fixes: 92c8a63223e5 ("cxgbe: add device configuration and Rx support")

Signed-off-by: Rahul Lakkireddy 
Signed-off-by: Kumar Sanghvi 
---
 drivers/net/cxgbe/sge.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/cxgbe/sge.c b/drivers/net/cxgbe/sge.c
index 51449e0..3c62d03 100644
--- a/drivers/net/cxgbe/sge.c
+++ b/drivers/net/cxgbe/sge.c
@@ -1823,7 +1823,7 @@ int t4_sge_alloc_rxq(struct adapter *adap, struct 
sge_rspq *iq, bool fwevtq,

 refill_fl_err:
t4_iq_free(adap, adap->mbox, adap->pf, 0, FW_IQ_TYPE_FL_INT_CAP,
-  iq->cntxt_id, fl ? fl->cntxt_id : 0x, 0x);
+  iq->cntxt_id, fl->cntxt_id, 0x);
 fl_nomem:
ret = -ENOMEM;
 err:
-- 
2.5.3



[dpdk-dev] [RFC 3/3] doc: announce ABI change for filtering support

2015-12-15 Thread Rahul Lakkireddy
Hi Thomas,

I am preparing a v2 of this series where I will be accomodating some
more fields to be considered for filtering. However, if the overall
approach seems ok to everyone then, should I submit a separate patch
for this ABI change announcement ?


Thanks,
Rahul.

On Thursday, December 12/10/15, 2015 at 19:31:04 +0530, Rahul Lakkireddy wrote:
> Current filtering support will be enhanced to accommodate support
> for Chelsio T5 hardware filtering support.
> 
> Signed-off-by: Rahul Lakkireddy 
> Signed-off-by: Kumar Sanghvi 
> ---
>  doc/guides/rel_notes/deprecation.rst | 6 ++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/doc/guides/rel_notes/deprecation.rst 
> b/doc/guides/rel_notes/deprecation.rst
> index 1c7ab01..ca43b16 100644
> --- a/doc/guides/rel_notes/deprecation.rst
> +++ b/doc/guides/rel_notes/deprecation.rst
> @@ -19,3 +19,9 @@ Deprecation Notices
>and table action handlers will be updated:
>the pipeline parameter will be added, the packets mask parameter will be
>either removed (for input port action handler) or made input-only.
> +
> +* The filtering support will be changed to add a new packet filter
> +  flow, add a new behavior 'switch', add an ability to add mask
> +  for fields in each filter rule, and add an ability to pass extra
> +  arguments for the behavior taken to allow rewriting matched fields
> +  in filter rule.
> -- 
> 2.5.3
> 


[dpdk-dev] [RFC 3/3] doc: announce ABI change for filtering support

2015-12-15 Thread Rahul Lakkireddy
Hi Thomas,

On Tuesday, December 12/15/15, 2015 at 00:55:20 -0800, Thomas Monjalon wrote:
> 2015-12-15 14:10, Rahul Lakkireddy:
> > Hi Thomas,
> > 
> > I am preparing a v2 of this series where I will be accomodating some
> > more fields to be considered for filtering. However, if the overall
> > approach seems ok to everyone then, should I submit a separate patch
> > for this ABI change announcement ?
> 
> Yes, if this announce is not enough:
>   http://dpdk.org/browse/dpdk/commit/?id=648e6b3815a35
> 

Apart from rte_eth_fdir_flow ABI change mentioned in above link, new
fields will be added to rte_eth_ipv4_flow and rte_eth_ipv6_flow,
which break their ABI.

Also, 4 new flow types will be added, which increases RTE_ETH_FLOW_MAX
from 18 to 22 and breaks the ABI.

Should I send a separate ABI change announce patch for each of them?

Thanks,
Rahul


[dpdk-dev] [PATCH] doc: announce ABI change for extending filtering support

2015-12-15 Thread Rahul Lakkireddy
Current filtering support will be enhanced to accommodate support
for Chelsio T5 hardware filtering support.

Signed-off-by: Rahul Lakkireddy 
Signed-off-by: Kumar Sanghvi 
---
 doc/guides/rel_notes/deprecation.rst | 8 
 1 file changed, 8 insertions(+)

diff --git a/doc/guides/rel_notes/deprecation.rst 
b/doc/guides/rel_notes/deprecation.rst
index f8a41dd..15e766d 100644
--- a/doc/guides/rel_notes/deprecation.rst
+++ b/doc/guides/rel_notes/deprecation.rst
@@ -41,3 +41,11 @@ Deprecation Notices
   commands (such as RETA update in testpmd).  This should impact
   CMDLINE_PARSE_RESULT_BUFSIZE, STR_TOKEN_SIZE and RDLINE_BUF_SIZE.
   It should be integrated in release 2.3.
+
+* ABI changes are planned for rte_eth_ipv4_flow and rte_eth_ipv6_flow to
+  include more fields to be matched against. The release 2.2 does not
+  contain these ABI changes, but release 2.3 will.
+
+* ABI changes are planned for adding four new flow types. This impacts
+  RTE_ETH_FLOW_MAX. The release 2.2 does not contain these ABI changes,
+  but release 2.3 will.
-- 
2.5.3



[dpdk-dev] [RFC v2 0/2] ethdev: Enhancements to flow director filter

2015-12-23 Thread Rahul Lakkireddy
This RFC series of patches attempt to extend the flow director filter to
add support for Chelsio T5 hardware filtering capabilities.

Chelsio T5 supports carrying out filtering in hardware which supports 3
actions to carry out on a packet which hit a filter viz.

1. Action Pass - Packets hitting a filter rule can be directed to a
   particular RXQ.

2. Action Drop - Packets hitting a filter rule are dropped in h/w.

3. Action Switch - Packets hitting a filter rule can be switched in h/w
   from one port to another, without involvement of host.  Also, the
   action Switch also supports rewrite of src-mac/dst-mac headers as
   well as rewrite of vlan headers.  It also supports rewrite of IP
   headers and thereby, supports NAT (Network Address Translation)
   in h/w.

Also, each filter rule can optionally support specifying a mask value
i.e. it's possible to create a filter rule for an entire subnet of IP
addresses or a range of tcp/udp ports, etc.

Patch 1 does the following:
- Adds an additional flow rte_eth_pkt_filter_flow which encapsulates
  ingress ports, l2 payload, vlan and ntuples.
- Adds an additional mask for the flow to allow range of values to be
  matched.
- Adds an ability to set both filters with masks (Maskfull) and
  without masks (Maskless).  Also allow prioritizing one of these
  filter types over the other when a packet matches several types.
- Adds a new behavior 'switch'.
- Adds behavior arguments that can be passed when a particular behavior
  is taken.  For ex: in case of action 'switch', pass additional 4-tuple
  to allow rewriting src/dst ip and port addresses to support NAT'ing.

Patch 2 shows testpmd command line example to support packet filter
flow.

The patch series has been compile tested on all x86 gcc targets and the
current fdir filter supported drivers seem to return appropriate error
codes when this new flow type and the new action are not supported and
hence are not affected.

Posting this series mainly for discussion on API change. Once this is
agreeable then, I will post the cxgbe PMD changes to use the new API.

---
v2:
1. Added ttl to rte_eth_ipv4_flow and tc, flow_label, next_header,
   and hop_limit to rte_eth_ipv6_flow.

2. Added new field type to rte_eth_pkt_filter_flow to differentiate
   between maskfull and maskless filter types.

3. Added new field prio to rte_eth_pkt_filter_flow to allow setting
   priority over maskfull or maskless when packet matches multiple
   filter types.

4. Added new behavior sub op RTE_FDIR_BEHAVIOR_SUB_OP_SWAP to allow
   swapping fields in matched flows. For ex, useful when swapping mac
   addresses in hardware before switching.

5. Updated the testpmd example to reflect the above new changes.

6. Dropped Patch 3 since the ABI announcement has already been merged.

Rahul Lakkireddy (2):
  ethdev: add packet filter flow and new behavior switch to fdir
  testpmd: add an example to show packet filter flow

 app/test-pmd/cmdline.c  | 528 +++-
 lib/librte_ether/rte_eth_ctrl.h | 127 +-
 2 files changed, 646 insertions(+), 9 deletions(-)

-- 
2.5.3



[dpdk-dev] [RFC v2 1/2] ethdev: add packet filter flow and new behavior switch to fdir

2015-12-23 Thread Rahul Lakkireddy
Add a new packet filter flow that allows filtering a packet based on
matching ingress port, ethertype, vlan, ip, and tcp/udp fields, i.e.
matching based on any or all fields at the same time.

Add the ability to provide masks for fields in flow to allow range of
values. Allow selection of maskfull vs maskless filter types. Provide
mechanism to set priority to maskfull vs maskless filter types when
packet matches several filter types.

Add a new vlan flow containing inner and outer vlan to match. Add tos,
proto, and ttl fields that can be matched for ipv4 flow.  Add tc,
flow_label, next_header, and hop_limit fields that can be matched for
ipv6 flow.

Add a new behavior switch.

Add the ability to provide behavior arguments to allow insert/deletion/
swapping of matched fields in the flow.  Useful when rewriting matched
fields with new values.  Adds arguments for port, mac, vlan, and nat.
Ex: allows to provide new ip and port addresses to rewrite the fields
of packets matching a filter rule before NAT'ing.

Signed-off-by: Rahul Lakkireddy 
Signed-off-by: Kumar Sanghvi 
---
v2:
1. Added ttl to rte_eth_ipv4_flow and tc, flow_label, next_header,
   and hop_limit to rte_eth_ipv6_flow.

2. Added new field type to rte_eth_pkt_filter_flow to differentiate
   between maskfull and maskless filter types.

3. Added new field prio to rte_eth_pkt_filter_flow to allow setting
   priority over maskfull or maskless when packet matches multiple
   filter types.

4. Added new behavior sub op RTE_FDIR_BEHAVIOR_SUB_OP_SWAP to allow
   swapping fields in matched flows. Useful when swapping mac addresses
   in hardware before switching.

 lib/librte_ether/rte_eth_ctrl.h | 127 +++-
 1 file changed, 126 insertions(+), 1 deletion(-)

diff --git a/lib/librte_ether/rte_eth_ctrl.h b/lib/librte_ether/rte_eth_ctrl.h
index ce224ad..5cc22a0 100644
--- a/lib/librte_ether/rte_eth_ctrl.h
+++ b/lib/librte_ether/rte_eth_ctrl.h
@@ -74,7 +74,11 @@ extern "C" {
 #define RTE_ETH_FLOW_IPV6_EX15
 #define RTE_ETH_FLOW_IPV6_TCP_EX16
 #define RTE_ETH_FLOW_IPV6_UDP_EX17
-#define RTE_ETH_FLOW_MAX18
+#define RTE_ETH_FLOW_PKT_FILTER_IPV4_TCP 18
+#define RTE_ETH_FLOW_PKT_FILTER_IPV4_UDP 19
+#define RTE_ETH_FLOW_PKT_FILTER_IPV6_TCP 20
+#define RTE_ETH_FLOW_PKT_FILTER_IPV6_UDP 21
+#define RTE_ETH_FLOW_MAX22

 /**
  * Feature filter types
@@ -407,6 +411,9 @@ struct rte_eth_l2_flow {
 struct rte_eth_ipv4_flow {
uint32_t src_ip;  /**< IPv4 source address to match. */
uint32_t dst_ip;  /**< IPv4 destination address to match. */
+   uint8_t tos;  /**< IPV4 type of service to match. */
+   uint8_t proto;/**< IPV4 proto to match. */
+   uint8_t ttl;  /**< IPV4 time to live to match. */
 };

 /**
@@ -443,6 +450,10 @@ struct rte_eth_sctpv4_flow {
 struct rte_eth_ipv6_flow {
uint32_t src_ip[4];  /**< IPv6 source address to match. */
uint32_t dst_ip[4];  /**< IPv6 destination address to match. */
+   uint8_t  tc; /**< IPv6 traffic class to match. */
+   uint32_t flow_label; /**< IPv6 flow label to match. */
+   uint8_t  next_header;/**< IPv6 next header to match. */
+   uint8_t  hop_limit;  /**< IPv6 hop limits to match. */
 };

 /**
@@ -500,6 +511,51 @@ struct rte_eth_tunnel_flow {
 };

 /**
+ * A structure used to define the input for vlan flow.
+ */
+struct rte_eth_vlan_flow {
+   uint16_t inner_vlan;  /**< Inner vlan field to match. */
+   uint16_t outer_vlan;  /**< Outer vlan field to match. */
+};
+
+/**
+ * A union used to define the input for N-Tuple flow
+ */
+union rte_eth_ntuple_flow {
+   struct rte_eth_tcpv4_flow  tcp4;
+   struct rte_eth_udpv4_flow  udp4;
+   struct rte_eth_tcpv6_flow  tcp6;
+   struct rte_eth_udpv6_flow  udp6;
+};
+
+/**
+ * A structure used to define the input for packet filter.
+ */
+struct rte_eth_pkt_filter {
+   uint8_t port_id; /**< Port id to match. */
+   struct rte_eth_l2_flowl2_flow;   /**< L2 flow fields to match. */
+   struct rte_eth_vlan_flow  vlan_flow; /**< Vlan flow fields to match. */
+   union rte_eth_ntuple_flow ntuple_flow;
+   /**< N-tuple flow fields to match. */
+};
+
+/**
+ * A structure used to define the input for packet filter flow.
+ */
+enum rte_eth_pkt_filter_type {
+   RTE_ETH_PKT_FILTER_TYPE_MASKLESS = 0, /**< Ignore masks in the flow */
+   RTE_ETH_PKT_FILTER_TYPE_MASKFULL, /**< Consider masks in the flow */
+};
+
+struct rte_eth_pkt_filter_flow {
+   enum rte_eth_pkt_filter_type type;   /**< Type of filter */
+   enum rte_eth_pkt_filter_type prio;
+   /**< Prioritize the filter type when a packet matches several types */
+   struct rte_eth_pkt_filter pkt;  /**< Packet fields to match. */
+   struct rte_eth_p

[dpdk-dev] [RFC v2 2/2] testpmd: add an example to show packet filter flow

2015-12-23 Thread Rahul Lakkireddy
Extend the existing flow_director_filter to add support for packet
filter flow.  Also shows how to pass the extra behavior arguments
to rewrite fields in matched filter rules.

Signed-off-by: Rahul Lakkireddy 
Signed-off-by: Kumar Sanghvi 
---
v2:
1. Added new field filter-type to allow specifying maskfull vs maskless
   filter types.
2. Added new field filter-prio to allow specifying the priority between
   maskfull and maskless filters i.e. if we have a maskfull and a
   maskless filter both of which can match a single traffic pattern
   then, which one takes the priority is determined by filter-prio.
3. Added new field flow-label to be matched for ipv6.
4. Added new mac-swap behavior argument.


 app/test-pmd/cmdline.c | 528 -
 1 file changed, 520 insertions(+), 8 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 73298c9..3402f2c 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -641,7 +641,7 @@ static void cmd_help_long_parsed(void *parsed_result,
" flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
" src (src_ip_address) dst (dst_ip_address)"
" vlan (vlan_value) flexbytes (flexbytes_value)"
-   " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
+   " (drop|fwd|switch) pf|vf(vf_id) queue (queue_id)"
" fd_id (fd_id_value)\n"
"Add/Del an IP type flow director filter.\n\n"

@@ -650,7 +650,7 @@ static void cmd_help_long_parsed(void *parsed_result,
" src (src_ip_address) (src_port)"
" dst (dst_ip_address) (dst_port)"
" vlan (vlan_value) flexbytes (flexbytes_value)"
-   " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
+   " (drop|fwd|switch) pf|vf(vf_id) queue (queue_id)"
" fd_id (fd_id_value)\n"
"Add/Del an UDP/TCP type flow director filter.\n\n"

@@ -659,16 +659,41 @@ static void cmd_help_long_parsed(void *parsed_result,
" src (src_ip_address) (src_port)"
" dst (dst_ip_address) (dst_port)"
" tag (verification_tag) vlan (vlan_value)"
-   " flexbytes (flexbytes_value) (drop|fwd)"
+   " flexbytes (flexbytes_value) (drop|fwd|switch)"
" pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
"Add/Del a SCTP type flow director filter.\n\n"

"flow_director_filter (port_id) mode IP 
(add|del|update)"
" flow l2_payload ether (ethertype)"
-   " flexbytes (flexbytes_value) (drop|fwd)"
+   " flexbytes (flexbytes_value) (drop|fwd|switch)"
" pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
"Add/Del a l2 payload type flow director 
filter.\n\n"

+   "flow_director_filter (port_id) mode IP 
(add|del|update)"
+   " flow (ipv4-tcp-pkt-filter|ipv4-udp-pkt-filter"
+   " ipv6-tcp-pkt-filter|ipv6-udp-pkt-filter)"
+   " filter-type maskfull|maskless"
+   " filter-prio default|maskfull|maskless"
+   " ingress-port (port_id) (port_id_mask)"
+   " ether (ethertype) (ethertype_mask)"
+   " inner-vlan (inner_vlan_value) (inner_vlan_mask)"
+   " outer-vlan (outer_vlan_value) (outer_vlan_mask)"
+   " tos (tos_value) (tos_mask)"
+   " flow-label (flow_label_value) (flow_label_mask)"
+   " proto (proto_value) (proto_mask)"
+   " ttl (ttl_value) (ttl_mask)"
+   " src (src_ip) (src_ip_mask) (src_port) (src_port_mask)"
+   " dst (dst_ip) (dst_ip_mask) (dst_port) (dst_port_mask)"
+   " flexbytes (flexbytes_value) (drop|fwd|switch)"
+   " pf|vf(vf_id) queue (queue_id)"
+   " port-arg none|port-redirect (dst-port-id)"
+   " mac-arg none|mac-rewrite|mac-swap (src-mac) (dst-mac)"
+   " vlan-arg none|vlan-rewrite|vlan-del (vlan_value)"
+   " nat-arg non

[dpdk-dev] [PATCH v2] vfio: Fix overflow while assigning vfio BAR region offset and size

2015-06-23 Thread Rahul Lakkireddy
When using vfio, the probe fails over Chelsio T5 adapters after
commit-id 90a1633b2 (eal/linux: allow to map BARs with MSI-X tables).

While debugging further, found that the BAR region offset and size read from
vfio are u64, but are assigned to uint32_t variables.  This results in the u64
value getting truncated to 0 and passing wrong offset and size to mmap for
subsequent BAR regions (i.e. trying to overwrite previously allocated BAR 0
region).

The fix is to use these region offset and size directly rather than assigning
to uint32_t variables.

Fixes: 90a1633b2347 ("eal/linux: allow to map BARs with MSI-X tables")
Signed-off-by: Rahul Lakkireddy 
Signed-off-by: Kumar Sanghvi 
---
v2:
- For fixing 32-bit build failure, rather than converting uint32_t var to 
uint64_t
  as done in v1, taking a different approach instead to revert a part of above
  commit-id so as to use the original region offset and size directly.
- Add the commit-id that this patch fixes and update commit log.

 lib/librte_eal/linuxapp/eal/eal_pci_vfio.c | 12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c 
b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
index 426953a..ff974f5 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
@@ -775,9 +775,6 @@ pci_vfio_map_resource(struct rte_pci_device *dev)
memreg[0].offset, memreg[0].size,
memreg[1].offset, memreg[1].size);
}
-   } else {
-   memreg[0].offset = reg.offset;
-   memreg[0].size = reg.size;
}

/* try to figure out an address */
@@ -815,6 +812,15 @@ pci_vfio_map_resource(struct rte_pci_device *dev)
MAP_FIXED);
}

+   if (!map_addr) {
+   /* Not a BAR containing MSI-X */
+   map_addr = pci_map_resource(bar_addr,
+   vfio_dev_fd,
+   reg.offset,
+   reg.size,
+   MAP_FIXED);
+   }
+
if (map_addr == MAP_FAILED || !map_addr) {
munmap(bar_addr, reg.size);
bar_addr = MAP_FAILED;
-- 
2.4.1



[dpdk-dev] [PATCH v3 3/9] cxgbe: add device configuration and RX support for cxgbe PMD.

2015-06-30 Thread Rahul Lakkireddy
On Sun, Jun 28, 2015 at 21:34:28 +0200, Thomas Monjalon wrote:
> 2015-06-18 17:47, Rahul Lakkireddy:
> > Adds RX support for the cxgbe poll mode driver.  This patch:
> > 
> > 1. Adds rx queue related eth_dev_ops.
> > 2. Adds RSS support.
> > 3. Adds dev_configure() and dev_infos_get() eth_dev_ops.
> > 4. Adds rx_pkt_burst for receiving packets.
> > 
> > Signed-off-by: Rahul Lakkireddy 
> > Signed-off-by: Kumar Sanghvi 
> 
> This patch doesn't build with 32-bit GCC because of some printf args (%lu).

I have fixed it in v4. Will post it soon.

Thanks,
Rahul.



[dpdk-dev] [PATCH v3 2/9] cxgbe: add cxgbe poll mode driver.

2015-06-30 Thread Rahul Lakkireddy
Hi Thomas,

On Sun, Jun 28, 2015 at 21:32:32 +0200, Thomas Monjalon wrote:
> 2015-06-18 17:47, Rahul Lakkireddy:
> > +Chelsio cxgbe
> > +M: Rahul Lakkireddy 
> > +F: drivers/net/cxgbe/
> > +F: doc/guides/nics/cxgbe.rst
> 
> Just a detail: the doc file is added in a later patch.
> For consistency, this line should be added later.

I have fixed it in v4. Will post it soon.

> 
> [...]
> > --- a/config/common_linuxapp
> > +++ b/config/common_linuxapp
> > @@ -208,6 +208,16 @@ CONFIG_RTE_LIBRTE_MLX4_TX_MP_CACHE=8
> >  CONFIG_RTE_LIBRTE_MLX4_SOFT_COUNTERS=1
> >  
> >  #
> > +# Compile burst-oriented Chelsio Terminator 10GbE/40GbE (CXGBE) PMD
> > +#
> > +CONFIG_RTE_LIBRTE_CXGBE_PMD=y
> > +CONFIG_RTE_LIBRTE_CXGBE_DEBUG=n
> > +CONFIG_RTE_LIBRTE_CXGBE_DEBUG_REG=n
> > +CONFIG_RTE_LIBRTE_CXGBE_DEBUG_MBOX=n
> > +CONFIG_RTE_LIBRTE_CXGBE_DEBUG_TX=n
> > +CONFIG_RTE_LIBRTE_CXGBE_DEBUG_RX=n
> 
> What is the status of the driver with FreeBSD?

We have compilation fixes in pipeline waiting for internal QA.
We are currently mid-way in testing linux vfio after which we will pick
up FBSD support.

> Could we, at least, add the options in common_bsdapp even disabled?

We tried compilation by keeping it disabled in common_bsdapp and the
compilation goes fine.

However, if its ok with you, we would like to carry out some basic testing
once our QA picks it up before adding this to common_bsdapp.

Thanks,
Rahul


[dpdk-dev] [PATCH v4 0/9] Chelsio Terminator 5 (T5) 10G/40G Poll Mode Driver

2015-06-30 Thread Rahul Lakkireddy
This series of patches add the CXGBE Poll Mode Driver support for Chelsio
Terminator 5 series of 10G/40G adapters.  The CXGBE PMD is split into multiple
patches.  The first patch adds the hardware specific api for all supported
Chelsio T5 adapters and the patches from 2 to 8 add the actual DPDK CXGBE PMD.

Also, the CXGBE PMD is enabled for compilation and linking by patch 2.
MAINTAINERS file is also updated by patch 2 to claim responsibility for the
CXGBE PMD.

More information on the CXGBE PMD can be found in the documentation added by
patch 9.  

v4:
- Fix 32-bit and clang compilation.
- Moved cxgbe doc entry in MAINTAINERS from patch 2 to patch 9 for consistency.

v3:
- Merge patches 10 and 11 with patch 2.
- Add rte_pmd_cxgbe_version.map and add EXPORT_MAP and LIBABIVER to cxgbe
  Makefile.
- Use RTE_DIM macro for calculating ARRAY_SIZE.

v2:
- Move the driver to drivers/net directory and update all config files and
  commit logs.  Also update MAINTAINERS.
- Break the second patch into more patches; incrementally, adding features to
  the cxgbe poll mode driver.
- Replace bitwise operations in finding last (most significant) bit set with
  gcc's __builtin_clz.
- Fix the return value returned by link update eth_dev operation.
- Few bug fixes and code cleanup.

Rahul Lakkireddy (9):
  cxgbe: add hardware specific api for all supported Chelsio T5 series
adapters.
  cxgbe: add cxgbe poll mode driver.
  cxgbe: add device configuration and RX support for cxgbe PMD.
  cxgbe: add TX support for cxgbe PMD.
  cxgbe: add device related operations for cxgbe PMD.
  cxgbe: add port statistics for cxgbe PMD.
  cxgbe: add link related functions for cxgbe PMD.
  cxgbe: add flow control functions for cxgbe PMD.
  doc: add cxgbe PMD documentation under doc/guides/nics/cxgbe.rst

 MAINTAINERS |5 +
 config/common_linuxapp  |   10 +
 doc/guides/nics/cxgbe.rst   |  209 +++
 doc/guides/nics/index.rst   |1 +
 doc/guides/prog_guide/source_org.rst|1 +
 drivers/net/Makefile|1 +
 drivers/net/cxgbe/Makefile  |   78 +
 drivers/net/cxgbe/base/adapter.h|  565 ++
 drivers/net/cxgbe/base/common.h |  401 
 drivers/net/cxgbe/base/t4_chip_type.h   |   79 +
 drivers/net/cxgbe/base/t4_hw.c  | 2686 +++
 drivers/net/cxgbe/base/t4_hw.h  |  149 ++
 drivers/net/cxgbe/base/t4_msg.h |  345 
 drivers/net/cxgbe/base/t4_pci_id_tbl.h  |  148 ++
 drivers/net/cxgbe/base/t4_regs.h|  779 
 drivers/net/cxgbe/base/t4_regs_values.h |  168 ++
 drivers/net/cxgbe/base/t4fw_interface.h | 1730 +
 drivers/net/cxgbe/cxgbe.h   |   60 +
 drivers/net/cxgbe/cxgbe_compat.h|  266 +++
 drivers/net/cxgbe/cxgbe_ethdev.c|  802 
 drivers/net/cxgbe/cxgbe_main.c  | 1207 
 drivers/net/cxgbe/rte_pmd_cxgbe_version.map |4 +
 drivers/net/cxgbe/sge.c | 2241 ++
 mk/rte.app.mk   |1 +
 24 files changed, 11936 insertions(+)
 create mode 100644 doc/guides/nics/cxgbe.rst
 create mode 100644 drivers/net/cxgbe/Makefile
 create mode 100644 drivers/net/cxgbe/base/adapter.h
 create mode 100644 drivers/net/cxgbe/base/common.h
 create mode 100644 drivers/net/cxgbe/base/t4_chip_type.h
 create mode 100644 drivers/net/cxgbe/base/t4_hw.c
 create mode 100644 drivers/net/cxgbe/base/t4_hw.h
 create mode 100644 drivers/net/cxgbe/base/t4_msg.h
 create mode 100644 drivers/net/cxgbe/base/t4_pci_id_tbl.h
 create mode 100644 drivers/net/cxgbe/base/t4_regs.h
 create mode 100644 drivers/net/cxgbe/base/t4_regs_values.h
 create mode 100644 drivers/net/cxgbe/base/t4fw_interface.h
 create mode 100644 drivers/net/cxgbe/cxgbe.h
 create mode 100644 drivers/net/cxgbe/cxgbe_compat.h
 create mode 100644 drivers/net/cxgbe/cxgbe_ethdev.c
 create mode 100644 drivers/net/cxgbe/cxgbe_main.c
 create mode 100644 drivers/net/cxgbe/rte_pmd_cxgbe_version.map
 create mode 100644 drivers/net/cxgbe/sge.c

-- 
2.4.1



[dpdk-dev] [PATCH v4 1/9] cxgbe: add hardware specific api for all supported Chelsio T5 series adapters.

2015-06-30 Thread Rahul Lakkireddy
Adds hardware specific api for all the Chelsio T5 adapters under
drivers/net/cxgbe/base directory.

Signed-off-by: Rahul Lakkireddy 
Signed-off-by: Kumar Sanghvi 
---
v4:
- No changes

v3:
- No changes

v2:
- Move files to new directory under drivers/net/cxgbe/base and update commit
  log.
- Few bug fixes related to tx.

 drivers/net/cxgbe/base/adapter.h|  565 +++
 drivers/net/cxgbe/base/common.h |  401 +
 drivers/net/cxgbe/base/t4_chip_type.h   |   79 +
 drivers/net/cxgbe/base/t4_hw.c  | 2686 +++
 drivers/net/cxgbe/base/t4_hw.h  |  149 ++
 drivers/net/cxgbe/base/t4_msg.h |  345 
 drivers/net/cxgbe/base/t4_pci_id_tbl.h  |  148 ++
 drivers/net/cxgbe/base/t4_regs.h|  779 +
 drivers/net/cxgbe/base/t4_regs_values.h |  168 ++
 drivers/net/cxgbe/base/t4fw_interface.h | 1730 
 10 files changed, 7050 insertions(+)
 create mode 100644 drivers/net/cxgbe/base/adapter.h
 create mode 100644 drivers/net/cxgbe/base/common.h
 create mode 100644 drivers/net/cxgbe/base/t4_chip_type.h
 create mode 100644 drivers/net/cxgbe/base/t4_hw.c
 create mode 100644 drivers/net/cxgbe/base/t4_hw.h
 create mode 100644 drivers/net/cxgbe/base/t4_msg.h
 create mode 100644 drivers/net/cxgbe/base/t4_pci_id_tbl.h
 create mode 100644 drivers/net/cxgbe/base/t4_regs.h
 create mode 100644 drivers/net/cxgbe/base/t4_regs_values.h
 create mode 100644 drivers/net/cxgbe/base/t4fw_interface.h

diff --git a/drivers/net/cxgbe/base/adapter.h b/drivers/net/cxgbe/base/adapter.h
new file mode 100644
index 000..0ea1c95
--- /dev/null
+++ b/drivers/net/cxgbe/base/adapter.h
@@ -0,0 +1,565 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2014-2015 Chelsio Communications.
+ *   All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the name of Chelsio Communications nor the names of its
+ *   contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ *   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.
+ */
+
+/* This file should not be included directly.  Include common.h instead. */
+
+#ifndef __T4_ADAPTER_H__
+#define __T4_ADAPTER_H__
+
+#include 
+
+#include "cxgbe_compat.h"
+#include "t4_regs_values.h"
+
+enum {
+   MAX_ETH_QSETS = 64,   /* # of Ethernet Tx/Rx queue sets */
+};
+
+struct adapter;
+struct sge_rspq;
+
+enum {
+   PORT_RSS_DONE = (1 << 0),
+};
+
+struct port_info {
+   struct adapter *adapter;/* adapter that this port belongs to */
+   struct rte_eth_dev *eth_dev;/* associated rte eth device */
+   struct port_stats stats_base;   /* port statistics base */
+   struct link_config link_cfg;/* link configuration info */
+
+   unsigned long flags;/* port related flags */
+   short int xact_addr_filt;   /* index of exact MAC address filter */
+
+   u16viid;/* associated virtual interface id */
+   s8 mdio_addr;   /* address of the PHY */
+   u8 port_type;   /* firmware port type */
+   u8 mod_type;/* firmware module type */
+   u8 port_id; /* physical port ID */
+   u8 tx_chan; /* associated channel */
+
+   u8 n_rx_qsets;  /* # of rx qsets */
+   u8 n_tx_qsets;  /* # of tx qsets */
+   u8 first_qset;  /* index of first qset */
+
+   u16*rss;/* rss table */
+   u8 rss_mode;/* rss mode */
+   u16rss_size

[dpdk-dev] [PATCH v4 2/9] cxgbe: add cxgbe poll mode driver.

2015-06-30 Thread Rahul Lakkireddy
Adds cxgbe poll mode driver for DPDK under drivers/net/cxgbe directory. This
patch:

1. Adds the Makefile to compile cxgbe pmd.
2. Registers and initializes the cxgbe pmd driver.

Enable cxgbe PMD for compilation and linking with changes to:
1. config/common_linuxapp to add macros for cxgbe pmd.
2. drivers/net/Makefile to add cxgbe pmd to the compile list.
3. mk/rte.app.mk to add cxgbe pmd to link.

Update MAINTAINERS file to claim responsibility for the cxgbe PMD.

Signed-off-by: Rahul Lakkireddy 
Signed-off-by: Kumar Sanghvi 
---
v4:
- Moved cxgbe doc entry in MAINTAINERS from patch 2 to patch 9 for consistency.

v3:
- Merge patches 10 and 11 with this patch to enable compilation and update
  MAINTAINERS.  Also, update commit log.
- Add rte_pmd_cxgbe_version.map and add EXPORT_MAP and LIBABIVER to cxgbe
  Makefile.
- Use RTE_DIM macro for calculating ARRAY_SIZE.

v2:
- Move files to new directory under drivers/net/cxgbe and update commit log.
- Move eth_dev_ops to separate patches.
- Update cxgbe Makefile to use relative rather than absolute path of pmd.
- Replace bitwise operations in fls() with gcc's __builtin_clz().
- Fix an issue in adap_init0_tweaks() related to rx_dma_offset.

 MAINTAINERS |   4 +
 config/common_linuxapp  |  10 +
 drivers/net/Makefile|   1 +
 drivers/net/cxgbe/Makefile  |  78 +++
 drivers/net/cxgbe/cxgbe.h   |  48 ++
 drivers/net/cxgbe/cxgbe_compat.h| 266 +++
 drivers/net/cxgbe/cxgbe_ethdev.c| 169 +++
 drivers/net/cxgbe/cxgbe_main.c  | 706 
 drivers/net/cxgbe/rte_pmd_cxgbe_version.map |   4 +
 drivers/net/cxgbe/sge.c | 311 
 mk/rte.app.mk   |   1 +
 11 files changed, 1598 insertions(+)
 create mode 100644 drivers/net/cxgbe/Makefile
 create mode 100644 drivers/net/cxgbe/cxgbe.h
 create mode 100644 drivers/net/cxgbe/cxgbe_compat.h
 create mode 100644 drivers/net/cxgbe/cxgbe_ethdev.c
 create mode 100644 drivers/net/cxgbe/cxgbe_main.c
 create mode 100644 drivers/net/cxgbe/rte_pmd_cxgbe_version.map
 create mode 100644 drivers/net/cxgbe/sge.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 54f0973..ba99f4b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -210,6 +210,10 @@ Linux AF_PACKET
 M: John W. Linville 
 F: drivers/net/af_packet/

+Chelsio cxgbe
+M: Rahul Lakkireddy 
+F: drivers/net/cxgbe/
+
 Cisco enic
 F: drivers/net/enic/

diff --git a/config/common_linuxapp b/config/common_linuxapp
index aae22f4..5a16214 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -213,6 +213,16 @@ CONFIG_RTE_LIBRTE_MLX4_TX_MP_CACHE=8
 CONFIG_RTE_LIBRTE_MLX4_SOFT_COUNTERS=1

 #
+# Compile burst-oriented Chelsio Terminator 10GbE/40GbE (CXGBE) PMD
+#
+CONFIG_RTE_LIBRTE_CXGBE_PMD=y
+CONFIG_RTE_LIBRTE_CXGBE_DEBUG=n
+CONFIG_RTE_LIBRTE_CXGBE_DEBUG_REG=n
+CONFIG_RTE_LIBRTE_CXGBE_DEBUG_MBOX=n
+CONFIG_RTE_LIBRTE_CXGBE_DEBUG_TX=n
+CONFIG_RTE_LIBRTE_CXGBE_DEBUG_RX=n
+
+#
 # Compile burst-oriented Cisco ENIC PMD driver
 #
 CONFIG_RTE_LIBRTE_ENIC_PMD=y
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index 1e6648a..644cacb 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -33,6 +33,7 @@ include $(RTE_SDK)/mk/rte.vars.mk

 DIRS-$(CONFIG_RTE_LIBRTE_PMD_AF_PACKET) += af_packet
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += bonding
+DIRS-$(CONFIG_RTE_LIBRTE_CXGBE_PMD) += cxgbe
 DIRS-$(CONFIG_RTE_LIBRTE_E1000_PMD) += e1000
 DIRS-$(CONFIG_RTE_LIBRTE_ENIC_PMD) += enic
 DIRS-$(CONFIG_RTE_LIBRTE_FM10K_PMD) += fm10k
diff --git a/drivers/net/cxgbe/Makefile b/drivers/net/cxgbe/Makefile
new file mode 100644
index 000..4dfc6b0
--- /dev/null
+++ b/drivers/net/cxgbe/Makefile
@@ -0,0 +1,78 @@
+#   BSD LICENSE
+#
+#   Copyright(c) 2014-2015 Chelsio Communications.
+#   All rights reserved.
+#
+#   Redistribution and use in source and binary forms, with or without
+#   modification, are permitted provided that the following conditions
+#   are met:
+#
+# * Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# * 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.
+# * Neither the name of Chelsio Communications nor the names of its
+#   contributors may be used to endorse or promote products derived
+#   from this software without specific prior written permission.
+#
+#   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

[dpdk-dev] [PATCH v4 3/9] cxgbe: add device configuration and RX support for cxgbe PMD.

2015-06-30 Thread Rahul Lakkireddy
Adds RX support for the cxgbe poll mode driver.  This patch:

1. Adds rx queue related eth_dev_ops.
2. Adds RSS support.
3. Adds dev_configure() and dev_infos_get() eth_dev_ops.
4. Adds rx_pkt_burst for receiving packets.

Signed-off-by: Rahul Lakkireddy 
Signed-off-by: Kumar Sanghvi 
---
v4:
- Fix 32-bit compilation.

v3:
- No changes.

v2:
- This patch is a subset of patch 2/5 submitted in v1.
- Cleanup some RX related macros and code.

 drivers/net/cxgbe/cxgbe.h|   6 +
 drivers/net/cxgbe/cxgbe_ethdev.c | 183 
 drivers/net/cxgbe/cxgbe_main.c   | 350 +++
 drivers/net/cxgbe/sge.c  | 915 +++
 4 files changed, 1454 insertions(+)

diff --git a/drivers/net/cxgbe/cxgbe.h b/drivers/net/cxgbe/cxgbe.h
index 44d48dc..90d1db0 100644
--- a/drivers/net/cxgbe/cxgbe.h
+++ b/drivers/net/cxgbe/cxgbe.h
@@ -44,5 +44,11 @@
 #define CXGBE_DEFAULT_RX_DESC_SIZE1024 /* Default RX ring size */

 int cxgbe_probe(struct adapter *adapter);
+void init_rspq(struct adapter *adap, struct sge_rspq *q, unsigned int us,
+  unsigned int cnt, unsigned int size, unsigned int iqe_size);
+int setup_sge_fwevtq(struct adapter *adapter);
+void cfg_queues(struct rte_eth_dev *eth_dev);
+int cfg_queue_count(struct rte_eth_dev *eth_dev);
+int setup_rss(struct port_info *pi);

 #endif /* _CXGBE_H_ */
diff --git a/drivers/net/cxgbe/cxgbe_ethdev.c b/drivers/net/cxgbe/cxgbe_ethdev.c
index 30d39b4..1c69973 100644
--- a/drivers/net/cxgbe/cxgbe_ethdev.c
+++ b/drivers/net/cxgbe/cxgbe_ethdev.c
@@ -85,7 +85,189 @@
  */
 #include "t4_pci_id_tbl.h"

+static uint16_t cxgbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
+   uint16_t nb_pkts)
+{
+   struct sge_eth_rxq *rxq = (struct sge_eth_rxq *)rx_queue;
+   unsigned int work_done;
+
+   CXGBE_DEBUG_RX(adapter, "%s: rxq->rspq.cntxt_id = %u; nb_pkts = %d\n",
+  __func__, rxq->rspq.cntxt_id, nb_pkts);
+
+   if (cxgbe_poll(>rspq, rx_pkts, (unsigned int)nb_pkts, _done))
+   dev_err(adapter, "error in cxgbe poll\n");
+
+   CXGBE_DEBUG_RX(adapter, "%s: work_done = %u\n", __func__, work_done);
+   return work_done;
+}
+
+static void cxgbe_dev_info_get(struct rte_eth_dev *eth_dev,
+  struct rte_eth_dev_info *device_info)
+{
+   struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private);
+   struct adapter *adapter = pi->adapter;
+   int max_queues = adapter->sge.max_ethqsets / adapter->params.nports;
+
+   device_info->min_rx_bufsize = 68; /* XXX: Smallest pkt size */
+   device_info->max_rx_pktlen = 1500; /* XXX: For now we support mtu */
+   device_info->max_rx_queues = max_queues;
+   device_info->max_tx_queues = max_queues;
+   device_info->max_mac_addrs = 1;
+   /* XXX: For now we support one MAC/port */
+   device_info->max_vfs = adapter->params.arch.vfcount;
+   device_info->max_vmdq_pools = 0; /* XXX: For now no support for VMDQ */
+
+   device_info->rx_offload_capa = DEV_RX_OFFLOAD_VLAN_STRIP |
+  DEV_RX_OFFLOAD_IPV4_CKSUM |
+  DEV_RX_OFFLOAD_UDP_CKSUM |
+  DEV_RX_OFFLOAD_TCP_CKSUM;
+
+   device_info->tx_offload_capa = 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;
+
+   device_info->reta_size = pi->rss_size;
+}
+
+static int cxgbe_dev_rx_queue_start(struct rte_eth_dev *eth_dev,
+   uint16_t tx_queue_id);
+static void cxgbe_dev_rx_queue_release(void *q);
+
+static int cxgbe_dev_configure(struct rte_eth_dev *eth_dev)
+{
+   struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private);
+   struct adapter *adapter = pi->adapter;
+   int err;
+
+   CXGBE_FUNC_TRACE();
+
+   if (!(adapter->flags & FW_QUEUE_BOUND)) {
+   err = setup_sge_fwevtq(adapter);
+   if (err)
+   return err;
+   adapter->flags |= FW_QUEUE_BOUND;
+   }
+
+   err = cfg_queue_count(eth_dev);
+   if (err)
+   return err;
+
+   return 0;
+}
+
+static int cxgbe_dev_rx_queue_start(struct rte_eth_dev *eth_dev,
+   uint16_t rx_queue_id)
+{
+   struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private);
+   struct adapter *adap = pi->adapter;
+   struct sge_rspq *q;
+
+   dev_debug(adapter, "%s: pi->port_id = %d; rx_queue_id = %d\n",
+ __func__, pi->port_id, rx_queue_id);
+

[dpdk-dev] [PATCH v4 4/9] cxgbe: add TX support for cxgbe PMD.

2015-06-30 Thread Rahul Lakkireddy
Adds TX support for the cxgbe poll mode driver.  This patch:

1. Adds tx queue related eth_dev_ops.
2. Adds tx_pkt_burst for transmitting packets.

Signed-off-by: Rahul Lakkireddy 
Signed-off-by: Kumar Sanghvi 
---
v4:
- Remove unused code to fix clang compilation.

v3:
- No changes.

v2:
- This patch is a subset of patch 2/5 submitted in v1.
- Few bug fixes for tx path.

 drivers/net/cxgbe/cxgbe_ethdev.c | 133 ++
 drivers/net/cxgbe/cxgbe_main.c   |   1 +
 drivers/net/cxgbe/sge.c  | 957 +++
 3 files changed, 1091 insertions(+)

diff --git a/drivers/net/cxgbe/cxgbe_ethdev.c b/drivers/net/cxgbe/cxgbe_ethdev.c
index 1c69973..b6e17e4 100644
--- a/drivers/net/cxgbe/cxgbe_ethdev.c
+++ b/drivers/net/cxgbe/cxgbe_ethdev.c
@@ -85,6 +85,39 @@
  */
 #include "t4_pci_id_tbl.h"

+static uint16_t cxgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
+   uint16_t nb_pkts)
+{
+   struct sge_eth_txq *txq = (struct sge_eth_txq *)tx_queue;
+   uint16_t pkts_sent, pkts_remain;
+   uint16_t total_sent = 0;
+   int ret = 0;
+
+   CXGBE_DEBUG_TX(adapter, "%s: txq = %p; tx_pkts = %p; nb_pkts = %d\n",
+  __func__, txq, tx_pkts, nb_pkts);
+
+   t4_os_lock(>txq_lock);
+   /* free up desc from already completed tx */
+   reclaim_completed_tx(>q);
+   while (total_sent < nb_pkts) {
+   pkts_remain = nb_pkts - total_sent;
+
+   for (pkts_sent = 0; pkts_sent < pkts_remain; pkts_sent++) {
+   ret = t4_eth_xmit(txq, tx_pkts[total_sent + pkts_sent]);
+   if (ret < 0)
+   break;
+   }
+   if (!pkts_sent)
+   break;
+   total_sent += pkts_sent;
+   /* reclaim as much as possible */
+   reclaim_completed_tx(>q);
+   }
+
+   t4_os_unlock(>txq_lock);
+   return total_sent;
+}
+
 static uint16_t cxgbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
uint16_t nb_pkts)
 {
@@ -131,8 +164,11 @@ static void cxgbe_dev_info_get(struct rte_eth_dev *eth_dev,
device_info->reta_size = pi->rss_size;
 }

+static int cxgbe_dev_tx_queue_start(struct rte_eth_dev *eth_dev,
+   uint16_t tx_queue_id);
 static int cxgbe_dev_rx_queue_start(struct rte_eth_dev *eth_dev,
uint16_t tx_queue_id);
+static void cxgbe_dev_tx_queue_release(void *q);
 static void cxgbe_dev_rx_queue_release(void *q);

 static int cxgbe_dev_configure(struct rte_eth_dev *eth_dev)
@@ -157,6 +193,98 @@ static int cxgbe_dev_configure(struct rte_eth_dev *eth_dev)
return 0;
 }

+static int cxgbe_dev_tx_queue_start(struct rte_eth_dev *eth_dev,
+   uint16_t tx_queue_id)
+{
+   struct sge_eth_txq *txq = (struct sge_eth_txq *)
+ (eth_dev->data->tx_queues[tx_queue_id]);
+
+   dev_debug(NULL, "%s: tx_queue_id = %d\n", __func__, tx_queue_id);
+
+   return t4_sge_eth_txq_start(txq);
+}
+
+static int cxgbe_dev_tx_queue_stop(struct rte_eth_dev *eth_dev,
+  uint16_t tx_queue_id)
+{
+   struct sge_eth_txq *txq = (struct sge_eth_txq *)
+ (eth_dev->data->tx_queues[tx_queue_id]);
+
+   dev_debug(NULL, "%s: tx_queue_id = %d\n", __func__, tx_queue_id);
+
+   return t4_sge_eth_txq_stop(txq);
+}
+
+static int cxgbe_dev_tx_queue_setup(struct rte_eth_dev *eth_dev,
+   uint16_t queue_idx, uint16_t nb_desc,
+   unsigned int socket_id,
+   const struct rte_eth_txconf *tx_conf)
+{
+   struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private);
+   struct adapter *adapter = pi->adapter;
+   struct sge *s = >sge;
+   struct sge_eth_txq *txq = >ethtxq[pi->first_qset + queue_idx];
+   int err = 0;
+   unsigned int temp_nb_desc;
+
+   RTE_SET_USED(tx_conf);
+
+   dev_debug(adapter, "%s: eth_dev->data->nb_tx_queues = %d; queue_idx = 
%d; nb_desc = %d; socket_id = %d; pi->first_qset = %u\n",
+ __func__, eth_dev->data->nb_tx_queues, queue_idx, nb_desc,
+ socket_id, pi->first_qset);
+
+   /*  Free up the existing queue  */
+   if (eth_dev->data->tx_queues[queue_idx]) {
+   cxgbe_dev_tx_queue_release(eth_dev->data->tx_queues[queue_idx]);
+   eth_dev->data->tx_queues[queue_idx] = NULL;
+   }
+
+   eth_dev->data->tx_queues[queue_idx] = (void *)txq;
+
+   /* Sanity Checking
+*
+* nb_desc should be > 1023 and <= CXGBE_MAX_RING_DESC_SIZE
+*/
+   temp_nb_desc = n

[dpdk-dev] [PATCH v4 6/9] cxgbe: add port statistics for cxgbe PMD.

2015-06-30 Thread Rahul Lakkireddy
Adds stats_get() and stats_reset() eth_dev_ops for cxgbe poll mode driver.

Signed-off-by: Rahul Lakkireddy 
Signed-off-by: Kumar Sanghvi 
---
v4:
- No changes.

v3:
- No changes.

v2:
- This patch is a subset of patch 2/5 submitted in v1.

 drivers/net/cxgbe/cxgbe.h|  2 +
 drivers/net/cxgbe/cxgbe_ethdev.c | 83 
 drivers/net/cxgbe/cxgbe_main.c   | 11 ++
 3 files changed, 96 insertions(+)

diff --git a/drivers/net/cxgbe/cxgbe.h b/drivers/net/cxgbe/cxgbe.h
index bf08baf..97c37d2 100644
--- a/drivers/net/cxgbe/cxgbe.h
+++ b/drivers/net/cxgbe/cxgbe.h
@@ -47,6 +47,8 @@ int cxgbe_probe(struct adapter *adapter);
 int cxgbe_up(struct adapter *adap);
 int cxgbe_down(struct port_info *pi);
 void cxgbe_close(struct adapter *adapter);
+void cxgbe_stats_get(struct port_info *pi, struct port_stats *stats);
+void cxgbe_stats_reset(struct port_info *pi);
 int link_start(struct port_info *pi);
 void init_rspq(struct adapter *adap, struct sge_rspq *q, unsigned int us,
   unsigned int cnt, unsigned int size, unsigned int iqe_size);
diff --git a/drivers/net/cxgbe/cxgbe_ethdev.c b/drivers/net/cxgbe/cxgbe_ethdev.c
index cb100fc..600a16c 100644
--- a/drivers/net/cxgbe/cxgbe_ethdev.c
+++ b/drivers/net/cxgbe/cxgbe_ethdev.c
@@ -500,6 +500,87 @@ static void cxgbe_dev_rx_queue_release(void *q)
}
 }

+/*
+ * Get port statistics.
+ */
+static void cxgbe_dev_stats_get(struct rte_eth_dev *eth_dev,
+   struct rte_eth_stats *eth_stats)
+{
+   struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private);
+   struct adapter *adapter = pi->adapter;
+   struct sge *s = >sge;
+   struct port_stats ps;
+   unsigned int i;
+
+   cxgbe_stats_get(pi, );
+
+   /* RX Stats */
+   eth_stats->ipackets = ps.rx_frames;
+   eth_stats->ibytes   = ps.rx_octets;
+   eth_stats->imcasts  = ps.rx_mcast_frames;
+   eth_stats->imissed  = ps.rx_ovflow0 + ps.rx_ovflow1 +
+ ps.rx_ovflow2 + ps.rx_ovflow3 +
+ ps.rx_trunc0 + ps.rx_trunc1 +
+ ps.rx_trunc2 + ps.rx_trunc3;
+   eth_stats->ibadcrc  = ps.rx_fcs_err;
+   eth_stats->ibadlen  = ps.rx_jabber + ps.rx_too_long + ps.rx_runt;
+   eth_stats->ierrors  = ps.rx_symbol_err + eth_stats->ibadcrc +
+ eth_stats->ibadlen + ps.rx_len_err +
+ eth_stats->imissed;
+   eth_stats->rx_pause_xon  = ps.rx_pause;
+
+   /* TX Stats */
+   eth_stats->opackets = ps.tx_frames;
+   eth_stats->obytes   = ps.tx_octets;
+   eth_stats->oerrors  = ps.tx_error_frames;
+   eth_stats->tx_pause_xon  = ps.tx_pause;
+
+   for (i = 0; i < pi->n_rx_qsets; i++) {
+   struct sge_eth_rxq *rxq =
+   >ethrxq[pi->first_qset + i];
+
+   eth_stats->q_ipackets[i] = rxq->stats.pkts;
+   eth_stats->q_ibytes[i] = rxq->stats.rx_bytes;
+   }
+
+   for (i = 0; i < pi->n_tx_qsets; i++) {
+   struct sge_eth_txq *txq =
+   >ethtxq[pi->first_qset + i];
+
+   eth_stats->q_opackets[i] = txq->stats.pkts;
+   eth_stats->q_obytes[i] = txq->stats.tx_bytes;
+   eth_stats->q_errors[i] = txq->stats.mapping_err;
+   }
+}
+
+/*
+ * Reset port statistics.
+ */
+static void cxgbe_dev_stats_reset(struct rte_eth_dev *eth_dev)
+{
+   struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private);
+   struct adapter *adapter = pi->adapter;
+   struct sge *s = >sge;
+   unsigned int i;
+
+   cxgbe_stats_reset(pi);
+   for (i = 0; i < pi->n_rx_qsets; i++) {
+   struct sge_eth_rxq *rxq =
+   >ethrxq[pi->first_qset + i];
+
+   rxq->stats.pkts = 0;
+   rxq->stats.rx_bytes = 0;
+   }
+   for (i = 0; i < pi->n_tx_qsets; i++) {
+   struct sge_eth_txq *txq =
+   >ethtxq[pi->first_qset + i];
+
+   txq->stats.pkts = 0;
+   txq->stats.tx_bytes = 0;
+   txq->stats.mapping_err = 0;
+   }
+}
+
 static struct eth_dev_ops cxgbe_eth_dev_ops = {
.dev_start  = cxgbe_dev_start,
.dev_stop   = cxgbe_dev_stop,
@@ -514,6 +595,8 @@ static struct eth_dev_ops cxgbe_eth_dev_ops = {
.rx_queue_start = cxgbe_dev_rx_queue_start,
.rx_queue_stop  = cxgbe_dev_rx_queue_stop,
.rx_queue_release   = cxgbe_dev_rx_queue_release,
+   .stats_get  = cxgbe_dev_stats_get,
+   .stats_reset= cxgbe_dev_stats_reset,
 };

 /*
diff --git a/drivers/net/cxgbe/cxgbe_main.c b/drivers/net/cxgbe/cxgbe_main.c
index 7995d3c..dad0a98 1006

[dpdk-dev] [PATCH v4 7/9] cxgbe: add link related functions for cxgbe PMD.

2015-06-30 Thread Rahul Lakkireddy
Adds link update, promiscuous and multicast related eth_dev_ops for cxgbe poll
mode driver.

Signed-off-by: Rahul Lakkireddy 
Signed-off-by: Kumar Sanghvi 
---
v4:
- No changes.

v3:
- No changes.

v2:
- This patch is a subset of patch 2/5 submitted in v1.
- Update cxgbe_dev_link_update() to return correct value.

 drivers/net/cxgbe/cxgbe_ethdev.c | 66 
 1 file changed, 66 insertions(+)

diff --git a/drivers/net/cxgbe/cxgbe_ethdev.c b/drivers/net/cxgbe/cxgbe_ethdev.c
index 600a16c..c0dd5f3 100644
--- a/drivers/net/cxgbe/cxgbe_ethdev.c
+++ b/drivers/net/cxgbe/cxgbe_ethdev.c
@@ -164,6 +164,67 @@ static void cxgbe_dev_info_get(struct rte_eth_dev *eth_dev,
device_info->reta_size = pi->rss_size;
 }

+static void cxgbe_dev_promiscuous_enable(struct rte_eth_dev *eth_dev)
+{
+   struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private);
+   struct adapter *adapter = pi->adapter;
+
+   t4_set_rxmode(adapter, adapter->mbox, pi->viid, -1,
+ 1, -1, 1, -1, false);
+}
+
+static void cxgbe_dev_promiscuous_disable(struct rte_eth_dev *eth_dev)
+{
+   struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private);
+   struct adapter *adapter = pi->adapter;
+
+   t4_set_rxmode(adapter, adapter->mbox, pi->viid, -1,
+ 0, -1, 1, -1, false);
+}
+
+static void cxgbe_dev_allmulticast_enable(struct rte_eth_dev *eth_dev)
+{
+   struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private);
+   struct adapter *adapter = pi->adapter;
+
+   /* TODO: address filters ?? */
+
+   t4_set_rxmode(adapter, adapter->mbox, pi->viid, -1,
+ -1, 1, 1, -1, false);
+}
+
+static void cxgbe_dev_allmulticast_disable(struct rte_eth_dev *eth_dev)
+{
+   struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private);
+   struct adapter *adapter = pi->adapter;
+
+   /* TODO: address filters ?? */
+
+   t4_set_rxmode(adapter, adapter->mbox, pi->viid, -1,
+ -1, 0, 1, -1, false);
+}
+
+static int cxgbe_dev_link_update(struct rte_eth_dev *eth_dev,
+__rte_unused int wait_to_complete)
+{
+   struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private);
+   struct adapter *adapter = pi->adapter;
+   struct sge *s = >sge;
+   struct rte_eth_link *old_link = _dev->data->dev_link;
+   unsigned int work_done, budget = 4;
+
+   cxgbe_poll(>fw_evtq, NULL, budget, _done);
+   if (old_link->link_status == pi->link_cfg.link_ok)
+   return -1;  /* link not changed */
+
+   eth_dev->data->dev_link.link_status = pi->link_cfg.link_ok;
+   eth_dev->data->dev_link.link_duplex = ETH_LINK_FULL_DUPLEX;
+   eth_dev->data->dev_link.link_speed = pi->link_cfg.speed;
+
+   /* link has changed */
+   return 0;
+}
+
 static int cxgbe_dev_tx_queue_start(struct rte_eth_dev *eth_dev,
uint16_t tx_queue_id);
 static int cxgbe_dev_rx_queue_start(struct rte_eth_dev *eth_dev,
@@ -585,8 +646,13 @@ static struct eth_dev_ops cxgbe_eth_dev_ops = {
.dev_start  = cxgbe_dev_start,
.dev_stop   = cxgbe_dev_stop,
.dev_close  = cxgbe_dev_close,
+   .promiscuous_enable = cxgbe_dev_promiscuous_enable,
+   .promiscuous_disable= cxgbe_dev_promiscuous_disable,
+   .allmulticast_enable= cxgbe_dev_allmulticast_enable,
+   .allmulticast_disable   = cxgbe_dev_allmulticast_disable,
.dev_configure  = cxgbe_dev_configure,
.dev_infos_get  = cxgbe_dev_info_get,
+   .link_update= cxgbe_dev_link_update,
.tx_queue_setup = cxgbe_dev_tx_queue_setup,
.tx_queue_start = cxgbe_dev_tx_queue_start,
.tx_queue_stop  = cxgbe_dev_tx_queue_stop,
-- 
2.4.1



[dpdk-dev] [PATCH v4 8/9] cxgbe: add flow control functions for cxgbe PMD.

2015-06-30 Thread Rahul Lakkireddy
Adds flow control related eth_dev_ops for cxgbe poll mode driver.

Signed-off-by: Rahul Lakkireddy 
Signed-off-by: Kumar Sanghvi 
---
v4:
- No changes.

v3:
- No changes.

v2:
- This patch is a subset of patch 2/5 submitted in v1.

 drivers/net/cxgbe/cxgbe_ethdev.c | 54 
 1 file changed, 54 insertions(+)

diff --git a/drivers/net/cxgbe/cxgbe_ethdev.c b/drivers/net/cxgbe/cxgbe_ethdev.c
index c0dd5f3..478051a 100644
--- a/drivers/net/cxgbe/cxgbe_ethdev.c
+++ b/drivers/net/cxgbe/cxgbe_ethdev.c
@@ -642,6 +642,58 @@ static void cxgbe_dev_stats_reset(struct rte_eth_dev 
*eth_dev)
}
 }

+static int cxgbe_flow_ctrl_get(struct rte_eth_dev *eth_dev,
+  struct rte_eth_fc_conf *fc_conf)
+{
+   struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private);
+   struct link_config *lc = >link_cfg;
+   int rx_pause, tx_pause;
+
+   fc_conf->autoneg = lc->fc & PAUSE_AUTONEG;
+   rx_pause = lc->fc & PAUSE_RX;
+   tx_pause = lc->fc & PAUSE_TX;
+
+   if (rx_pause && tx_pause)
+   fc_conf->mode = RTE_FC_FULL;
+   else if (rx_pause)
+   fc_conf->mode = RTE_FC_RX_PAUSE;
+   else if (tx_pause)
+   fc_conf->mode = RTE_FC_TX_PAUSE;
+   else
+   fc_conf->mode = RTE_FC_NONE;
+   return 0;
+}
+
+static int cxgbe_flow_ctrl_set(struct rte_eth_dev *eth_dev,
+  struct rte_eth_fc_conf *fc_conf)
+{
+   struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private);
+   struct adapter *adapter = pi->adapter;
+   struct link_config *lc = >link_cfg;
+
+   if (lc->supported & FW_PORT_CAP_ANEG) {
+   if (fc_conf->autoneg)
+   lc->requested_fc |= PAUSE_AUTONEG;
+   else
+   lc->requested_fc &= ~PAUSE_AUTONEG;
+   }
+
+   if (((fc_conf->mode & RTE_FC_FULL) == RTE_FC_FULL) ||
+   (fc_conf->mode & RTE_FC_RX_PAUSE))
+   lc->requested_fc |= PAUSE_RX;
+   else
+   lc->requested_fc &= ~PAUSE_RX;
+
+   if (((fc_conf->mode & RTE_FC_FULL) == RTE_FC_FULL) ||
+   (fc_conf->mode & RTE_FC_TX_PAUSE))
+   lc->requested_fc |= PAUSE_TX;
+   else
+   lc->requested_fc &= ~PAUSE_TX;
+
+   return t4_link_l1cfg(adapter, adapter->mbox, pi->tx_chan,
+>link_cfg);
+}
+
 static struct eth_dev_ops cxgbe_eth_dev_ops = {
.dev_start  = cxgbe_dev_start,
.dev_stop   = cxgbe_dev_stop,
@@ -663,6 +715,8 @@ static struct eth_dev_ops cxgbe_eth_dev_ops = {
.rx_queue_release   = cxgbe_dev_rx_queue_release,
.stats_get  = cxgbe_dev_stats_get,
.stats_reset= cxgbe_dev_stats_reset,
+   .flow_ctrl_get  = cxgbe_flow_ctrl_get,
+   .flow_ctrl_set  = cxgbe_flow_ctrl_set,
 };

 /*
-- 
2.4.1



[dpdk-dev] [PATCH v4 9/9] doc: add cxgbe PMD documentation under doc/guides/nics/cxgbe.rst

2015-06-30 Thread Rahul Lakkireddy
Adds cxgbe poll mode driver documentation under the usual doc/guides/nics/
directory with the rest of the drivers.  The documentation covers cxgbe
implementation details, features and limitations, prerequisites, configuration,
and a sample application usage.

Signed-off-by: Rahul Lakkireddy 
Signed-off-by: Kumar Sanghvi 
---
v4:
- Add cxgbe doc entry to MAINTAINERS.

v3:
- No changes.

v2:
- Move cxgbe entry to Drivers section in source_org.rst.
- Order the cxgbe entry alphabetically in index.rst.

 MAINTAINERS  |   1 +
 doc/guides/nics/cxgbe.rst| 209 +++
 doc/guides/nics/index.rst|   1 +
 doc/guides/prog_guide/source_org.rst |   1 +
 4 files changed, 212 insertions(+)
 create mode 100644 doc/guides/nics/cxgbe.rst

diff --git a/MAINTAINERS b/MAINTAINERS
index ba99f4b..659672e 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -213,6 +213,7 @@ F: drivers/net/af_packet/
 Chelsio cxgbe
 M: Rahul Lakkireddy 
 F: drivers/net/cxgbe/
+F: doc/guides/nics/cxgbe.rst

 Cisco enic
 F: drivers/net/enic/
diff --git a/doc/guides/nics/cxgbe.rst b/doc/guides/nics/cxgbe.rst
new file mode 100644
index 000..54a019d
--- /dev/null
+++ b/doc/guides/nics/cxgbe.rst
@@ -0,0 +1,209 @@
+..  BSD LICENSE
+Copyright 2015 Chelsio Communications.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+* Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+* 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.
+* Neither the name of Chelsio Communications nor the names of its
+contributors may be used to endorse or promote products derived
+from this software without specific prior written permission.
+
+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.
+
+CXGBE Poll Mode Driver
+==
+
+The CXGBE PMD (**librte_pmd_cxgbe**) provides poll mode driver support
+for **Chelsio T5** 10/40 Gbps family of adapters.
+
+More information can be found at `Chelsio Communications
+<http://www.chelsio.com>`_.
+
+Features
+
+
+CXGBE PMD has the support for:
+
+- Multiple queues for TX and RX.
+- Receiver Side Steering (RSS).
+- VLAN filtering.
+- Checksum offload.
+- Promiscuous mode.
+- All multicast mode.
+- Port hardware statistics.
+
+Limitations
+---
+
+The Chelsio T5 devices provide two/four ports but expose a single PCI bus
+address, thus, librte_pmd_cxgbe registers itself as a
+PCI driver that allocates one Ethernet device per detected port.
+
+For this reason, one cannot white/blacklist a single port without also
+white/blacklisting the others on the same device.
+
+Configuration
+-
+
+Compiling CXGBE PMD
+~~~
+
+These options can be modified in the ``.config`` file.
+
+- ``CONFIG_RTE_LIBRTE_CXGBE_PMD`` (default **y**)
+
+  Toggle compilation of librte_pmd_cxgbe driver.
+
+- ``CONFIG_RTE_LIBRTE_CXGBE_DEBUG`` (default **n**)
+
+  Toggle debugging code. Enabling this option adds additional generic debugging
+  messages at the cost of lower performance.
+
+- ``CONFIG_RTE_LIBRTE_CXGBE_DEBUG_REG`` (default **n**)
+
+  Toggle debugging code. Enabling this option adds additional registers related
+  run-time checks and debugging messages at the cost of lower performance.
+
+- ``CONFIG_RTE_LIBRTE_CXGBE_DEBUG_MBOX`` (default **n**)
+
+  Toggle debugging code. Enabling this option adds additional firmware mailbox
+  related run-time checks and debugging messages at the cost of lower
+  performance.
+
+- ``CONFIG_RTE_LIBRTE_CXGBE_DEBUG_TX`` (default **n**)
+
+  Toggle debugging code. Enabling this option adds additional transmission data
+  path run-time checks and debugging messages at the cost of lower performance.
+
+- ``CONFIG_RTE_LIBRTE_CXGBE_DEBUG_RX`` (default **n**)
+
+  Toggle debugging code. Enabling this option adds additional receiving data
+  path

[dpdk-dev] [PATCH v4 0/9] Chelsio Terminator 5 (T5) 10G/40G Poll Mode Driver

2015-07-01 Thread Rahul Lakkireddy
On Tue, Jun 30, 2015 at 23:01:39 +0200, Thomas Monjalon wrote:
> 2015-06-30 04:58, Rahul Lakkireddy:
> > This series of patches add the CXGBE Poll Mode Driver support for Chelsio
> > Terminator 5 series of 10G/40G adapters.  The CXGBE PMD is split into 
> > multiple
> > patches.  The first patch adds the hardware specific api for all supported
> > Chelsio T5 adapters and the patches from 2 to 8 add the actual DPDK CXGBE 
> > PMD.
> > 
> > Also, the CXGBE PMD is enabled for compilation and linking by patch 2.
> > MAINTAINERS file is also updated by patch 2 to claim responsibility for the
> > CXGBE PMD.
> > 
> > More information on the CXGBE PMD can be found in the documentation added by
> > patch 9.  
> > 
> > v4:
> > - Fix 32-bit and clang compilation.
> > - Moved cxgbe doc entry in MAINTAINERS from patch 2 to patch 9 for 
> > consistency.
> > 
> > v3:
> > - Merge patches 10 and 11 with patch 2.
> > - Add rte_pmd_cxgbe_version.map and add EXPORT_MAP and LIBABIVER to cxgbe
> >   Makefile.
> > - Use RTE_DIM macro for calculating ARRAY_SIZE.
> > 
> > v2:
> > - Move the driver to drivers/net directory and update all config files and
> >   commit logs.  Also update MAINTAINERS.
> > - Break the second patch into more patches; incrementally, adding features 
> > to
> >   the cxgbe poll mode driver.
> > - Replace bitwise operations in finding last (most significant) bit set with
> >   gcc's __builtin_clz.
> > - Fix the return value returned by link update eth_dev operation.
> > - Few bug fixes and code cleanup.
> > 
> > Rahul Lakkireddy (9):
> >   cxgbe: add hardware specific api for all supported Chelsio T5 series
> > adapters.
> >   cxgbe: add cxgbe poll mode driver.
> >   cxgbe: add device configuration and RX support for cxgbe PMD.
> >   cxgbe: add TX support for cxgbe PMD.
> >   cxgbe: add device related operations for cxgbe PMD.
> >   cxgbe: add port statistics for cxgbe PMD.
> >   cxgbe: add link related functions for cxgbe PMD.
> >   cxgbe: add flow control functions for cxgbe PMD.
> >   doc: add cxgbe PMD documentation under doc/guides/nics/cxgbe.rst
> 
> Applied, thanks for the good work and welcome :)

Thank you very much.  We are very glad to be on board.

Thanks,
Rahul


[dpdk-dev] [PATCH v2] vfio: Fix overflow while assigning vfio BAR region offset and size

2015-07-07 Thread Rahul Lakkireddy
Hi Alejandro,

On Mon, Jul 06, 2015 at 16:45:01 +0100, Alejandro Lucero wrote:
> Hi all,
> 
> From the kernel VFIO maintainer:
> 
> "I suppose in the short term, mmap should not be advertised as available
> on 32bit hosts.  Thanks,"
> 
> So, as VFIO support for 32bit systems is broken, DPDK should not configure
> VFIO in that case.
> 

Thank you very much for the clarification.

> 
> If we need to support 4G BARs, our only choice is really to extend the
> vfio region support for a separate file descriptor per region.  The only
> devices I'm aware of with 4G BARs are Nvidia Tesla.  This is possible,
> but I would expect such devices would be extremely rare on 32bit hosts.
> 

Our Chelsio T5 cards can also have 4G bar size. So, it seems this won't work
on 32-bit with current state of kernel vfio driver.

Nevertheless, updating your patch with below diff works fine on 64-bit
for vfio testing on Chelsio T5 cards and it compiles for 32-bit targets
as well.


diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c 
b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
index 426953a..6127f5f 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
@@ -728,7 +728,7 @@ pci_vfio_map_resource(struct rte_pci_device *dev)
struct vfio_region_info reg = { .argsz = sizeof(reg) };
void *bar_addr;
struct memreg {
-   uint32_t offset, size;
+   unsigned long offset, size;
} memreg[2] = {};

reg.index = i;
@@ -771,7 +771,7 @@ pci_vfio_map_resource(struct rte_pci_device *dev)
RTE_LOG(DEBUG, EAL,
"Trying to map BAR %d that contains the 
MSI-X "
"table. Trying offsets: "
-   "%04x:%04x, %04x:%04x\n", i,
+   "0x%04lx:0x%04lx, 0x%04lx:0x%04lx\n", i,
memreg[0].offset, memreg[0].size,
memreg[1].offset, memreg[1].size);
}


Thanks,
Rahul


[dpdk-dev] [PATCH 0/3] cxgbe: RX perf fixes, doc update, and add support for more devices

2015-07-07 Thread Rahul Lakkireddy
This series of patches do the following:
1. RX performance fixes for cxgbe Poll Mode Driver.
2. Add more supported Chelsio T5 device ids.
3. Update cxgbe documentation to include instructions on how to flash
   firmware and enable/disable flow control. Also, provide a list of
   supported Chelsio T5 devices.

Rahul Lakkireddy (3):
  cxgbe: Fix RX performance for cxgbe PMD.
  cxgbe: Add more supported Chelsio T5 devices.
  doc: Update cxgbe documentation

 doc/guides/nics/cxgbe.rst   |  84 ++-
 drivers/net/cxgbe/base/adapter.h|   2 +
 drivers/net/cxgbe/base/t4_pci_id_tbl.h  |   3 +
 drivers/net/cxgbe/base/t4_regs_values.h |   1 +
 drivers/net/cxgbe/sge.c | 239 
 5 files changed, 175 insertions(+), 154 deletions(-)

-- 
2.4.1



[dpdk-dev] [PATCH 1/3] cxgbe: Fix RX performance for cxgbe PMD.

2015-07-07 Thread Rahul Lakkireddy
CXGBE PMD rx allocates a new mbuf everytime, which could lead to performance
hit.  Instead, do bulk allocation of mbufs and re-use them.

Also, simplify the overall rx-handler, and update its logic to fix rx perf.

Signed-off-by: Rahul Lakkireddy 
Signed-off-by: Kumar Sanghvi 
---
 drivers/net/cxgbe/base/adapter.h|   2 +
 drivers/net/cxgbe/base/t4_regs_values.h |   1 +
 drivers/net/cxgbe/sge.c | 239 
 3 files changed, 89 insertions(+), 153 deletions(-)

diff --git a/drivers/net/cxgbe/base/adapter.h b/drivers/net/cxgbe/base/adapter.h
index 0ea1c95..a1e8ef7 100644
--- a/drivers/net/cxgbe/base/adapter.h
+++ b/drivers/net/cxgbe/base/adapter.h
@@ -149,6 +149,7 @@ struct sge_rspq {   /* state for an SGE 
response queue */
unsigned int bar2_qid;  /* Queue ID for BAR2 Queue registers */

unsigned int cidx;  /* consumer index */
+   unsigned int gts_idx;   /* last gts write sent */
unsigned int iqe_len;   /* entry size */
unsigned int size;  /* capacity of response queue */
int offset; /* offset into current Rx buffer */
@@ -157,6 +158,7 @@ struct sge_rspq {   /* state for an SGE 
response queue */
u8 intr_params; /* interrupt holdoff parameters */
u8 next_intr_params;/* holdoff params for next interrupt */
u8 pktcnt_idx;  /* interrupt packet threshold */
+   u8 port_id; /* associated port-id */
u8 idx; /* queue index within its group */
u16 cntxt_id;   /* SGE relative QID for the response Q */
u16 abs_id; /* absolute SGE id for the response q */
diff --git a/drivers/net/cxgbe/base/t4_regs_values.h 
b/drivers/net/cxgbe/base/t4_regs_values.h
index 181bd9d..d7d3144 100644
--- a/drivers/net/cxgbe/base/t4_regs_values.h
+++ b/drivers/net/cxgbe/base/t4_regs_values.h
@@ -68,6 +68,7 @@
  * Egress Context field values
  */
 #define X_FETCHBURSTMIN_64B2
+#define X_FETCHBURSTMIN_128B   3
 #define X_FETCHBURSTMAX_256B   2
 #define X_FETCHBURSTMAX_512B   3

diff --git a/drivers/net/cxgbe/sge.c b/drivers/net/cxgbe/sge.c
index 359296e..b737183 100644
--- a/drivers/net/cxgbe/sge.c
+++ b/drivers/net/cxgbe/sge.c
@@ -74,7 +74,7 @@ static inline void ship_tx_pkt_coalesce_wr(struct adapter 
*adap,
 /*
  * Max number of Rx buffers we replenish at a time.
  */
-#define MAX_RX_REFILL 16U
+#define MAX_RX_REFILL 64U

 #define NOMEM_TMR_IDX (SGE_NTIMERS - 1)

@@ -238,39 +238,6 @@ static inline bool fl_starving(const struct adapter 
*adapter,
return fl->avail - fl->pend_cred <= s->fl_starve_thres;
 }

-static inline unsigned int get_buf_size(struct adapter *adapter,
-   const struct rx_sw_desc *d)
-{
-   struct sge *s = >sge;
-   unsigned int rx_buf_size_idx = d->dma_addr & RX_BUF_SIZE;
-   unsigned int buf_size;
-
-   switch (rx_buf_size_idx) {
-   case RX_SMALL_PG_BUF:
-   buf_size = PAGE_SIZE;
-   break;
-
-   case RX_LARGE_PG_BUF:
-   buf_size = PAGE_SIZE << s->fl_pg_order;
-   break;
-
-   case RX_SMALL_MTU_BUF:
-   buf_size = FL_MTU_SMALL_BUFSIZE(adapter);
-   break;
-
-   case RX_LARGE_MTU_BUF:
-   buf_size = FL_MTU_LARGE_BUFSIZE(adapter);
-   break;
-
-   default:
-   BUG_ON(1);
-   buf_size = 0; /* deal with bogus compiler warnings */
-   /* NOTREACHED */
-   }
-
-   return buf_size;
-}
-
 /**
  * free_rx_bufs - free the Rx buffers on an SGE free list
  * @q: the SGE free list to free buffers from
@@ -319,7 +286,8 @@ static void unmap_rx_buf(struct sge_fl *q)

 static inline void ring_fl_db(struct adapter *adap, struct sge_fl *q)
 {
-   if (q->pend_cred >= 8) {
+   /* see if we have exceeded q->size / 4 */
+   if (q->pend_cred >= (q->size / 4)) {
u32 val = adap->params.arch.sge_fl_db;

if (is_t4(adap->params.chip))
@@ -356,15 +324,6 @@ static inline void ring_fl_db(struct adapter *adap, struct 
sge_fl *q)
}
 }

-static inline struct rte_mbuf *cxgbe_rxmbuf_alloc(struct rte_mempool *mp)
-{
-   struct rte_mbuf *m;
-
-   m = __rte_mbuf_raw_alloc(mp);
-   __rte_mbuf_sanity_check_raw(m, 0);
-   return m;
-}
-
 static inline void set_rx_sw_desc(struct rx_sw_desc *sd, void *buf,
  dma_addr_t mapping)
 {
@@ -393,9 +352,20 @@ static unsigned int refill_fl_usembufs(struct adapter 
*adap, struct sge_fl *q,
__be64 *d = >desc[q->pidx];
struct rx_sw_desc *sd = >sdesc[q->pidx];
unsigned int buf_size_idx = RX_SMALL_MTU_BUF;
+   struct rte_mbuf *buf_bulk[n];
+   int r

[dpdk-dev] [PATCH 2/3] cxgbe: Add more supported Chelsio T5 devices.

2015-07-07 Thread Rahul Lakkireddy
Update pci id table to include more supported Chelsio T5 devices.

Signed-off-by: Rahul Lakkireddy 
Signed-off-by: Kumar Sanghvi 
---
 drivers/net/cxgbe/base/t4_pci_id_tbl.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/cxgbe/base/t4_pci_id_tbl.h 
b/drivers/net/cxgbe/base/t4_pci_id_tbl.h
index ea72edf..110fadb 100644
--- a/drivers/net/cxgbe/base/t4_pci_id_tbl.h
+++ b/drivers/net/cxgbe/base/t4_pci_id_tbl.h
@@ -141,6 +141,9 @@ CH_PCI_DEVICE_ID_TABLE_DEFINE_BEGIN
CH_PCI_ID_TABLE_FENTRY(0x5087), /* Custom T580-CR */
CH_PCI_ID_TABLE_FENTRY(0x5088), /* Custom T570-CR */
CH_PCI_ID_TABLE_FENTRY(0x5089), /* Custom T520-CR */
+   CH_PCI_ID_TABLE_FENTRY(0x5090), /* Custom T540-CR */
+   CH_PCI_ID_TABLE_FENTRY(0x5091), /* Custom T522-CR */
+   CH_PCI_ID_TABLE_FENTRY(0x5092), /* Custom T520-CR */
 CH_PCI_DEVICE_ID_TABLE_DEFINE_END;

 #endif /* CH_PCI_DEVICE_ID_TABLE_DEFINE_BEGIN */
-- 
2.4.1



[dpdk-dev] [PATCH 3/3] doc: Update cxgbe documentation

2015-07-07 Thread Rahul Lakkireddy
Update cxgbe documentation with the following:
1. Add instructions on how to flash firmware and config file on Chelsio T5
   devices.
2. Add a list of supported devices.
3. Add instructions on how to enable and disable flow control via testpmd.

Signed-off-by: Rahul Lakkireddy 
Signed-off-by: Kumar Sanghvi 
---
 doc/guides/nics/cxgbe.rst | 84 ++-
 1 file changed, 83 insertions(+), 1 deletion(-)

diff --git a/doc/guides/nics/cxgbe.rst b/doc/guides/nics/cxgbe.rst
index 54a019d..6ac5e07 100644
--- a/doc/guides/nics/cxgbe.rst
+++ b/doc/guides/nics/cxgbe.rst
@@ -102,7 +102,72 @@ Prerequisites
 -

 - Requires firmware version **1.13.32.0** and higher. Visit
-  `Chelsio Communications <http://www.chelsio.com>`_ to get latest firmware.
+  `Chelsio Download Center <http://service.chelsio.com>`_ to get latest 
firmware
+  bundled with the latest Chelsio Unified Wire package. Installing and loading
+  the latest cxgb4 kernel driver from the Chelsio Unified Wire package should
+  get you the latest firmware. More information can be obtained from the User
+  Guide that is bundled with the Chelsio Unified Wire package.
+
+Steps to manually install the latest firmware from the downloaded source files
+are as follows:
+
+#. Load the kernel module:
+
+   .. code-block:: console
+
+  modprobe cxgb4
+
+#. Use ifconfig to get the interface name assigned to Chelsio card:
+
+   .. code-block:: console
+
+  ifconfig -a | grep "00:07:43"
+
+   Example output:
+
+   .. code-block:: console
+
+  p1p1  Link encap:Ethernet  HWaddr 00:07:43:2D:EA:C0
+  p1p2  Link encap:Ethernet  HWaddr 00:07:43:2D:EA:C8
+
+#. Install cxgbtool:
+
+   .. code-block:: console
+
+  cd /tools/cxgbtool
+  make install
+
+#. Use cxgbtool to load the firmware config file onto the card:
+
+   .. code-block:: console
+
+  cxgbtool p1p1 loadcfg /src/network/firmware/t5-config.txt
+
+#. Use cxgbtool to load the firmware image onto the card:
+
+   .. code-block:: console
+
+  cxgbtool p1p1 loadfw /src/network/firmware/t5fw-*.bin
+
+#. Verify with ethtool:
+
+   .. code-block:: console
+
+  ethtool -i p1p1 | grep "firmware"
+
+   Example output:
+
+   .. code-block:: console
+
+  firmware-version: 1.13.32.0, TP 0.1.4.8
+
+Supported Chelsio T5 NICs
+-
+
+- 1G NICs: T502-BT
+- 10G NICs: T520-BT, T520-CR, T520-LL-CR, T520-SO-CR, T540-CR
+- 40G NICs: T580-CR, T580-LP-CR, T580-SO-CR
+- Other T5 NICs: T522-CR

 Sample Application Notes
 -
@@ -207,3 +272,20 @@ devices managed by librte_pmd_cxgbe.
   Port 1 Link Up - speed 1 Mbps - full-duplex
   Done
   testpmd>
+
+.. note::
+
+   Flow control pause TX/RX is disabled by default and can be enabled via
+   testpmd as follows:
+
+   .. code-block:: console
+
+  testpmd> set flow_ctrl rx on tx on 0 0 0 0 mac_ctrl_frame_fwd off 
autoneg on 0
+  testpmd> set flow_ctrl rx on tx on 0 0 0 0 mac_ctrl_frame_fwd off 
autoneg on 1
+
+   To disable again, use:
+
+   .. code-block:: console
+
+  testpmd> set flow_ctrl rx off tx off 0 0 0 0 mac_ctrl_frame_fwd off 
autoneg off 0
+  testpmd> set flow_ctrl rx off tx off 0 0 0 0 mac_ctrl_frame_fwd off 
autoneg off 1
-- 
2.4.1



[dpdk-dev] [PATCH 1/3] cxgbe: Fix RX performance for cxgbe PMD.

2015-07-09 Thread Rahul Lakkireddy
Hi Thomas,

On Tue, Jul 07, 2015 at 23:30:38 +0200, Thomas Monjalon wrote:
> 2015-07-07 22:42, Rahul Lakkireddy:
> > CXGBE PMD rx allocates a new mbuf everytime, which could lead to performance
> > hit.  Instead, do bulk allocation of mbufs and re-use them.
> > 
> > Also, simplify the overall rx-handler, and update its logic to fix rx perf.
> 
> For such change, it would be nice to provide some benchmark numbers.
> Thanks

On my setup having T580-CR card which is 2-port 40G, I see Rx PPS improving for
64 byte size from ~25Mpps to ~37Mpps on single port.  Similarly, roughly 10
Mpps improvement is seen for dual port also.

And for IO size 128 bytes, approx. 3Mpps improvement is seen.
Of course, my setup is not a powerful one as used by our QA team.
Nevertheless, the improvement is visible in my setup also.

Thanks,
Rahul


[dpdk-dev] [RFC] Generic flow director/filtering/classification API

2016-07-26 Thread Rahul Lakkireddy
On Monday, July 07/25/16, 2016 at 09:40:02 -0700, John Fastabend wrote:
> On 16-07-25 04:32 AM, Rahul Lakkireddy wrote:
> > Hi Adrien,
> > 
> > On Thursday, July 07/21/16, 2016 at 19:07:38 +0200, Adrien Mazarguil wrote:
> >> Hi Rahul,
> >>
> >> Please see below.
> >>
> >> On Thu, Jul 21, 2016 at 01:43:37PM +0530, Rahul Lakkireddy wrote:
> >>> Hi Adrien,
> >>>
> >>> The proposal looks very good.  It satisfies most of the features
> >>> supported by Chelsio NICs.  We are looking for suggestions on exposing
> >>> more additional features supported by Chelsio NICs via this API.
> >>>
> >>> Chelsio NICs have two regions in which filters can be placed -
> >>> Maskfull and Maskless regions.  As their names imply, maskfull region
> >>> can accept masks to match a range of values; whereas, maskless region
> >>> don't accept any masks and hence perform a more strict exact-matches.
> >>> Filters without masks can also be placed in maskfull region.  By
> >>> default, maskless region have higher priority over the maskfull region.
> >>> However, the priority between the two regions is configurable.
> >>
> >> I understand this configuration affects the entire device. Just to be 
> >> clear,
> >> assuming some filters are already configured, are they affected by a change
> >> of region priority later?
> >>
> > 
> > Both the regions exist at the same time in the device.  Each filter can
> > either belong to maskfull or the maskless region.
> > 
> > The priority is configured at time of filter creation for every
> > individual filter and cannot be changed while the filter is still
> > active. If priority needs to be changed for a particular filter then,
> > it needs to be deleted first and re-created.
> 
> Could you model this as two tables and add a table_id to the API? This
> way user space could populate the table it chooses. We would have to add
> some capabilities attributes to "learn" if tables support masks or not
> though.
> 

This approach sounds interesting.

> I don't see how the PMD can sort this out in any meaningful way and it
> has to be exposed to the application that has the intelligence to 'know'
> priorities between masks and non-masks filters. I'm sure you could come
> up with something but it would be less than ideal in many cases I would
> guess and we can't have the driver getting priorities wrong or we may
> not get the correct behavior.
> 
> > 
> >>> Please suggest on how we can let the apps configure in which region
> >>> filters must be placed and set the corresponding priority accordingly
> >>> via this API.
> >>
> >> Okay. Applications, like customers, are always right.
> >>
> >> With this in mind, PMDs are not allowed to break existing flow rules, and
> >> face two options when applications provide a flow specification that would
> >> break an existing rule:
> >>
> >> - Refuse to create it (easiest).
> >>
> >> - Find a workaround to apply it anyway (possibly quite complicated).
> >>
> >> The reason you have these two regions is performance right? Otherwise I'd
> >> just say put everything in the maskfull region.
> >>
> > 
> > Unfortunately, our maskfull region is extremely small too compared to
> > maskless region.
> > 
> 
> To me this means a userspace application would want to pack it
> carefully to get the full benefit. So you need some mechanism to specify
> the "region" hence the above table proposal.
> 

Right. Makes sense.

[...]
> >> Now about this "promisc" match criteria, it can be added as a new meta
> >> pattern item (4.1.3 Meta item types). Do you want it to be defined from the
> >> start or add it later with the related code in your PMD?
> >>
> > 
> > It could be added as a meta item.  If there are other interested
> > parties, it can be added now.  Otherwise, we'll add it with our filtering
> > related code.
> > 
> 
> hmm I guess by "promisc" here you mean match packets received from the
> wire before they have been switched by the silicon?
> 

Match packets received from wire before they have been switched by
silicon, and which also includes packets not destined for DUT and were
still received due to interface being in promisc mode.

> >>> - Match FCoE packets.
> >>
> >> The "oE" part is covered by the ETH item (using the proper Ethertype), but 
> >> a
&g

[dpdk-dev] removal of old deprecation notice for Chelsio filtering

2016-07-28 Thread Rahul Lakkireddy
Hi Thomas,

On Thursday, July 07/28/16, 2016 at 01:29:20 -0700, Thomas Monjalon wrote:
> Hi Rahul,
> 
> We still have this deprecation notice:
> 
> * ABI changes are planned for adding four new flow types. This impacts
>   RTE_ETH_FLOW_MAX. The release 2.2 does not contain these ABI changes,
>   but release 2.3 will. [postponed]
> 
> Do you agree that we can remove it now we have a better generic filtering
> API approach?
> 

Yes.  We can remove this deprecation notice in favor of the generic
filtering proposal in discussion.  I'll send a patch now.

Thanks,
Rahul


[dpdk-dev] [PATCH] doc: remove deprecation notice related to new flow types

2016-07-28 Thread Rahul Lakkireddy
Remove deprecation notice pertaining to introduction of new flow
types in favor of a more generic filtering infrastructure proposal.

Signed-off-by: Rahul Lakkireddy 
Signed-off-by: Kumar Sanghvi 
---
 doc/guides/rel_notes/deprecation.rst | 4 
 1 file changed, 4 deletions(-)

diff --git a/doc/guides/rel_notes/deprecation.rst 
b/doc/guides/rel_notes/deprecation.rst
index f502f86..7fc1185 100644
--- a/doc/guides/rel_notes/deprecation.rst
+++ b/doc/guides/rel_notes/deprecation.rst
@@ -23,10 +23,6 @@ Deprecation Notices
   do not need to care about the kind of devices that are being used, making it
   easier to add new buses later.

-* ABI changes are planned for adding four new flow types. This impacts
-  RTE_ETH_FLOW_MAX. The release 2.2 does not contain these ABI changes,
-  but release 2.3 will. [postponed]
-
 * The mbuf flags PKT_RX_VLAN_PKT and PKT_RX_QINQ_PKT are deprecated and
   are respectively replaced by PKT_RX_VLAN_STRIPPED and
   PKT_RX_QINQ_STRIPPED, that are better described. The old flags and
-- 
2.5.3



[dpdk-dev] [PATCH 1/5] pci: fix access to PCI config space in bsd

2016-06-01 Thread Rahul Lakkireddy
Hi Bruce,

On Tuesday, May 05/31/16, 2016 at 09:20:13 -0700, Bruce Richardson wrote:
> On Fri, May 06, 2016 at 01:13:15PM +0530, Rahul Lakkireddy wrote:
> > PCIOCREAD and PCIOCWRITE ioctls to read/write PCI config space fail
> > with EPERM due to missing write permission.  Fix by opening /dev/pci/
> > with O_RDWR instead.
> > 
> > Fixes: 632b2d1deeed ("eal: provide functions to access PCI config")
> > 
> > Signed-off-by: Rahul Lakkireddy 
> > Signed-off-by: Kumar Sanghvi 
> > ---
> >  lib/librte_eal/bsdapp/eal/eal_pci.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/lib/librte_eal/bsdapp/eal/eal_pci.c 
> > b/lib/librte_eal/bsdapp/eal/eal_pci.c
> > index 2d16d78..82330be 100644
> > --- a/lib/librte_eal/bsdapp/eal/eal_pci.c
> > +++ b/lib/librte_eal/bsdapp/eal/eal_pci.c
> > @@ -422,7 +422,7 @@ int rte_eal_pci_read_config(const struct rte_pci_device 
> > *dev,
> > goto error;
> > }
> >  
> > -   fd = open("/dev/pci", O_RDONLY);
> > +   fd = open("/dev/pci", O_RDWR);
> > if (fd < 0) {
> > RTE_LOG(ERR, EAL, "%s(): error opening /dev/pci\n", __func__);
> > goto error;
> > @@ -466,7 +466,7 @@ int rte_eal_pci_write_config(const struct 
> > rte_pci_device *dev,
> >  
> > memcpy(_data, buf, len);
> >  
> > -   fd = open("/dev/pci", O_RDONLY);
> > +   fd = open("/dev/pci", O_RDWR);
> > if (fd < 0) {
> > RTE_LOG(ERR, EAL, "%s(): error opening /dev/pci\n", __func__);
> > goto error;
> > -- 
> Does the read function as well as the write one need O_RDWR permissions? There
> is also an ioctl in rte_eal_pci_scan which operates on a RDONLY file 
> descriptor.
> Does that need to be modified also?

Yes, both PCIOCREAD and PCIOCWRITE ioctls seem to require write
permission.  Otherwise, pci_ioctl [1] seems to return EPERM.  On the
other hand, the PCIOCGETCONF ioctl used in rte_eal_pci_scan doesn't
seem to require a write permission.  So, it should be fine to leave it
as RDONLY.

[1] 
https://svnweb.freebsd.org/base/release/10.3.0/sys/dev/pci/pci_user.c?revision=297553=markup#l493

Thanks,
Rahul


[dpdk-dev] [PATCH v2 0/6] cxgbe: Optimize tx/rx for 40GbE and add Jumbo Frame support for CXGBE PMD

2015-10-21 Thread Rahul Lakkireddy
Hi Thomas,

On Tuesday, October 10/20/15, 2015 at 09:51:07 -0700, Thomas Monjalon wrote:
> 2015-10-08 19:16, Rahul Lakkireddy:
> > This series of patches improve forwarding performance for Chelsio T5 40GbE
> > cards and add Jumbo Frame support for cxgbe pmd. Also update documentation
> > and release notes.
> 
> Applied, thanks.
> 
> What are the performance numbers with these patches?

Without this patch series, the l3fwd perf with 8 queues for 64B was ~28 MPPS.
With this patch series, the perf has improved to ~31 MPPS.

Thanks,
Rahul


[dpdk-dev] [PATCH 16/20] cxgbe: copy pci device info to eth_dev data

2015-09-29 Thread Rahul Lakkireddy
Hi Bernard,

On Monday, September 09/28/15, 2015 at 14:03:34 +0100, Bernard Iremonger wrote:
> Signed-off-by: Bernard Iremonger 
> ---
>  drivers/net/cxgbe/cxgbe_ethdev.c | 5 +
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/net/cxgbe/cxgbe_ethdev.c 
> b/drivers/net/cxgbe/cxgbe_ethdev.c
> index 478051a..2fa2cc3 100644
> --- a/drivers/net/cxgbe/cxgbe_ethdev.c
> +++ b/drivers/net/cxgbe/cxgbe_ethdev.c
> @@ -2,6 +2,8 @@
>   *   BSD LICENSE
>   *
>   *   Copyright(c) 2014-2015 Chelsio Communications.
> + *   Copyright(c) 2015 Intel Corporation.
> + *
>   *   All rights reserved.
>   *
>   *   Redistribution and use in source and binary forms, with or without
> @@ -744,6 +746,9 @@ static int eth_cxgbe_dev_init(struct rte_eth_dev *eth_dev)
>   return 0;
>  
>   pci_dev = eth_dev->pci_dev;
> +
> + rte_eth_copy_dev_info(eth_dev, pci_dev);
> +
>   snprintf(name, sizeof(name), "cxgbeadapter%d", eth_dev->data->port_id);
>   adapter = rte_zmalloc(name, sizeof(*adapter), 0);
>   if (!adapter)
> -- 
> 1.9.1
> 

Out of curiosity, do you really need to add Intel copyright on top of source
file for a 3 line change in source file? I see that you have done the same for
cisco, mellanox, broadcom and other vendors as well.

I don't claim to understand Copyright very well. However, I have seen in other
open community projects like kernel.org where people many times do significant
change in someone else's code and yet, don't normally add their own copyright
to source files.

Care to explain what is the intention here with addition of Intel Copyright
statement?

Thanks,
Rahul



[dpdk-dev] [PATCH 0/5] Chelsio Terminator 5 (T5) 10G/40G Poll Mode Driver

2015-05-22 Thread Rahul Lakkireddy
This series of patches add the CXGBE Poll Mode Driver support for Chelsio
Terminator 5 series of 10G/40G adapters.  The CXGBE PMD is split into two
patches.  The first patch adds the hardware specific api for all supported
Chelsio T5 adapters and the second patch adds the actual DPDK CXGBE PMD.

More information on the CXGBE PMD can be found in the documentation added by
the third patch.  Also, the CXGBE PMD is enabled for compilation and linking
by the fourth patch.  Finally, update MAINTAINERS file to claim responsibility
for the CXGBE PMD.

Rahul Lakkireddy (5):
  cxgbe: add hardware specific api for all supported Chelsio T5 series
adapters.
  cxgbe: add cxgbe poll mode driver.
  doc: add cxgbe PMD documentation under doc/guides/nics/cxgbe.rst
  config: enable cxgbe PMD for compilation and linking.
  maintainers: claim responsibility for cxgbe PMD.

 MAINTAINERS |5 +
 config/common_linuxapp  |   10 +
 doc/guides/nics/cxgbe.rst   |  209 +++
 doc/guides/nics/index.rst   |1 +
 doc/guides/prog_guide/source_org.rst|1 +
 lib/Makefile|1 +
 lib/librte_pmd_cxgbe/Makefile   |   74 +
 lib/librte_pmd_cxgbe/cxgbe.h|   60 +
 lib/librte_pmd_cxgbe/cxgbe/adapter.h|  560 ++
 lib/librte_pmd_cxgbe/cxgbe/common.h |  401 
 lib/librte_pmd_cxgbe/cxgbe/t4_chip_type.h   |   79 +
 lib/librte_pmd_cxgbe/cxgbe/t4_hw.c  | 2686 +++
 lib/librte_pmd_cxgbe/cxgbe/t4_hw.h  |  149 ++
 lib/librte_pmd_cxgbe/cxgbe/t4_msg.h |  345 
 lib/librte_pmd_cxgbe/cxgbe/t4_pci_id_tbl.h  |  148 ++
 lib/librte_pmd_cxgbe/cxgbe/t4_regs.h|  779 
 lib/librte_pmd_cxgbe/cxgbe/t4_regs_values.h |  168 ++
 lib/librte_pmd_cxgbe/cxgbe/t4fw_interface.h | 1730 +
 lib/librte_pmd_cxgbe/cxgbe_compat.h |  290 +++
 lib/librte_pmd_cxgbe/cxgbe_ethdev.c |  796 
 lib/librte_pmd_cxgbe/cxgbe_main.c   | 1219 
 lib/librte_pmd_cxgbe/sge.c  | 2250 ++
 mk/rte.app.mk   |1 +
 23 files changed, 11962 insertions(+), 0 deletions(-)
 create mode 100644 doc/guides/nics/cxgbe.rst
 create mode 100644 lib/librte_pmd_cxgbe/Makefile
 create mode 100644 lib/librte_pmd_cxgbe/cxgbe.h
 create mode 100644 lib/librte_pmd_cxgbe/cxgbe/adapter.h
 create mode 100644 lib/librte_pmd_cxgbe/cxgbe/common.h
 create mode 100644 lib/librte_pmd_cxgbe/cxgbe/t4_chip_type.h
 create mode 100644 lib/librte_pmd_cxgbe/cxgbe/t4_hw.c
 create mode 100644 lib/librte_pmd_cxgbe/cxgbe/t4_hw.h
 create mode 100644 lib/librte_pmd_cxgbe/cxgbe/t4_msg.h
 create mode 100644 lib/librte_pmd_cxgbe/cxgbe/t4_pci_id_tbl.h
 create mode 100644 lib/librte_pmd_cxgbe/cxgbe/t4_regs.h
 create mode 100644 lib/librte_pmd_cxgbe/cxgbe/t4_regs_values.h
 create mode 100644 lib/librte_pmd_cxgbe/cxgbe/t4fw_interface.h
 create mode 100644 lib/librte_pmd_cxgbe/cxgbe_compat.h
 create mode 100644 lib/librte_pmd_cxgbe/cxgbe_ethdev.c
 create mode 100644 lib/librte_pmd_cxgbe/cxgbe_main.c
 create mode 100644 lib/librte_pmd_cxgbe/sge.c



[dpdk-dev] [PATCH 1/5] cxgbe: add hardware specific api for all supported Chelsio T5 series adapters.

2015-05-22 Thread Rahul Lakkireddy
Adds hardware specific api for all the Chelsio T5 adapters under
lib/librte_pmd_cxgbe/cxgbe directory.

Signed-off-by: Rahul Lakkireddy 
Signed-off-by: Kumar Sanghvi 
---
 lib/librte_pmd_cxgbe/cxgbe/adapter.h|  560 ++
 lib/librte_pmd_cxgbe/cxgbe/common.h |  401 
 lib/librte_pmd_cxgbe/cxgbe/t4_chip_type.h   |   79 +
 lib/librte_pmd_cxgbe/cxgbe/t4_hw.c  | 2686 +++
 lib/librte_pmd_cxgbe/cxgbe/t4_hw.h  |  149 ++
 lib/librte_pmd_cxgbe/cxgbe/t4_msg.h |  345 
 lib/librte_pmd_cxgbe/cxgbe/t4_pci_id_tbl.h  |  148 ++
 lib/librte_pmd_cxgbe/cxgbe/t4_regs.h|  779 
 lib/librte_pmd_cxgbe/cxgbe/t4_regs_values.h |  168 ++
 lib/librte_pmd_cxgbe/cxgbe/t4fw_interface.h | 1730 +
 10 files changed, 7045 insertions(+), 0 deletions(-)
 create mode 100644 lib/librte_pmd_cxgbe/cxgbe/adapter.h
 create mode 100644 lib/librte_pmd_cxgbe/cxgbe/common.h
 create mode 100644 lib/librte_pmd_cxgbe/cxgbe/t4_chip_type.h
 create mode 100644 lib/librte_pmd_cxgbe/cxgbe/t4_hw.c
 create mode 100644 lib/librte_pmd_cxgbe/cxgbe/t4_hw.h
 create mode 100644 lib/librte_pmd_cxgbe/cxgbe/t4_msg.h
 create mode 100644 lib/librte_pmd_cxgbe/cxgbe/t4_pci_id_tbl.h
 create mode 100644 lib/librte_pmd_cxgbe/cxgbe/t4_regs.h
 create mode 100644 lib/librte_pmd_cxgbe/cxgbe/t4_regs_values.h
 create mode 100644 lib/librte_pmd_cxgbe/cxgbe/t4fw_interface.h

diff --git a/lib/librte_pmd_cxgbe/cxgbe/adapter.h 
b/lib/librte_pmd_cxgbe/cxgbe/adapter.h
new file mode 100644
index 000..e928854
--- /dev/null
+++ b/lib/librte_pmd_cxgbe/cxgbe/adapter.h
@@ -0,0 +1,560 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2014-2015 Chelsio Communications.
+ *   All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the name of Chelsio Communications nor the names of its
+ *   contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ *   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.
+ */
+
+/* This file should not be included directly.  Include common.h instead. */
+
+#ifndef __T4_ADAPTER_H__
+#define __T4_ADAPTER_H__
+
+#include 
+
+#include "cxgbe_compat.h"
+#include "t4_regs_values.h"
+
+enum {
+   MAX_ETH_QSETS = 64,   /* # of Ethernet Tx/Rx queue sets */
+};
+
+struct adapter;
+struct sge_rspq;
+
+enum {
+   PORT_RSS_DONE = (1 << 0),
+};
+
+struct port_info {
+   struct adapter *adapter;/* adapter that this port belongs to */
+   struct rte_eth_dev *eth_dev;/* associated rte eth device */
+   struct port_stats stats_base;   /* port statistics base */
+   struct link_config link_cfg;/* link configuration info */
+
+   unsigned long flags;/* port related flags */
+   short int xact_addr_filt;   /* index of exact MAC address filter */
+
+   u16viid;/* associated virtual interface id */
+   s8 mdio_addr;   /* address of the PHY */
+   u8 port_type;   /* firmware port type */
+   u8 mod_type;/* firmware module type */
+   u8 port_id; /* physical port ID */
+   u8 tx_chan; /* associated channel */
+
+   u8 n_rx_qsets;  /* # of rx qsets */
+   u8 n_tx_qsets;  /* # of tx qsets */
+   u8 first_qset;  /* index of first qset */
+
+   u16*rss;/* rss table */
+   u8 rss_mode;/* rss mode */
+   u16rss_size;/* size of VI's RSS table 

[dpdk-dev] [PATCH 2/5] cxgbe: add cxgbe poll mode driver.

2015-05-22 Thread Rahul Lakkireddy
Adds cxgbe poll mode driver for DPDK under lib/librte_pmd_cxgbe directory. This
patch:

1. Adds the Makefile to compile cxgbe pmd.
2. Registers and initializes the cxgbe pmd driver.
3. Implements the necessary eth_dev_ops.

Signed-off-by: Rahul Lakkireddy 
Signed-off-by: Kumar Sanghvi 
---
 lib/librte_pmd_cxgbe/Makefile   |   74 ++
 lib/librte_pmd_cxgbe/cxgbe.h|   60 +
 lib/librte_pmd_cxgbe/cxgbe_compat.h |  290 +
 lib/librte_pmd_cxgbe/cxgbe_ethdev.c |  796 +
 lib/librte_pmd_cxgbe/cxgbe_main.c   | 1219 +++
 lib/librte_pmd_cxgbe/sge.c  | 2250 +++
 6 files changed, 4689 insertions(+), 0 deletions(-)
 create mode 100644 lib/librte_pmd_cxgbe/Makefile
 create mode 100644 lib/librte_pmd_cxgbe/cxgbe.h
 create mode 100644 lib/librte_pmd_cxgbe/cxgbe_compat.h
 create mode 100644 lib/librte_pmd_cxgbe/cxgbe_ethdev.c
 create mode 100644 lib/librte_pmd_cxgbe/cxgbe_main.c
 create mode 100644 lib/librte_pmd_cxgbe/sge.c

diff --git a/lib/librte_pmd_cxgbe/Makefile b/lib/librte_pmd_cxgbe/Makefile
new file mode 100644
index 000..945f196
--- /dev/null
+++ b/lib/librte_pmd_cxgbe/Makefile
@@ -0,0 +1,74 @@
+#   BSD LICENSE
+#
+#   Copyright(c) 2014-2015 Chelsio Communications.
+#   All rights reserved.
+#
+#   Redistribution and use in source and binary forms, with or without
+#   modification, are permitted provided that the following conditions
+#   are met:
+#
+# * Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# * 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.
+# * Neither the name of Chelsio Communications nor the names of its
+#   contributors may be used to endorse or promote products derived
+#   from this software without specific prior written permission.
+#
+#   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 $(RTE_SDK)/mk/rte.vars.mk
+
+#
+# library name
+#
+LIB = librte_pmd_cxgbe.a
+
+CFLAGS += -I$(RTE_SDK)/lib/librte_pmd_cxgbe/cxgbe/
+CFLAGS += -I$(RTE_SDK)/lib/librte_pmd_cxgbe/
+CFLAGS += -O3
+CFLAGS += $(WERROR_FLAGS)
+
+ifeq ($(CC), icc)
+#
+# CFLAGS for icc
+#
+CFLAGS_BASE_DRIVER = -wd174 -wd593 -wd869 -wd981 -wd2259
+else
+#
+# CFLAGS for gcc
+#
+ifeq ($(shell test $(GCC_VERSION) -ge 44 && echo 1), 1)
+CFLAGS += -Wno-deprecated
+endif
+CFLAGS_BASE_DRIVER = -Wno-unused-parameter -Wno-unused-value
+CFLAGS_BASE_DRIVER += -Wno-strict-aliasing -Wno-format-extra-args
+
+endif
+
+#
+# all source are stored in SRCS-y
+#
+SRCS-$(CONFIG_RTE_LIBRTE_CXGBE_PMD) += cxgbe_ethdev.c
+SRCS-$(CONFIG_RTE_LIBRTE_CXGBE_PMD) += cxgbe_main.c
+SRCS-$(CONFIG_RTE_LIBRTE_CXGBE_PMD) += sge.c
+SRCS-$(CONFIG_RTE_LIBRTE_CXGBE_PMD) += cxgbe/t4_hw.c
+
+# this lib depends upon:
+DEPDIRS-$(CONFIG_RTE_LIBRTE_CXGBE_PMD) += lib/librte_eal lib/librte_ether
+DEPDIRS-$(CONFIG_RTE_LIBRTE_CXGBE_PMD) += lib/librte_mempool lib/librte_mbuf
+DEPDIRS-$(CONFIG_RTE_LIBRTE_CXGBE_PMD) += lib/librte_net lib/librte_malloc
+
+include $(RTE_SDK)/mk/rte.lib.mk
diff --git a/lib/librte_pmd_cxgbe/cxgbe.h b/lib/librte_pmd_cxgbe/cxgbe.h
new file mode 100644
index 000..97c37d2
--- /dev/null
+++ b/lib/librte_pmd_cxgbe/cxgbe.h
@@ -0,0 +1,60 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2014-2015 Chelsio Communications.
+ *   All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the name of Chelsio Communications nor the names of its
+ *   contributors may be used to endorse or promot

[dpdk-dev] [PATCH 3/5] doc: add cxgbe PMD documentation under doc/guides/nics/cxgbe.rst

2015-05-22 Thread Rahul Lakkireddy
Adds cxgbe poll mode driver documentation under the usual doc/guides/nics/
directory with the rest of the drivers.  The documentation covers cxgbe
implementation details, features and limitations, prerequisites, configuration,
and a sample application usage.

Signed-off-by: Rahul Lakkireddy 
Signed-off-by: Kumar Sanghvi 
---
 doc/guides/nics/cxgbe.rst|  209 ++
 doc/guides/nics/index.rst|1 +
 doc/guides/prog_guide/source_org.rst |1 +
 3 files changed, 211 insertions(+), 0 deletions(-)
 create mode 100644 doc/guides/nics/cxgbe.rst

diff --git a/doc/guides/nics/cxgbe.rst b/doc/guides/nics/cxgbe.rst
new file mode 100644
index 000..71f21a6
--- /dev/null
+++ b/doc/guides/nics/cxgbe.rst
@@ -0,0 +1,209 @@
+..  BSD LICENSE
+Copyright 2015 Chelsio Communications.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+* Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+* 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.
+* Neither the name of Chelsio Communications nor the names of its
+contributors may be used to endorse or promote products derived
+from this software without specific prior written permission.
+
+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.
+
+CXGBE Poll Mode Driver
+==
+
+The CXGBE PMD (**librte_pmd_cxgbe**) provides poll mode driver support
+for **Chelsio T5** 10/40 Gbps family of adapters.
+
+More information can be found at `Chelsio Communications
+<http://www.chelsio.com>`_.
+
+Features
+
+
+CXGBE PMD has the support for:
+
+- Multiple queues for TX and RX.
+- Receiver Side Steering (RSS).
+- VLAN filtering.
+- Checksum offload.
+- Promiscuous mode.
+- All multicast mode.
+- Port hardware statistics.
+
+Limitations
+---
+
+The Chelsio T5 devices provide two/four ports but expose only a single PCI bus
+address. Thus, librte_pmd_cxgbe registers itself as a PCI driver that allocates
+one Ethernet device per detected port.
+
+For this reason, one cannot white/blacklist a single port without also
+white/blacklisting the others on the same device.
+
+Configuration
+-
+
+Compiling CXGBE PMD
+~~~
+
+These options can be modified in the ``.config`` file.
+
+- ``CONFIG_RTE_LIBRTE_CXGBE_PMD`` (default **y**)
+
+  Toggle compilation of librte_pmd_cxgbe driver.
+
+- ``CONFIG_RTE_LIBRTE_CXGBE_DEBUG`` (default **n**)
+
+  Toggle debugging code. Enabling this option adds additional generic debugging
+  messages at the cost of lower performance.
+
+- ``CONFIG_RTE_LIBRTE_CXGBE_DEBUG_REG`` (default **n**)
+
+  Toggle debugging code. Enabling this option adds additional registers related
+  run-time checks and debugging messages at the cost of lower performance.
+
+- ``CONFIG_RTE_LIBRTE_CXGBE_DEBUG_MBOX`` (default **n**)
+
+  Toggle debugging code. Enabling this option adds additional firmware mailbox
+  related run-time checks and debugging messages at the cost of lower
+  performance.
+
+- ``CONFIG_RTE_LIBRTE_CXGBE_DEBUG_TX`` (default **n**)
+
+  Toggle debugging code. Enabling this option adds additional transmission data
+  path run-time checks and debugging messages at the cost of lower performance.
+
+- ``CONFIG_RTE_LIBRTE_CXGBE_DEBUG_RX`` (default **n**)
+
+  Toggle debugging code. Enabling this option adds additional receiving data
+  path run-time checks and debugging messages at the cost of lower performance.
+
+Prerequisites
+-
+
+- Requires firmware version **1.13.32.0** and higher. Visit
+  `Chelsio Communications <http://www.chelsio.com>`_ to get latest firmware.
+
+Sample Application Notes
+-
+
+This section demonstrates how to launch **testpmd** with Chelsio T5
+devices managed by librte_pmd_cxgbe.
+
+#. Load the kernel module:
+
+   .. code-block:: console
+

[dpdk-dev] [PATCH 4/5] config: enable cxgbe PMD for compilation and linking.

2015-05-22 Thread Rahul Lakkireddy
Changes to:
1. config/common_linuxapp to add macros for cxgbe pmd.
2. lib/Makefile to add cxgbe pmd to the compile list.
3. mk/rte.app.mk to add cxgbe pmd to link.

Signed-off-by: Rahul Lakkireddy 
Signed-off-by: Kumar Sanghvi 
---
 config/common_linuxapp |   10 ++
 lib/Makefile   |1 +
 mk/rte.app.mk  |1 +
 3 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/config/common_linuxapp b/config/common_linuxapp
index 0078dc9..dfafd45 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -208,6 +208,16 @@ CONFIG_RTE_LIBRTE_MLX4_TX_MP_CACHE=8
 CONFIG_RTE_LIBRTE_MLX4_SOFT_COUNTERS=1

 #
+# Compile burst-oriented Chelsio Terminator 10GbE/40GbE (CXGBE) PMD
+#
+CONFIG_RTE_LIBRTE_CXGBE_PMD=y
+CONFIG_RTE_LIBRTE_CXGBE_DEBUG=n
+CONFIG_RTE_LIBRTE_CXGBE_DEBUG_REG=n
+CONFIG_RTE_LIBRTE_CXGBE_DEBUG_MBOX=n
+CONFIG_RTE_LIBRTE_CXGBE_DEBUG_TX=n
+CONFIG_RTE_LIBRTE_CXGBE_DEBUG_RX=n
+
+#
 # Compile burst-oriented Cisco ENIC PMD driver
 #
 CONFIG_RTE_LIBRTE_ENIC_PMD=y
diff --git a/lib/Makefile b/lib/Makefile
index d94355d..19beb28 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -46,6 +46,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += librte_pmd_ixgbe
 DIRS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += librte_pmd_i40e
 DIRS-$(CONFIG_RTE_LIBRTE_FM10K_PMD) += librte_pmd_fm10k
 DIRS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += librte_pmd_mlx4
+DIRS-$(CONFIG_RTE_LIBRTE_CXGBE_PMD) += librte_pmd_cxgbe
 DIRS-$(CONFIG_RTE_LIBRTE_ENIC_PMD) += librte_pmd_enic
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += librte_pmd_bond
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_RING) += librte_pmd_ring
diff --git a/mk/rte.app.mk b/mk/rte.app.mk
index 1a2043a..0ed9651 100644
--- a/mk/rte.app.mk
+++ b/mk/rte.app.mk
@@ -128,6 +128,7 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_FM10K_PMD)  += 
-lrte_pmd_fm10k
 _LDLIBS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD)  += -lrte_pmd_ixgbe
 _LDLIBS-$(CONFIG_RTE_LIBRTE_E1000_PMD)  += -lrte_pmd_e1000
 _LDLIBS-$(CONFIG_RTE_LIBRTE_MLX4_PMD)   += -lrte_pmd_mlx4
+_LDLIBS-$(CONFIG_RTE_LIBRTE_CXGBE_PMD)  += -lrte_pmd_cxgbe
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_RING)   += -lrte_pmd_ring
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_PCAP)   += -lrte_pmd_pcap
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_AF_PACKET)  += -lrte_pmd_af_packet
-- 
1.7.1



[dpdk-dev] [PATCH 5/5] maintainers: claim responsibility for cxgbe PMD.

2015-05-22 Thread Rahul Lakkireddy
Update MAINTAINERS file to claim responsibility for the cxgbe PMD.

Signed-off-by: Rahul Lakkireddy 
Signed-off-by: Kumar Sanghvi 
---
 MAINTAINERS |5 +
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 0477e7d..37b7472 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -239,6 +239,11 @@ M: Adrien Mazarguil 
 F: lib/librte_pmd_mlx4/
 F: doc/guides/nics/mlx4.rst

+Chelsio cxgbe
+M: Rahul Lakkireddy 
+F: lib/librte_pmd_cxgbe/
+F: doc/guides/nics/cxgbe.rst
+
 RedHat virtio
 M: Changchun Ouyang 
 F: lib/librte_pmd_virtio/
-- 
1.7.1



[dpdk-dev] [PATCH 2/5] cxgbe: add cxgbe poll mode driver.

2015-05-23 Thread Rahul Lakkireddy
On Fri, May 22, 2015 at 09:43:20 -0700, Stephen Hemminger wrote:
> On Fri, 22 May 2015 18:54:20 +0530
> Rahul Lakkireddy  wrote:
> 
> > +/**
> > + * fls - find last (most-significant) bit set
> > + * @x: the word to search
> > + *
> > + * This is defined the same way as ffs.
> > + * Note fls(0) = 0, fls(1) = 1, fls(0x8000) = 32.
> > + */
> > +static inline int fls(int x)
> 
> Isn't there a Gcc intrinsic already for this?

I guess you are referring to __builtin_clz ?
I will do that change in v2.


Thanks,
Rahul.


[dpdk-dev] [PATCH 2/5] cxgbe: add cxgbe poll mode driver.

2015-05-23 Thread Rahul Lakkireddy
On Fri, May 22, 2015 at 09:42:50 -0700, Stephen Hemminger wrote:
> On Fri, 22 May 2015 18:54:20 +0530
> Rahul Lakkireddy  wrote:
> 
> > +#define pr_err(y, args...) dev_err(0, y, ##args)
> > +#define pr_warn(y, args...) dev_warn(0, y, ##args)
> > +#define pr_info(y, args...) dev_info(0, y, ##args)
> > +#define BUG() pr_err("BUG at %s:%d", __func__, __LINE__)
> > +
> > +#define ASSERT(x) do {\
> > +   if (!(x)) \
> > +   rte_panic("CXGBE: x"); \
> > +} while (0)
> > +#define BUG_ON(x) ASSERT(!(x))
> > +
> > +#ifndef WARN_ON
> > +#define WARN_ON(x) do { \
> > +   int ret = !!(x); \
> > +   if (unlikely(ret)) \
> > +   pr_warn("WARN_ON: \"" #x "\" at %s:%d\n", __func__, __LINE__); \
> > +} while (0)
> > +#endif
> > +
> > +#define __iomem
> > +
> > +#ifndef BIT
> > +#define BIT(n) (1 << (n))
> > +#endif
> > +
> > +#define L1_CACHE_SHIFT  6
> > +#define L1_CACHE_BYTES  BIT(L1_CACHE_SHIFT)
> > +
> > +#define PAGE_SHIFT  12
> > +#define ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1))
> > +#define PTR_ALIGN(p, a) ((typeof(p))ALIGN((unsigned long)(p), (a)))
> > +
> > +#define VLAN_HLEN 4
> > +
> > +#define rmb() rte_rmb() /* dpdk rte provided rmb */
> > +#define wmb() rte_wmb() /* dpdk rte provided wmb */
> > +
> > +typedef uint8_t   u8;
> > +typedef int8_ts8;
> > +typedef uint16_t  u16;
> > +typedef uint32_t  u32;
> > +typedef int32_t   s32;
> > +typedef uint64_t  u64;
> > +typedef int   bool;
> > +typedef uint64_t  dma_addr_t;
> > +
> > +#ifndef __le16
> > +#define __le16 uint16_t
> > +#endif
> > +#ifndef __le32
> > +#define __le32 uint32_t
> > +#endif
> > +#ifndef __le64
> > +#define __le64 uint64_t
> > +#endif
> > +#ifndef __be16
> > +#define __be16 uint16_t
> > +#endif
> > +#ifndef __be32
> > +#define __be32 uint32_t
> > +#endif
> > +#ifndef __be64
> > +#define __be64 uint64_t
> > +#endif
> > +#ifndef __u8
> > +#define __u8   uint8_t
> > +#endif
> > +#ifndef __u16
> > +#define __u16  uint16_t
> > +#endif
> > +#ifndef __u32
> > +#define __u32  uint32_t
> > +#endif
> > +#ifndef __u64
> > +#define __u64  uint64_t
> > +#endif
> > +
> > +#define FALSE  0
> > +#define TRUE   1
> > +#define false  0
> > +#define true   1
> > +
> > +#define min(a, b) RTE_MIN(a, b)
> > +#define max(a, b) RTE_MAX(a, b)
> 
> This is not Linux kernel.
> Please don't create wrappers for all the stuff in Linux to port your driver.

We actually referred several PMD's compat file including - enic_compat.h,
i40e_osdep.h, ixgbe_osdep.h, fm10k_osdep.h, etc.

Most of the types above are already defined by many of existing PMD's compat
file.  Can we at-least keep those which are already defined by several PMD's
compat file?


Thanks,
Rahul.


[dpdk-dev] [PATCH 2/5] cxgbe: add cxgbe poll mode driver.

2015-05-26 Thread Rahul Lakkireddy
On Sat, May 23, 2015 at 11:27:56 +0530, Rahul Lakkireddy wrote:
> On Fri, May 22, 2015 at 09:42:50 -0700, Stephen Hemminger wrote:
> > On Fri, 22 May 2015 18:54:20 +0530
> > Rahul Lakkireddy  wrote:
> > 
> > > +#define pr_err(y, args...) dev_err(0, y, ##args)
> > > +#define pr_warn(y, args...) dev_warn(0, y, ##args)
> > > +#define pr_info(y, args...) dev_info(0, y, ##args)
> > > +#define BUG() pr_err("BUG at %s:%d", __func__, __LINE__)
> > > +
> > > +#define ASSERT(x) do {\
> > > + if (!(x)) \
> > > + rte_panic("CXGBE: x"); \
> > > +} while (0)
> > > +#define BUG_ON(x) ASSERT(!(x))
> > > +
> > > +#ifndef WARN_ON
> > > +#define WARN_ON(x) do { \
> > > + int ret = !!(x); \
> > > + if (unlikely(ret)) \
> > > + pr_warn("WARN_ON: \"" #x "\" at %s:%d\n", __func__, __LINE__); \
> > > +} while (0)
> > > +#endif
> > > +
> > > +#define __iomem
> > > +
> > > +#ifndef BIT
> > > +#define BIT(n) (1 << (n))
> > > +#endif
> > > +
> > > +#define L1_CACHE_SHIFT  6
> > > +#define L1_CACHE_BYTES  BIT(L1_CACHE_SHIFT)
> > > +
> > > +#define PAGE_SHIFT  12
> > > +#define ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1))
> > > +#define PTR_ALIGN(p, a) ((typeof(p))ALIGN((unsigned long)(p), (a)))
> > > +
> > > +#define VLAN_HLEN 4
> > > +
> > > +#define rmb() rte_rmb() /* dpdk rte provided rmb */
> > > +#define wmb() rte_wmb() /* dpdk rte provided wmb */
> > > +
> > > +typedef uint8_t   u8;
> > > +typedef int8_ts8;
> > > +typedef uint16_t  u16;
> > > +typedef uint32_t  u32;
> > > +typedef int32_t   s32;
> > > +typedef uint64_t  u64;
> > > +typedef int   bool;
> > > +typedef uint64_t  dma_addr_t;
> > > +
> > > +#ifndef __le16
> > > +#define __le16   uint16_t
> > > +#endif
> > > +#ifndef __le32
> > > +#define __le32   uint32_t
> > > +#endif
> > > +#ifndef __le64
> > > +#define __le64   uint64_t
> > > +#endif
> > > +#ifndef __be16
> > > +#define __be16   uint16_t
> > > +#endif
> > > +#ifndef __be32
> > > +#define __be32   uint32_t
> > > +#endif
> > > +#ifndef __be64
> > > +#define __be64   uint64_t
> > > +#endif
> > > +#ifndef __u8
> > > +#define __u8 uint8_t
> > > +#endif
> > > +#ifndef __u16
> > > +#define __u16uint16_t
> > > +#endif
> > > +#ifndef __u32
> > > +#define __u32uint32_t
> > > +#endif
> > > +#ifndef __u64
> > > +#define __u64uint64_t
> > > +#endif
> > > +
> > > +#define FALSE0
> > > +#define TRUE 1
> > > +#define false0
> > > +#define true 1
> > > +
> > > +#define min(a, b) RTE_MIN(a, b)
> > > +#define max(a, b) RTE_MAX(a, b)
> > 
> > This is not Linux kernel.
> > Please don't create wrappers for all the stuff in Linux to port your driver.
> 
> We actually referred several PMD's compat file including - enic_compat.h,
> i40e_osdep.h, ixgbe_osdep.h, fm10k_osdep.h, etc.
> 
> Most of the types above are already defined by many of existing PMD's compat
> file.  Can we at-least keep those which are already defined by several PMD's
> compat file?

Just to give a background - since we are new to dpdk community, we studied the
already merged PMD's compat files as reference to understand how things are
done for driver submission. And so, we wrote cxgbe compat file along similar
lines. However, if above wrappers are not acceptable then, we will definitely
remove them in V2.

Just trying to get a clarification so that we don't repeat the same mistake in
V2 submission. Reviews from you and dpdk community are more than welcome and
appreciated.


Thanks,
Rahul.


[dpdk-dev] [PATCH 2/5] cxgbe: add cxgbe poll mode driver.

2015-05-27 Thread Rahul Lakkireddy
On Tue, May 26, 2015 at 10:24:37 -0700, Stephen Hemminger wrote:
> On Tue, 26 May 2015 22:32:07 +0530
> Rahul Lakkireddy  wrote:
> 
> > On Sat, May 23, 2015 at 11:27:56 +0530, Rahul Lakkireddy wrote:
> > > On Fri, May 22, 2015 at 09:42:50 -0700, Stephen Hemminger wrote:
> > > > On Fri, 22 May 2015 18:54:20 +0530
> > > > Rahul Lakkireddy  wrote:
> > > > 
[...]

> > > > 
> > > > This is not Linux kernel.
> > > > Please don't create wrappers for all the stuff in Linux to port your 
> > > > driver.
> > > 
> > > We actually referred several PMD's compat file including - enic_compat.h,
> > > i40e_osdep.h, ixgbe_osdep.h, fm10k_osdep.h, etc.
> > > 
> > > Most of the types above are already defined by many of existing PMD's 
> > > compat
> > > file.  Can we at-least keep those which are already defined by several 
> > > PMD's
> > > compat file?
> > 
> > Just to give a background - since we are new to dpdk community, we studied 
> > the
> > already merged PMD's compat files as reference to understand how things are
> > done for driver submission. And so, we wrote cxgbe compat file along similar
> > lines. However, if above wrappers are not acceptable then, we will 
> > definitely
> > remove them in V2.
> > 
> > Just trying to get a clarification so that we don't repeat the same mistake 
> > in
> > V2 submission. Reviews from you and dpdk community are more than welcome and
> > appreciated.
> 
> Does this driver share source code with other platforms?

Yes. The h/w specific code is common to Linux and FBSD.
And we will be enabling FBSD support soon after this PMD gets merged and we are
able to carry out and complete testing on FBSD.


> If it does then the compatibility wrappers make sense and reduce the
> maintenance effort.
> If the driver is a standalone port to DPDK, then it makes sense to complete
> the effort and use standard DPDK coding practices (stdint, stdbool, etc).
> 
> The other drivers in DPDK do things based on that. Many of the hardware
> drivers share code with BSD. Others like the virtual drivers were written
> or ported completely from scratch.
>

Thank you for your guidance.



[dpdk-dev] [PATCH 3/5] doc: add cxgbe PMD documentation under doc/guides/nics/cxgbe.rst

2015-05-27 Thread Rahul Lakkireddy
On Wed, May 27, 2015 at 07:38:50 +0200, Thomas Monjalon wrote:
> 2015-05-22 18:54, Rahul Lakkireddy:
> > Adds cxgbe poll mode driver documentation under the usual doc/guides/nics/
> > directory with the rest of the drivers.  The documentation covers cxgbe
> > implementation details, features and limitations, prerequisites, 
> > configuration,
> > and a sample application usage.
> > 
> > Signed-off-by: Rahul Lakkireddy 
> > Signed-off-by: Kumar Sanghvi 
> 
> Nice documentation, thank you.
> Do not hesitate to add some design insights which would help tuning or
> maintenance.

Sure. I will figure out if something can be added to documentation for tuning
part.

> 
> > --- a/doc/guides/nics/index.rst
> > +++ b/doc/guides/nics/index.rst
> > @@ -44,6 +44,7 @@ Network Interface Controller Drivers
> >  ixgbe
> >  intel_vf
> >  mlx4
> > +cxgbe
> >  virtio
> >  vmxnet3
> 
> Please add it in the alphabetical order.

Ok. Will correct this in v2.

Thanks,
Rahul.


[dpdk-dev] [PATCH 2/5] cxgbe: add cxgbe poll mode driver.

2015-05-27 Thread Rahul Lakkireddy
On Tue, May 26, 2015 at 22:49:08 -0700, Thomas Monjalon wrote:
> 2015-05-23 11:23, Rahul Lakkireddy:
> > We need to rebase anyway since PMDs now seem to have moved to
> > drivers/net directory.
> 
> Yes. And the subdirectory should probably be renamed base/.

Yes, we will do this.

> 
> It would be nice to introduce the PMD features in separate patches
> as it was done for fm10k.
> 
> Thanks

Ok. We will break this patch into several separate patches for v2 submission.


Thanks,
Rahul.


[dpdk-dev] [PATCH] ethdev: add a missing sanity check for nb_tx_desc during txq setup

2015-11-20 Thread Rahul Lakkireddy
Add a sanity check for number of tx descriptors requested during tx
queue setup.  Return -EINVAL if the number requested does not meet
the tx descriptor requirements of the device.

Fixes: 80a1deb4c77a ("ethdev: add API to retrieve queue information")

Signed-off-by: Rahul Lakkireddy 
Signed-off-by: Kumar Sanghvi 
---
 lib/librte_ether/rte_ethdev.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index b19ac9a..dfd6c0b 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -1342,6 +1342,18 @@ rte_eth_tx_queue_setup(uint8_t port_id, uint16_t 
tx_queue_id,

rte_eth_dev_info_get(port_id, _info);

+   if (nb_tx_desc > dev_info.tx_desc_lim.nb_max ||
+   nb_tx_desc < dev_info.tx_desc_lim.nb_min ||
+   nb_tx_desc % dev_info.tx_desc_lim.nb_align != 0) {
+   PMD_DEBUG_TRACE("Invalid value for nb_tx_desc(=%hu), "
+   "should be: <= %hu, = %hu, and a product of 
%hu\n",
+   nb_tx_desc,
+   dev_info.tx_desc_lim.nb_max,
+   dev_info.tx_desc_lim.nb_min,
+   dev_info.tx_desc_lim.nb_align);
+   return -EINVAL;
+   }
+
if (tx_conf == NULL)
tx_conf = _info.default_txconf;

-- 
2.5.3



[dpdk-dev] [PATCH 0/2] cxgbe: Minor fixes in cxgbe pmd

2015-11-20 Thread Rahul Lakkireddy
This series of patches fix some issues and recent regressions in cxgbe pmd.

Patch 1 fixes a regression where queue setup for cxgbe pmd fails with
-EINVAL because cxgbe pmd requires a min of 1024 descriptors, but most
examples and apps initialize with 128 rx descriptors and 512 tx
descriptors.

Patch 2 replaces spinning for a lock with a better trylock in
tx alarm callback.

Rahul Lakkireddy (2):
  cxgbe: fix queue setup failure due to strict min desc requirement
  cxgbe: fix unnecessary spinning for a lock with trylock instead

 drivers/net/cxgbe/base/adapter.h |  9 +
 drivers/net/cxgbe/cxgbe.h|  2 +-
 drivers/net/cxgbe/sge.c  | 21 -
 3 files changed, 22 insertions(+), 10 deletions(-)

-- 
2.5.3



[dpdk-dev] [PATCH 1/2] cxgbe: fix queue setup failure due to strict min desc requirement

2015-11-20 Thread Rahul Lakkireddy
Most dpdk examples and apps seem to initialize with a minimum of 128 rx
descriptors and 512 tx descriptors for queue setup.  However, CXGBE PMD
enforces a minimum of 1024 descriptors.  This causes the dpdk stack
to return -EINVAL because the apps do not request the minimum required.

The fix is to relax this enforcing in CXGBE PMD. A minimum of 128
descriptors seems to be a good number with the least impact on the
performance.

Fixes: 946c9ed95616 ("cxgbe: get descriptor limits")

Signed-off-by: Rahul Lakkireddy 
Signed-off-by: Kumar Sanghvi 
---
 drivers/net/cxgbe/cxgbe.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/cxgbe/cxgbe.h b/drivers/net/cxgbe/cxgbe.h
index adc0d92..0201c99 100644
--- a/drivers/net/cxgbe/cxgbe.h
+++ b/drivers/net/cxgbe/cxgbe.h
@@ -37,7 +37,7 @@
 #include "common.h"
 #include "t4_regs.h"

-#define CXGBE_MIN_RING_DESC_SIZE  1024 /* Min TX/RX descriptor ring size */
+#define CXGBE_MIN_RING_DESC_SIZE  128  /* Min TX/RX descriptor ring size */
 #define CXGBE_MAX_RING_DESC_SIZE  4096 /* Max TX/RX descriptor ring size */

 #define CXGBE_DEFAULT_TX_DESC_SIZE1024 /* Default TX ring size */
-- 
2.5.3



[dpdk-dev] [PATCH 2/2] cxgbe: fix unnecessary spinning for a lock with trylock instead

2015-11-20 Thread Rahul Lakkireddy
CXGBE PMD depends on an alarm to periodically transmit any pending
coalesced packets and hence spins for a lock for each tx queue in the
alarm callback.

A better solution is to try to get a lock whenever possible, instead
of spinning for it.

Signed-off-by: Rahul Lakkireddy 
Signed-off-by: Kumar Sanghvi 
---
 drivers/net/cxgbe/base/adapter.h |  9 +
 drivers/net/cxgbe/sge.c  | 21 -
 2 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/drivers/net/cxgbe/base/adapter.h b/drivers/net/cxgbe/base/adapter.h
index a1e8ef7..a5225c0 100644
--- a/drivers/net/cxgbe/base/adapter.h
+++ b/drivers/net/cxgbe/base/adapter.h
@@ -473,6 +473,15 @@ static inline void t4_os_unlock(rte_spinlock_t *lock)
 }

 /**
+ * t4_os_trylock - try to get a lock
+ * @lock: the spinlock
+ */
+static inline int t4_os_trylock(rte_spinlock_t *lock)
+{
+   return rte_spinlock_trylock(lock);
+}
+
+/**
  * t4_os_init_list_head - initialize
  * @head: head of list to initialize [to empty]
  */
diff --git a/drivers/net/cxgbe/sge.c b/drivers/net/cxgbe/sge.c
index aa0c2e5..51449e0 100644
--- a/drivers/net/cxgbe/sge.c
+++ b/drivers/net/cxgbe/sge.c
@@ -808,20 +808,23 @@ static void tx_timer_cb(void *data)
struct adapter *adap = (struct adapter *)data;
struct sge_eth_txq *txq = >sge.ethtxq[0];
int i;
+   unsigned int coal_idx;

/* monitor any pending tx */
for (i = 0; i < adap->sge.max_ethqsets; i++, txq++) {
-   t4_os_lock(>txq_lock);
-   if (txq->q.coalesce.idx) {
-   if (txq->q.coalesce.idx == txq->q.last_coal_idx &&
-   txq->q.pidx == txq->q.last_pidx) {
-   ship_tx_pkt_coalesce_wr(adap, txq);
-   } else {
-   txq->q.last_coal_idx = txq->q.coalesce.idx;
-   txq->q.last_pidx = txq->q.pidx;
+   if (t4_os_trylock(>txq_lock)) {
+   coal_idx = txq->q.coalesce.idx;
+   if (coal_idx) {
+   if (coal_idx == txq->q.last_coal_idx &&
+   txq->q.pidx == txq->q.last_pidx) {
+   ship_tx_pkt_coalesce_wr(adap, txq);
+   } else {
+   txq->q.last_coal_idx = coal_idx;
+   txq->q.last_pidx = txq->q.pidx;
+   }
}
+   t4_os_unlock(>txq_lock);
}
-   t4_os_unlock(>txq_lock);
}
rte_eal_alarm_set(50, tx_timer_cb, (void *)adap);
 }
-- 
2.5.3



[dpdk-dev] |ERROR| pw 9018 ethdev: add a missing sanity check for nb_tx_desc during txq setup

2015-11-20 Thread Rahul Lakkireddy
Hi all,

I received this auto email regarding 'Unexpected Packets Drop' and
it is referring to my patch.  I don't think I've changed anything that
could cause this.  Kindly advise.

Thanks,
Rahul

On Friday, November 11/20/15, 2015 at 03:14:51 -0800, sys_stv at intel.com 
wrote:
> Test-Label: Intel Niantic on Fedora
> Test-Status: ERROR
> Patchwork: http://www.dpdk.org/dev/patchwork/patch/9018/
> 
> DPDK git baseline: e64833f2273ac67becbca10d9f2f1598872dc99e
> Patchwork ID: 9018
> http://www.dpdk.org/dev/patchwork/patch/9018/
> Submitter: Rahul Lakkireddy 
> Date: Fri, 20 Nov 2015 15:56:37 +0530
> 
> Source Compilation:
> OS: fedora
> Nic: niantic
> i686-native-linuxapp-gcc: compile pass
> x86_64-native-linuxapp-gcc: compile pass
> 
> DTS validation: 
> OS: fedora
> Nic: Niantic
> TestType: auto
> GCC: 4
> x86_64-native-linuxapp-gcc:  total 79, passed 78, failed 1.
> Failed Case List:
> Target: x86_64-native-linuxapp-gcc
> OS: fedora
> Failed DTS case: 
> checksum_offload_with_vlan: 
> http://dpdk.org/browse/tools/dts/tree/test_plans/checksum_offload_test_plan.rst
> 
> DTS Validation Error:
> 
> 
> TEST SUITE : TestChecksumOffload
> 
> ---
> Begin: Test Casetest_checksum_offload_with_vlan
> --
> FAILED  'Unexpected Packets Drop'
> --
> [   SUITE_DUT_CMD]  ./x86_64-native-linuxapp-gcc/app/testpmd -c 0x6 -n 4  -- 
> -i --portmask=0x3 --disable-hw-vlan --enable-rx-cksum --crc-strip --txqflags=0
> [   SUITE_DUT_CMD]  set verbose 1
> [   SUITE_DUT_CMD]  set fwd csum
> [   SUITE_DUT_CMD]  csum set ip hw 0
> [   SUITE_DUT_CMD]  csum set udp hw 0
> [   SUITE_DUT_CMD]  csum set tcp hw 0
> [   SUITE_DUT_CMD]  csum set sctp hw 0
> [   SUITE_DUT_CMD]  csum set ip hw 1
> [   SUITE_DUT_CMD]  csum set udp hw 1
> [   SUITE_DUT_CMD]  csum set tcp hw 1
> [   SUITE_DUT_CMD]  csum set sctp hw 1
> [   SUITE_DUT_CMD]  start
> [SUITE_TESTER_CMD]  scapy
> [SUITE_TESTER_CMD]  sys.path.append("./")
> [SUITE_TESTER_CMD]  from sctp import *
> [SUITE_TESTER_CMD]  p = 
> Ether(dst="90:e2:ba:4a:54:81")/IPv6(src="::2")/UDP()/("X"*46)
> [SUITE_TESTER_CMD]  p.show2()
> [SUITE_TESTER_CMD]  p = 
> Ether(dst="90:e2:ba:4a:54:81")/IP(src="127.0.0.2")/SCTP()/("X"*48)
> [SUITE_TESTER_CMD]  p.show2()
> [SUITE_TESTER_CMD]  p = 
> Ether(dst="90:e2:ba:4a:54:81")/IPv6(src="::2")/TCP()/("X"*46)
> [SUITE_TESTER_CMD]  p.show2()
> [SUITE_TESTER_CMD]  p = 
> Ether(dst="90:e2:ba:4a:54:81")/IP(src="127.0.0.2")/UDP()/("X"*46)
> [SUITE_TESTER_CMD]  p.show2()
> [SUITE_TESTER_CMD]  p = 
> Ether(dst="90:e2:ba:4a:54:81")/IP(src="127.0.0.2")/TCP()/("X"*46)
> [SUITE_TESTER_CMD]  p.show2()
> [SUITE_TESTER_CMD]  exit()
> [SUITE_TESTER_CMD]  echo -n '' >  scapyResult.txt
> [SUITE_TESTER_CMD]  scp sniff.py root at 10.239.128.80:~/
> [SUITE_TESTER_CMD]  SCAPY Receive setup:
> [SUITE_TESTER_CMD]  scapy
> [SUITE_TESTER_CMD]  subprocess.call("scapy -c sniff.py &", shell=True)
> [SUITE_TESTER_CMD]  sys.path.append("./")
> [SUITE_TESTER_CMD]  import sctp
> [SUITE_TESTER_CMD]  from sctp import *
> [SUITE_TESTER_CMD]  
> sendp([Ether(dst="90:e2:ba:4a:54:81")/IPv6(src="::1")/UDP(chksum=0xf)/("X"*46)],
>  iface="p785p2")
> [SUITE_TESTER_CMD]  
> sendp([Ether(dst="90:e2:ba:4a:54:81")/IP(chksum=0x0)/SCTP(chksum=0xf)/("X"*48)],
>  iface="p785p2")
> [SUITE_TESTER_CMD]  
> sendp([Ether(dst="90:e2:ba:4a:54:81")/IPv6(src="::1")/TCP(chksum=0xf)/("X"*46)],
>  iface="p785p2")
> [SUITE_TESTER_CMD]  
> sendp([Ether(dst="90:e2:ba:4a:54:81")/IP(chksum=0x0)/UDP(chksum=0xf)/("X"*46)],
>  iface="p785p2")
> [SUITE_TESTER_CMD]  
> sendp([Ether(dst="90:e2:ba:4a:54:81")/IP(chksum=0x0)/TCP(chksum=0xf)/("X"*46)],
>  iface="p785p2")
> [SUITE_TESTER_CMD]  exit()
> [SUITE_TESTER_CMD]  cat scapyResult.txt
> [SUITE_TESTER_CMD]  SCAPY Result:
> End test_checksum_offload_with_vlan
> ---
> [SUITE_DUT_CMD] quit
> 
> 
> 
> DPDK STV team 


[dpdk-dev] Query on Filtering Support in DPDK

2015-11-30 Thread Rahul Lakkireddy
Hi,

We are working towards adding h/w based filtering support in cxgbe PMD.

Chelsio T5 supports carrying out filtering in hardware which supports 3
actions to carry out on a packet which hit a filter viz.

1. Action Pass - Packets hitting a filter rule can be directed to a
   particular RXQ.

2. Action Drop - Packets hitting a filter rule are dropped in h/w.

3. Action Switch - Packets hitting a filter rule can be switched in h/w
   from one port to another, without involvement of host.  Also, the
   action Switch also supports rewrite of src-mac/dst-mac headers as
   well as rewrite of vlan headers.  It also supports rewrite of IP
   headers and thereby, supports NAT (Network Address Translation)
   in h/w.

Also, each filter rule can optionally support specifying a mask value
i.e. it's possible to create a filter rule for an entire subnet of IP
addresses or a range of tcp/udp ports, etc.

We went through the existing filtering support (ethertype_filter,
syn_filter, ntuple_filter, flow_director) and have some questions on how
to accommodate the various h/w filtering features supported by Chelsio T5
by extending DPDK filtering support.

Some of the features that we would like to accommodate in DPDK filtering
are:

1. Add a new action 'switch' that will:
   * Allow re-direction to different ports in hardware.

   Also, for such a rule, additionally support below:

   * Allow source mac/destination mac and vlan header re-writing to be
 done by the hardware.

   * Allow re-write of TCP/IP headers to perform NAT in hardware.

2. Add ability to mask individual fields at a particular layer for each
   filter in flow_director. For example, mask all ip packets coming from
   a particular subnet mask and particular range of l4 ports for each
   filter rule.

We would like to get some suggestions on how to proceed with adding the
above features.

Thanks,
Rahul


[dpdk-dev] [PATCH 0/6] cxgbe: Optimize tx/rx for 40GbE and add Jumbo Frame support for CXGBE PMD

2015-10-02 Thread Rahul Lakkireddy
This series of patches improve forwarding performance for Chelsio T5 40GbE
cards and add Jumbo Frame support for cxgbe pmd. Also update documentation
and release notes.

Rahul Lakkireddy (6):
  cxgbe: Optimize forwarding performance for 40G
  cxgbe: Update device info and perform sanity checks to enable jumbo
frames
  cxgbe: Update tx path to transmit jumbo frames
  cxgbe: Update rx path to receive jumbo frames
  cxgbe: Allow apps to change mtu
  doc: Update cxgbe documentation and release notes

 doc/guides/nics/cxgbe.rst|  81 -
 doc/guides/rel_notes/release_2_2.rst |   5 +
 drivers/net/cxgbe/base/t4_regs.h |  16 
 drivers/net/cxgbe/cxgbe.h|   3 +
 drivers/net/cxgbe/cxgbe_ethdev.c |  52 ++-
 drivers/net/cxgbe/cxgbe_main.c   |  10 +-
 drivers/net/cxgbe/sge.c  | 171 ++-
 7 files changed, 268 insertions(+), 70 deletions(-)

-- 
2.5.3



[dpdk-dev] [PATCH 1/6] cxgbe: Optimize forwarding performance for 40G

2015-10-02 Thread Rahul Lakkireddy
Update sge initialization with respect to free-list manager configuration
and ingress arbiter. Also update refill logic to refill mbufs only after
a certain threshold for rx.  Optimize tx packet prefetch and free.

Approx. 4 MPPS improvement seen in forwarding performance after the
optimization.

Signed-off-by: Rahul Lakkireddy 
Signed-off-by: Kumar Sanghvi 
---
 drivers/net/cxgbe/base/t4_regs.h | 16 
 drivers/net/cxgbe/cxgbe_main.c   |  7 +++
 drivers/net/cxgbe/sge.c  | 17 -
 3 files changed, 35 insertions(+), 5 deletions(-)

diff --git a/drivers/net/cxgbe/base/t4_regs.h b/drivers/net/cxgbe/base/t4_regs.h
index cd28b59..9057e40 100644
--- a/drivers/net/cxgbe/base/t4_regs.h
+++ b/drivers/net/cxgbe/base/t4_regs.h
@@ -266,6 +266,18 @@
 #define A_SGE_FL_BUFFER_SIZE2 0x104c
 #define A_SGE_FL_BUFFER_SIZE3 0x1050

+#define A_SGE_FLM_CFG 0x1090
+
+#define S_CREDITCNT4
+#define M_CREDITCNT0x3U
+#define V_CREDITCNT(x) ((x) << S_CREDITCNT)
+#define G_CREDITCNT(x) (((x) >> S_CREDITCNT) & M_CREDITCNT)
+
+#define S_CREDITCNTPACKING2
+#define M_CREDITCNTPACKING0x3U
+#define V_CREDITCNTPACKING(x) ((x) << S_CREDITCNTPACKING)
+#define G_CREDITCNTPACKING(x) (((x) >> S_CREDITCNTPACKING) & 
M_CREDITCNTPACKING)
+
 #define A_SGE_CONM_CTRL 0x1094

 #define S_EGRTHRESHOLD8
@@ -361,6 +373,10 @@

 #define A_SGE_CONTROL2 0x1124

+#define S_IDMAARBROUNDROBIN19
+#define V_IDMAARBROUNDROBIN(x) ((x) << S_IDMAARBROUNDROBIN)
+#define F_IDMAARBROUNDROBINV_IDMAARBROUNDROBIN(1U)
+
 #define S_INGPACKBOUNDARY16
 #define M_INGPACKBOUNDARY0x7U
 #define V_INGPACKBOUNDARY(x) ((x) << S_INGPACKBOUNDARY)
diff --git a/drivers/net/cxgbe/cxgbe_main.c b/drivers/net/cxgbe/cxgbe_main.c
index 3755444..316b87d 100644
--- a/drivers/net/cxgbe/cxgbe_main.c
+++ b/drivers/net/cxgbe/cxgbe_main.c
@@ -422,6 +422,13 @@ static int adap_init0_tweaks(struct adapter *adapter)
t4_set_reg_field(adapter, A_SGE_CONTROL, V_PKTSHIFT(M_PKTSHIFT),
 V_PKTSHIFT(rx_dma_offset));

+   t4_set_reg_field(adapter, A_SGE_FLM_CFG,
+V_CREDITCNT(M_CREDITCNT) | M_CREDITCNTPACKING,
+V_CREDITCNT(3) | V_CREDITCNTPACKING(1));
+
+   t4_set_reg_field(adapter, A_SGE_CONTROL2, V_IDMAARBROUNDROBIN(1U),
+V_IDMAARBROUNDROBIN(1U));
+
/*
 * Don't include the "IP Pseudo Header" in CPL_RX_PKT checksums: Linux
 * adds the pseudo header itself.
diff --git a/drivers/net/cxgbe/sge.c b/drivers/net/cxgbe/sge.c
index 6eb1244..e540881 100644
--- a/drivers/net/cxgbe/sge.c
+++ b/drivers/net/cxgbe/sge.c
@@ -286,8 +286,7 @@ static void unmap_rx_buf(struct sge_fl *q)

 static inline void ring_fl_db(struct adapter *adap, struct sge_fl *q)
 {
-   /* see if we have exceeded q->size / 4 */
-   if (q->pend_cred >= (q->size / 4)) {
+   if (q->pend_cred >= 64) {
u32 val = adap->params.arch.sge_fl_db;

if (is_t4(adap->params.chip))
@@ -995,7 +994,14 @@ static inline int tx_do_packet_coalesce(struct sge_eth_txq 
*txq,
int i;

for (i = 0; i < sd->coalesce.idx; i++) {
-   rte_pktmbuf_free(sd->coalesce.mbuf[i]);
+   struct rte_mbuf *tmp = sd->coalesce.mbuf[i];
+
+   do {
+   struct rte_mbuf *next = tmp->next;
+
+   rte_pktmbuf_free_seg(tmp);
+   tmp = next;
+   } while (tmp);
sd->coalesce.mbuf[i] = NULL;
}
}
@@ -1054,7 +1060,6 @@ out_free:
return 0;
}

-   rte_prefetch0(&((>q)->sdesc->mbuf->pool));
pi = (struct port_info *)txq->eth_dev->data->dev_private;
adap = pi->adapter;

@@ -1070,6 +1075,7 @@ out_free:
txq->stats.mapping_err++;
goto out_free;
}
+   rte_prefetch0((volatile void *)addr);
return tx_do_packet_coalesce(txq, mbuf, cflits, adap,
 pi, addr);
} else {
@@ -1454,7 +1460,8 @@ static int process_responses(struct sge_rspq *q, int 
budget,
unsigned int params;
u32 val;

-   __refill_fl(q->adapter, >fl);
+   if (fl_cap(>fl) - rxq->fl.avail >= 64)
+   __refill_fl(q->adapter, >fl);
params = V_QINTR_TIMER_IDX(X_TIMERREG_UPDATE_CIDX);
q->next_intr_params = params;
val = V_CIDXINC(cidx_inc) | V_SEINTARM(params);
-- 
2.5.3



[dpdk-dev] [PATCH 2/6] cxgbe: Update device info and perform sanity checks to enable jumbo frames

2015-10-02 Thread Rahul Lakkireddy
Increase max_rx_pktlen to accommodate jumbo frame size. Perform sanity
checks and enable jumbo mode in rx queue setup. Set link mtu based on
max_rx_pktlen.

Signed-off-by: Rahul Lakkireddy 
Signed-off-by: Kumar Sanghvi 
---
 drivers/net/cxgbe/cxgbe.h|  3 +++
 drivers/net/cxgbe/cxgbe_ethdev.c | 23 +--
 drivers/net/cxgbe/cxgbe_main.c   |  3 ++-
 3 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/drivers/net/cxgbe/cxgbe.h b/drivers/net/cxgbe/cxgbe.h
index 97c37d2..adc0d92 100644
--- a/drivers/net/cxgbe/cxgbe.h
+++ b/drivers/net/cxgbe/cxgbe.h
@@ -43,6 +43,9 @@
 #define CXGBE_DEFAULT_TX_DESC_SIZE1024 /* Default TX ring size */
 #define CXGBE_DEFAULT_RX_DESC_SIZE1024 /* Default RX ring size */

+#define CXGBE_MIN_RX_BUFSIZE ETHER_MIN_MTU /* min buf size */
+#define CXGBE_MAX_RX_PKTLEN (9000 + ETHER_HDR_LEN + ETHER_CRC_LEN) /* max pkt 
*/
+
 int cxgbe_probe(struct adapter *adapter);
 int cxgbe_up(struct adapter *adap);
 int cxgbe_down(struct port_info *pi);
diff --git a/drivers/net/cxgbe/cxgbe_ethdev.c b/drivers/net/cxgbe/cxgbe_ethdev.c
index 478051a..6d7b29c 100644
--- a/drivers/net/cxgbe/cxgbe_ethdev.c
+++ b/drivers/net/cxgbe/cxgbe_ethdev.c
@@ -141,8 +141,8 @@ static void cxgbe_dev_info_get(struct rte_eth_dev *eth_dev,
struct adapter *adapter = pi->adapter;
int max_queues = adapter->sge.max_ethqsets / adapter->params.nports;

-   device_info->min_rx_bufsize = 68; /* XXX: Smallest pkt size */
-   device_info->max_rx_pktlen = 1500; /* XXX: For now we support mtu */
+   device_info->min_rx_bufsize = CXGBE_MIN_RX_BUFSIZE;
+   device_info->max_rx_pktlen = CXGBE_MAX_RX_PKTLEN;
device_info->max_rx_queues = max_queues;
device_info->max_tx_queues = max_queues;
device_info->max_mac_addrs = 1;
@@ -498,6 +498,8 @@ static int cxgbe_dev_rx_queue_setup(struct rte_eth_dev 
*eth_dev,
int err = 0;
int msi_idx = 0;
unsigned int temp_nb_desc;
+   struct rte_eth_dev_info dev_info;
+   unsigned int pkt_len = eth_dev->data->dev_conf.rxmode.max_rx_pkt_len;

RTE_SET_USED(rx_conf);

@@ -505,6 +507,17 @@ static int cxgbe_dev_rx_queue_setup(struct rte_eth_dev 
*eth_dev,
  __func__, eth_dev->data->nb_rx_queues, queue_idx, nb_desc,
  socket_id, mp);

+   cxgbe_dev_info_get(eth_dev, _info);
+
+   /* Must accommodate at least ETHER_MIN_MTU */
+   if ((pkt_len < dev_info.min_rx_bufsize) ||
+   (pkt_len > dev_info.max_rx_pktlen)) {
+   dev_err(adap, "%s: max pkt len must be > %d and <= %d\n",
+   __func__, dev_info.min_rx_bufsize,
+   dev_info.max_rx_pktlen);
+   return -EINVAL;
+   }
+
/*  Free up the existing queue  */
if (eth_dev->data->rx_queues[queue_idx]) {
cxgbe_dev_rx_queue_release(eth_dev->data->rx_queues[queue_idx]);
@@ -534,6 +547,12 @@ static int cxgbe_dev_rx_queue_setup(struct rte_eth_dev 
*eth_dev,
if ((>fl) != NULL)
rxq->fl.size = temp_nb_desc;

+   /* Set to jumbo mode if necessary */
+   if (pkt_len > ETHER_MAX_LEN)
+   eth_dev->data->dev_conf.rxmode.jumbo_frame = 1;
+   else
+   eth_dev->data->dev_conf.rxmode.jumbo_frame = 0;
+
err = t4_sge_alloc_rxq(adapter, >rspq, false, eth_dev, msi_idx,
   >fl, t4_ethrx_handler,
   t4_get_mps_bg_map(adapter, pi->tx_chan), mp,
diff --git a/drivers/net/cxgbe/cxgbe_main.c b/drivers/net/cxgbe/cxgbe_main.c
index 316b87d..aff23d0 100644
--- a/drivers/net/cxgbe/cxgbe_main.c
+++ b/drivers/net/cxgbe/cxgbe_main.c
@@ -855,12 +855,13 @@ int link_start(struct port_info *pi)
 {
struct adapter *adapter = pi->adapter;
int ret;
+   unsigned int mtu = pi->eth_dev->data->dev_conf.rxmode.max_rx_pkt_len;

/*
 * We do not set address filters and promiscuity here, the stack does
 * that step explicitly.
 */
-   ret = t4_set_rxmode(adapter, adapter->mbox, pi->viid, 1500, -1, -1,
+   ret = t4_set_rxmode(adapter, adapter->mbox, pi->viid, mtu, -1, -1,
-1, 1, true);
if (ret == 0) {
ret = t4_change_mac(adapter, adapter->mbox, pi->viid,
-- 
2.5.3



[dpdk-dev] [PATCH 3/6] cxgbe: Update tx path to transmit jumbo frames

2015-10-02 Thread Rahul Lakkireddy
Add a non-coalesce path.  Skip coalescing for Jumbo Frames, and send the
packet through non-coalesced path if there are enough credits.  Also,
free these non-coalesced packets while reclaiming credits.

Signed-off-by: Rahul Lakkireddy 
Signed-off-by: Kumar Sanghvi 
---
 drivers/net/cxgbe/sge.c | 96 -
 1 file changed, 64 insertions(+), 32 deletions(-)

diff --git a/drivers/net/cxgbe/sge.c b/drivers/net/cxgbe/sge.c
index e540881..921173a 100644
--- a/drivers/net/cxgbe/sge.c
+++ b/drivers/net/cxgbe/sge.c
@@ -199,11 +199,20 @@ static void free_tx_desc(struct sge_txq *q, unsigned int 
n)

 static void reclaim_tx_desc(struct sge_txq *q, unsigned int n)
 {
+   struct tx_sw_desc *d;
unsigned int cidx = q->cidx;

+   d = >sdesc[cidx];
while (n--) {
-   if (++cidx == q->size)
+   if (d->mbuf) {   /* an SGL is present */
+   rte_pktmbuf_free(d->mbuf);
+   d->mbuf = NULL;
+   }
+   ++d;
+   if (++cidx == q->size) {
cidx = 0;
+   d = q->sdesc;
+   }
}
q->cidx = cidx;
 }
@@ -1045,6 +1054,7 @@ int t4_eth_xmit(struct sge_eth_txq *txq, struct rte_mbuf 
*mbuf)
u32 wr_mid;
u64 cntrl, *end;
bool v6;
+   u32 max_pkt_len = txq->eth_dev->data->dev_conf.rxmode.max_rx_pkt_len;

/* Reject xmit if queue is stopped */
if (unlikely(txq->flags & EQ_STOPPED))
@@ -1060,6 +1070,10 @@ out_free:
return 0;
}

+   if ((!(m->ol_flags & PKT_TX_TCP_SEG)) &&
+   (unlikely(m->pkt_len > max_pkt_len)))
+   goto out_free;
+
pi = (struct port_info *)txq->eth_dev->data->dev_private;
adap = pi->adapter;

@@ -1067,7 +1081,7 @@ out_free:
/* align the end of coalesce WR to a 512 byte boundary */
txq->q.coalesce.max = (8 - (txq->q.pidx & 7)) * 8;

-   if (!(m->ol_flags & PKT_TX_TCP_SEG)) {
+   if (!((m->ol_flags & PKT_TX_TCP_SEG) || (m->pkt_len > ETHER_MAX_LEN))) {
if (should_tx_packet_coalesce(txq, mbuf, , adap)) {
if (unlikely(map_mbuf(mbuf, addr) < 0)) {
dev_warn(adap, "%s: mapping err for coalesce\n",
@@ -1114,33 +1128,46 @@ out_free:

len = 0;
len += sizeof(*cpl);
-   lso = (void *)(wr + 1);
-   v6 = (m->ol_flags & PKT_TX_IPV6) != 0;
-   l3hdr_len = m->l3_len;
-   l4hdr_len = m->l4_len;
-   eth_xtra_len = m->l2_len - ETHER_HDR_LEN;
-   len += sizeof(*lso);
-   wr->op_immdlen = htonl(V_FW_WR_OP(FW_ETH_TX_PKT_WR) |
-  V_FW_WR_IMMDLEN(len));
-   lso->lso_ctrl = htonl(V_LSO_OPCODE(CPL_TX_PKT_LSO) |
- F_LSO_FIRST_SLICE | F_LSO_LAST_SLICE |
- V_LSO_IPV6(v6) |
- V_LSO_ETHHDR_LEN(eth_xtra_len / 4) |
- V_LSO_IPHDR_LEN(l3hdr_len / 4) |
- V_LSO_TCPHDR_LEN(l4hdr_len / 4));
-   lso->ipid_ofst = htons(0);
-   lso->mss = htons(m->tso_segsz);
-   lso->seqno_offset = htonl(0);
-   if (is_t4(adap->params.chip))
-   lso->len = htonl(m->pkt_len);
-   else
-   lso->len = htonl(V_LSO_T5_XFER_SIZE(m->pkt_len));
-   cpl = (void *)(lso + 1);
-   cntrl = V_TXPKT_CSUM_TYPE(v6 ? TX_CSUM_TCPIP6 : TX_CSUM_TCPIP) |
- V_TXPKT_IPHDR_LEN(l3hdr_len) |
- V_TXPKT_ETHHDR_LEN(eth_xtra_len);
-   txq->stats.tso++;
-   txq->stats.tx_cso += m->tso_segsz;
+
+   /* Coalescing skipped and we send through normal path */
+   if (!(m->ol_flags & PKT_TX_TCP_SEG)) {
+   wr->op_immdlen = htonl(V_FW_WR_OP(FW_ETH_TX_PKT_WR) |
+  V_FW_WR_IMMDLEN(len));
+   cpl = (void *)(wr + 1);
+   if (m->ol_flags & PKT_TX_IP_CKSUM) {
+   cntrl = hwcsum(adap->params.chip, m) |
+   F_TXPKT_IPCSUM_DIS;
+   txq->stats.tx_cso++;
+   }
+   } else {
+   lso = (void *)(wr + 1);
+   v6 = (m->ol_flags & PKT_TX_IPV6) != 0;
+   l3hdr_len = m->l3_len;
+   l4hdr_len = m->l4_len;
+   eth_xtra_len = m->l2_len - ETHER_HDR_LEN;
+   len += sizeof(*lso);
+   wr->op_immdlen = htonl(V_FW_WR_OP(FW_ETH_TX_PKT_WR) |
+  V_FW_WR_IMMDLEN(len));
+   lso->lso_ctrl = htonl(V_LSO_OPCODE(CPL_TX_PKT_LSO) |
+ 

[dpdk-dev] [PATCH 4/6] cxgbe: Update rx path to receive jumbo frames

2015-10-02 Thread Rahul Lakkireddy
Ensure jumbo mode is enabled and that the mbuf data room size can
accommodate jumbo size.  If the mbuf data room size can't accommodate
jumbo size, chain mbufs to jumbo size.

Signed-off-by: Rahul Lakkireddy 
Signed-off-by: Kumar Sanghvi 
---
 drivers/net/cxgbe/sge.c | 58 -
 1 file changed, 53 insertions(+), 5 deletions(-)

diff --git a/drivers/net/cxgbe/sge.c b/drivers/net/cxgbe/sge.c
index 921173a..91ef363 100644
--- a/drivers/net/cxgbe/sge.c
+++ b/drivers/net/cxgbe/sge.c
@@ -247,6 +247,29 @@ static inline bool fl_starving(const struct adapter 
*adapter,
return fl->avail - fl->pend_cred <= s->fl_starve_thres;
 }

+static inline unsigned int get_buf_size(struct adapter *adapter,
+   const struct rx_sw_desc *d)
+{
+   unsigned int rx_buf_size_idx = d->dma_addr & RX_BUF_SIZE;
+   unsigned int buf_size = 0;
+
+   switch (rx_buf_size_idx) {
+   case RX_SMALL_MTU_BUF:
+   buf_size = FL_MTU_SMALL_BUFSIZE(adapter);
+   break;
+
+   case RX_LARGE_MTU_BUF:
+   buf_size = FL_MTU_LARGE_BUFSIZE(adapter);
+   break;
+
+   default:
+   BUG_ON(1);
+   /* NOT REACHED */
+   }
+
+   return buf_size;
+}
+
 /**
  * free_rx_bufs - free the Rx buffers on an SGE free list
  * @q: the SGE free list to free buffers from
@@ -362,6 +385,14 @@ static unsigned int refill_fl_usembufs(struct adapter 
*adap, struct sge_fl *q,
unsigned int buf_size_idx = RX_SMALL_MTU_BUF;
struct rte_mbuf *buf_bulk[n];
int ret, i;
+   struct rte_pktmbuf_pool_private *mbp_priv;
+   u8 jumbo_en = rxq->rspq.eth_dev->data->dev_conf.rxmode.jumbo_frame;
+
+   /* Use jumbo mtu buffers iff mbuf data room size can fit jumbo data. */
+   mbp_priv = rte_mempool_get_priv(rxq->rspq.mb_pool);
+   if (jumbo_en &&
+   ((mbp_priv->mbuf_data_room_size - RTE_PKTMBUF_HEADROOM) >= 9000))
+   buf_size_idx = RX_LARGE_MTU_BUF;

ret = rte_mempool_get_bulk(rxq->rspq.mb_pool, (void *)buf_bulk, n);
if (unlikely(ret != 0)) {
@@ -1439,14 +1470,31 @@ static int process_responses(struct sge_rspq *q, int 
budget,
const struct cpl_rx_pkt *cpl =
(const void *)>cur_desc[1];
bool csum_ok = cpl->csum_calc && !cpl->err_vec;
-   struct rte_mbuf *pkt;
-   u32 len = ntohl(rc->pldbuflen_qid);
+   struct rte_mbuf *pkt, *npkt;
+   u32 len, bufsz;

+   len = ntohl(rc->pldbuflen_qid);
BUG_ON(!(len & F_RSPD_NEWBUF));
pkt = rsd->buf;
-   pkt->data_len = G_RSPD_LEN(len);
-   pkt->pkt_len = pkt->data_len;
-   unmap_rx_buf(>fl);
+   npkt = pkt;
+   len = G_RSPD_LEN(len);
+   pkt->pkt_len = len;
+
+   /* Chain mbufs into len if necessary */
+   while (len) {
+   struct rte_mbuf *new_pkt = rsd->buf;
+
+   bufsz = min(get_buf_size(q->adapter, rsd), len);
+   new_pkt->data_len = bufsz;
+   unmap_rx_buf(>fl);
+   len -= bufsz;
+   npkt->next = new_pkt;
+   npkt = new_pkt;
+   pkt->nb_segs++;
+   rsd = >fl.sdesc[rxq->fl.cidx];
+   }
+   npkt->next = NULL;
+   pkt->nb_segs--;

if (cpl->l2info & htonl(F_RXF_IP)) {
pkt->packet_type = RTE_PTYPE_L3_IPV4;
-- 
2.5.3



  1   2   >