[dpdk-dev] [PATCH] scripts: check cc stable mailing list in commit

2016-11-21 Thread Thomas Monjalon
Add a check for commits fixing a released bug.
Such commits are found thanks to scripts/git-log-fixes.sh.
They must be sent CC: stable at dpdk.org.
In order to avoid forgetting CC, this mail header can be written
in the git commit message.

Signed-off-by: Thomas Monjalon 
---
 scripts/check-git-log.sh | 9 +
 1 file changed, 9 insertions(+)

diff --git a/scripts/check-git-log.sh b/scripts/check-git-log.sh
index 5f8a9fc..4f98a7a 100755
--- a/scripts/check-git-log.sh
+++ b/scripts/check-git-log.sh
@@ -47,12 +47,14 @@ if [ "$1" = '-h' -o "$1" = '--help' ] ; then
exit
 fi

+selfdir=$(dirname $(readlink -e $0))
 range=${1:-origin/master..}

 commits=$(git log --format='%h' --reverse $range)
 headlines=$(git log --format='%s' --reverse $range)
 bodylines=$(git log --format='%b' --reverse $range)
 fixes=$(git log --format='%h %s' --reverse $range | grep -i ': *fix' | cut -d' 
' -f1)
+stablefixes=$($selfdir/git-log-fixes.sh $range | sed '/(N\/A)$/d'  | cut -d' ' 
-f2)
 tags=$(git log --format='%b' --reverse $range | grep -i -e 'by *:' -e 'fix.*:')
 bytag='\(Reported\|Suggested\|Signed-off\|Acked\|Reviewed\|Tested\)-by:'

@@ -191,3 +193,10 @@ bad=$(for fixtag in $fixtags ; do
printf "$fixtag" | grep -v "^$good$"
 done | sed 's,^,\t,')
 [ -z "$bad" ] || printf "Wrong 'Fixes' reference:\n$bad\n"
+
+# check CC:stable for fixes
+bad=$(for fix in $stablefixes ; do
+   git log --format='%b' -1 $fix | grep -qi '^CC: *stable at dpdk.org' ||
+   git log --format='\t%s' -1 $fix
+done)
+[ -z "$bad" ] || printf "Should CC: stable at dpdk.org\n$bad\n"
-- 
2.7.0



[dpdk-dev] [PATCH] scripts: fix checkpatch from standard input

2016-11-21 Thread Thomas Monjalon
When checking a valid patch from standard input,
the footer lines of the report are not filtered out.

The function check is called outside of any loop,
so the statement continue has no effect and the footer is printed.

Fixes: 8005feef421d ("scripts: add standard input to checkpatch")

Signed-off-by: Thomas Monjalon 
---
 scripts/checkpatches.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/checkpatches.sh b/scripts/checkpatches.sh
index 336cc7b..cfe262b 100755
--- a/scripts/checkpatches.sh
+++ b/scripts/checkpatches.sh
@@ -94,7 +94,7 @@ check () { #   
else
report=$($DPDK_CHECKPATCH_PATH $options - 2>/dev/null)
fi
-   [ $? -ne 0 ] || continue
+   [ $? -ne 0 ] || return 0
$verbose || printf '\n### %s\n\n' "$3"
printf '%s\n' "$report" | sed -n '1,/^total:.*lines checked$/p'
status=$(($status + 1))
-- 
2.7.0



[dpdk-dev] [PATCH] eal: postpone vdev initialization

2016-11-21 Thread Jerin Jacob
On Mon, Nov 21, 2016 at 09:54:57AM +, Ferruh Yigit wrote:
> On 11/20/2016 8:00 AM, Jerin Jacob wrote:
> > Some platform like octeontx may use pci and
> > vdev based combined device to represent a logical
> > dpdk functional device.In such case, postponing the
> > vdev initialization after pci device
> > initialization will provide the better view of
> > the pci device resources in the system in
> > vdev's probe function, and it allows better
> > functional subsystem registration in vdev probe
> > function.
> > 
> > As a bonus, This patch fixes a bond device
> > initialization use case.
> > 
> > example command to reproduce the issue:
> > ./testpmd -c 0x2  --vdev 'eth_bond0,mode=0,
> > slave=:02:00.0,slave=:03:00.0' --
> > --port-topology=chained
> > 
> > root cause:
> > In existing case(vdev initialization and then pci
> > initialization), creates three Ethernet ports with
> > following port ids
> > 0 - Bond device
> > 1 - PCI device 0
> > 2 - PCI devive 1
> > 
> > Since testpmd, calls the configure/start on all the ports on
> > start up,it will translate to following illegal setup sequence
> > 
> > 1)bond device configure/start
> > 1.1) pci device0 stop/configure/start
> > 1.2) pci device1 stop/configure/start
> > 2)pci device 0 configure(illegal setup case,
> > as device in start state)
> > 
> > The fix changes the initialization sequence and
> > allow initialization in following valid setup order
> > 1) pcie device 0 configure/start
> > 2) pcie device 1 configure/start
> > 3) bond device 2 configure/start
> > 3.1) pcie device 0/stop/configure/start
> > 3.2) pcie device 1/stop/configure/start
> > 
> > Signed-off-by: Jerin Jacob 
> > ---
> 
> This changes the port id assignments to the devices, right?
> 
> Previously virtual devices get first available port ids (0..N1), later
> physical devices (N1..N2). Now this becomes reverse.
> 
> Can this change break some existing user applications?

I guess it may be effected only to ethdev bond pmd based application,
which is broken anyway.
Let me know what it takes to make forward progress on this patch. I can
fix the same in v2.

Jerin



[dpdk-dev] 16.07.2 stable patches review and test

2016-11-21 Thread Yuanhan Liu
Hi all,

Here is a list of patches targeted for 16.07.2 release. Please help
reviewing and testing. The planned date for the final release is 30th,
Nov. Before that, please shout if anyone has objections with these
patches being applied, or if I missed some important fixes.

These patches are located at branch 16.07 of dpdk-stable repo:
http://dpdk.org/browse/dpdk-stable/

Please also be noted that this would be the last stable release for 16.07.

Thanks.

--yliu

---
Adrien Mazarguil (1):
  net/mlx5: fix Rx VLAN offload capability report

Ajit Khaparde (1):
  net/bnxt: fix crash when closing

Beilei Xing (1):
  net/i40e: fix floating VEB

Bernard Iremonger (1):
  app/testpmd: fix DCB configuration

David Marchand (1):
  ethdev: fix vendor id in debug message

E. Scott Daniels (1):
  ethdev: prevent duplicate event callback

Eric Kinzie (1):
  net/bonding: validate speed after link up

Ferruh Yigit (4):
  net/ring: fix ring device creation via devargs
  net/bnx2x: fix build with icc
  kni: fix build with kernel 4.8
  kni: fix build with kernel 4.9

Gowrishankar Muthukrishnan (1):
  examples/ip_pipeline: fix plugin loading

Igor Ryzhov (1):
  pci: fix probing error if no driver found

Jasvinder Singh (1):
  examples/qos_sched: fix dequeue from ring

Jeff Guo (1):
  net/i40e: fix hash filter on X722

Jianbo Liu (2):
  eal/arm: fix file descriptor leak when getting CPU features
  eal/ppc: fix file descriptor leak when getting CPU features

Jingjing Wu (2):
  net/i40e: fix DCB configuration
  doc: add limitations for i40e PMD

John Daley (5):
  net/enic: fix flow director
  net/enic: fix crash with removed flow director filters
  net/enic: fix multi-queue Rx performance
  net/enic: fix crash on MTU update or Rx queue reconfigure
  net/enic: fix max packet length check

John W. Linville (4):
  net/ena: improve safety of string handling
  net/bnxt: ensure entry length is unsigned
  net/i40e: do not use VSI before NULL check
  net/bnxt: fix bit shift size

Kamil Rytarowski (1):
  net/thunderx: fix Tx checksum handling

Michael Qiu (2):
  examples/tep_term: fix L4 length
  examples/tep_term: fix packet length with multi-segments

Mohammad Abdul Awal (1):
  app/testpmd: fix RSS hash key size

Nelio Laranjeiro (1):
  net/mlx5: fix Rx checksum macros

Nelson Escobar (3):
  net/enic: revert truncated packets counter fix
  net/enic: document how to configure vNIC parameters
  net/enic: fix Rx queue index when not using Rx scatter

Nipun Gupta (1):
  mempool: fix leak if populate fails

N?lio Laranjeiro (7):
  net/mlx5: fix Rx function selection
  net/mlx5: fix hash key size retrieval
  net/mlx5: support Mellanox OFED 3.4
  net/mlx5: re-factorize functions
  net/mlx5: fix inline logic
  net/mlx5: fix link speed capability information
  net/mlx5: fix support for newer link speeds

Olga Shern (1):
  net/mlx5: fix link status report

Olivier Gournet (1):
  net/mlx5: fix initialization in secondary process

Pablo de Lara (3):
  app/test: fix hash multiwriter sequence
  hash: fix unlimited cuckoo path
  hash: fix bucket size usage

Piotr Azarewicz (1):
  examples/l2fwd-crypto: fix verify with decrypt in chain

Qi Zhang (4):
  net/ixgbe: fix out of order Rx read
  net/fm10k: fix out of order Rx read
  net/i40e: fix Rx hang when disable LLDP
  net/i40e: fix out of order Rx read

Qiming Yang (2):
  net/i40e: fix link status change interrupt
  net/i40e: fix VF bonded device link down

Rasesh Mody (3):
  net/bnx2x: fix maximum PF queues
  net/bnx2x: fix socket id for slowpath memory
  net/qede/base: fix 32-bit build

Raslan Darawsheh (2):
  net/mlx5: fix removing VLAN filter
  net/mlx5: fix handling of small mbuf sizes

Reshma Pattan (2):
  pdump: fix created directory permissions
  app/procinfo: free xstats memory upon failure

Sagi Grimberg (1):
  net/mlx5: fix possible NULL dereference in Rx path

Sergio Gonzalez Monroy (1):
  examples/ipsec-secgw: check SP only when setup

Wei Dai (3):
  lpm: fix freeing unused sub-table on rule delete
  mempool: fix search of maximum contiguous pages
  lpm: fix freeing memory

Wenzhuo Lu (6):
  app/testpmd: fix DCB configuration
  app/testpmd: fix PF/VF check of flow director
  net/ixgbe: fix flow director mask
  app/testpmd: fix flow director mask
  app/testpmd: fix flow director endianness
  net/ixgbe: fix VF registers

Xiao Wang (2):
  net/fm10k: fix Rx checksum flags
  net/fm10k: fix VF Tx queue initialization

Yaacov Hazan (3):
  net/mlx5: fix inconsistent return value in flow director
  net/mlx5: refactor allocation of flow director queues
  net/mlx5: fix flow director drop mode

Yong Wang (1):
  net/vmxnet3: fix mbuf release on reset/stop

Yuanhan Liu (1):
  

[dpdk-dev] [PATCH v2 2/2] net: align ethdev and eal driver names

2016-11-21 Thread David Marchand
Some virtual pmds report a different name than the vdev driver name
registered in eal.
While it does not hurt, let's try to be consistent.

Signed-off-by: David Marchand 
Reviewed-by: Ferruh Yigit 
---
 drivers/net/af_packet/rte_eth_af_packet.c  |  4 +++-
 drivers/net/bonding/rte_eth_bond_api.c |  7 +++
 drivers/net/bonding/rte_eth_bond_pmd.c |  4 ++--
 drivers/net/bonding/rte_eth_bond_private.h |  2 +-
 drivers/net/mpipe/mpipe_tilegx.c   | 21 -
 drivers/net/null/rte_eth_null.c|  4 +++-
 drivers/net/pcap/rte_eth_pcap.c|  4 +++-
 drivers/net/ring/rte_eth_ring.c|  4 +++-
 drivers/net/vhost/rte_eth_vhost.c  |  4 +++-
 drivers/net/virtio/virtio_ethdev.c |  6 +-
 drivers/net/virtio/virtio_ethdev.h |  2 ++
 drivers/net/virtio/virtio_user_ethdev.c|  2 +-
 drivers/net/xenvirt/rte_eth_xenvirt.c  |  3 ++-
 13 files changed, 47 insertions(+), 20 deletions(-)

diff --git a/drivers/net/af_packet/rte_eth_af_packet.c 
b/drivers/net/af_packet/rte_eth_af_packet.c
index a66a657..8cae165 100644
--- a/drivers/net/af_packet/rte_eth_af_packet.c
+++ b/drivers/net/af_packet/rte_eth_af_packet.c
@@ -437,6 +437,8 @@ open_packet_iface(const char *key __rte_unused,
return 0;
 }

+static struct rte_vdev_driver pmd_af_packet_drv;
+
 static int
 rte_pmd_init_internals(const char *name,
const int sockfd,
@@ -690,7 +692,7 @@ rte_pmd_init_internals(const char *name,
(*eth_dev)->dev_ops = 
(*eth_dev)->driver = NULL;
(*eth_dev)->data->dev_flags = RTE_ETH_DEV_DETACHABLE;
-   (*eth_dev)->data->drv_name = "AF_PACKET PMD";
+   (*eth_dev)->data->drv_name = pmd_af_packet_drv.driver.name;
(*eth_dev)->data->kdrv = RTE_KDRV_NONE;
(*eth_dev)->data->numa_node = numa_node;

diff --git a/drivers/net/bonding/rte_eth_bond_api.c 
b/drivers/net/bonding/rte_eth_bond_api.c
index 2a3893a..a4e86ae 100644
--- a/drivers/net/bonding/rte_eth_bond_api.c
+++ b/drivers/net/bonding/rte_eth_bond_api.c
@@ -37,6 +37,7 @@
 #include 
 #include 
 #include 
+#include 

 #include "rte_eth_bond.h"
 #include "rte_eth_bond_private.h"
@@ -44,8 +45,6 @@

 #define DEFAULT_POLLING_INTERVAL_10_MS (10)

-const char pmd_bond_driver_name[] = "rte_bond_pmd";
-
 int
 check_for_bonded_ethdev(const struct rte_eth_dev *eth_dev)
 {
@@ -54,7 +53,7 @@ check_for_bonded_ethdev(const struct rte_eth_dev *eth_dev)
return -1;

/* return 0 if driver name matches */
-   return eth_dev->data->drv_name != pmd_bond_driver_name;
+   return eth_dev->data->drv_name != pmd_bond_drv.driver.name;
 }

 int
@@ -221,7 +220,7 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t 
socket_id)
RTE_ETH_DEV_DETACHABLE;
eth_dev->driver = NULL;
eth_dev->data->kdrv = RTE_KDRV_NONE;
-   eth_dev->data->drv_name = pmd_bond_driver_name;
+   eth_dev->data->drv_name = pmd_bond_drv.driver.name;
eth_dev->data->numa_node =  socket_id;

rte_spinlock_init(>lock);
diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c 
b/drivers/net/bonding/rte_eth_bond_pmd.c
index a80b6fa..9bfd9f6 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -2566,12 +2566,12 @@ bond_ethdev_configure(struct rte_eth_dev *dev)
return 0;
 }

-static struct rte_vdev_driver bond_drv = {
+struct rte_vdev_driver pmd_bond_drv = {
.probe = bond_probe,
.remove = bond_remove,
 };

-RTE_PMD_REGISTER_VDEV(net_bonding, bond_drv);
+RTE_PMD_REGISTER_VDEV(net_bonding, pmd_bond_drv);
 RTE_PMD_REGISTER_ALIAS(net_bonding, eth_bond);

 RTE_PMD_REGISTER_PARAM_STRING(net_bonding,
diff --git a/drivers/net/bonding/rte_eth_bond_private.h 
b/drivers/net/bonding/rte_eth_bond_private.h
index d95d440..5a411e2 100644
--- a/drivers/net/bonding/rte_eth_bond_private.h
+++ b/drivers/net/bonding/rte_eth_bond_private.h
@@ -63,7 +63,7 @@

 extern const char *pmd_bond_init_valid_arguments[];

-extern const char pmd_bond_driver_name[];
+extern struct rte_vdev_driver pmd_bond_drv;

 /** Port Queue Mapping Structure */
 struct bond_rx_queue {
diff --git a/drivers/net/mpipe/mpipe_tilegx.c b/drivers/net/mpipe/mpipe_tilegx.c
index f00..f0ba91e 100644
--- a/drivers/net/mpipe/mpipe_tilegx.c
+++ b/drivers/net/mpipe/mpipe_tilegx.c
@@ -87,7 +87,6 @@ struct mpipe_local {
 static __thread struct mpipe_local mpipe_local;
 static struct mpipe_context mpipe_contexts[GXIO_MPIPE_INSTANCE_MAX];
 static int mpipe_instances;
-static const char *drivername = "MPIPE PMD";

 /* Per queue statistics. */
 struct mpipe_queue_stats {
@@ -1549,7 +1548,7 @@ mpipe_link_mac(const char *ifname, uint8_t *mac)
 }

 static int
-rte_pmd_mpipe_probe(const char *ifname,
+rte_pmd_mpipe_probe_common(struct rte_vdev_driver *drv, const char *ifname,
  const char *params __rte_unused)
 {
gxio_mpipe_context_t *context;
@@ -1606,7 +1605,7 @@ 

[dpdk-dev] Solarflare PMD submission question

2016-11-21 Thread Andrew Rybchenko
On 11/21/2016 01:30 PM, Ferruh Yigit wrote:
> On 11/21/2016 8:59 AM, Thomas Monjalon wrote:
>> 2016-11-21 11:46, Andrew Rybchenko:
>>> On 11/21/2016 11:19 AM, Thomas Monjalon wrote:
> Before submitting 56 patches I'd like to double-check that checkpatch.pl
> errors (for example, because of assignments in the 'if' condition,
> parenthesis around return value) is not a show-stopper for base driver
> import.
 You can run checkpatches.sh or send the patches to checkpatch at dpdk.org.
 The script check-git-log.sh can also guide you for the expected formatting.
>>> Yes, I did it and it helped me to find and fix some coding standard
>>> violations.
>>>
>>> The problem with libefx (base driver) is that it is existing code which
>>> follows FreeBSD and illumos coding conventions which contradict to
>>> checkpatches.sh sometimes (e.g. require parenthesis around return
>>> value). Other example of error produced by checkpatches.sh is assign in
>>> if. It is widely used in the code to assign return code value and
>>> compare it vs 0 in one line. It is not a coding standard conflict, but
>>> it is very wide-spread in the code (so changing it will produce too many
>>> changes not strictly required/useful).
>>>
>>> So, may I repeat my question if it is a show-stopper for base driver or
>>> acceptable.
>> I would vote to accept these minor style warnings for the base driver.
>> Ferruh, any comment?
>>
> For _base driver_, I am also OK for having checkpatch warnings.

In term of checkpatshes.sh return value in parenthesis is an error (not 
warning). Hopefully it changes nothing.

Andrew.


[dpdk-dev] [PATCH 2/7] eal: Helper to convert to struct rte_pci_device

2016-11-21 Thread Jan Blunck
On Sun, Nov 20, 2016 at 4:20 PM, David Marchand
 wrote:
> Hello Jan,
>
> On Sun, Nov 20, 2016 at 11:05 AM, Jan Blunck  wrote:
>> Signed-off-by: Jan Blunck 
>> ---
>>  lib/librte_eal/common/include/rte_pci.h | 2 ++
>>  1 file changed, 2 insertions(+)
>>
>> diff --git a/lib/librte_eal/common/include/rte_pci.h 
>> b/lib/librte_eal/common/include/rte_pci.h
>> index 9ce8847..0376160 100644
>> --- a/lib/librte_eal/common/include/rte_pci.h
>> +++ b/lib/librte_eal/common/include/rte_pci.h
>> @@ -160,6 +160,8 @@ struct rte_pci_device {
>> enum rte_kernel_driver kdrv;/**< Kernel driver 
>> passthrough */
>>  };
>>
>> +#define ETH_DEV_PCI_DEV(ptr) ((ptr)->pci_dev)
>> +
>>  /** Any PCI device identifier (vendor, device, ...) */
>>  #define PCI_ANY_ID (0x)
>>  #define RTE_CLASS_ANY_ID (0xff)
>
> This should come from ethdev, not eal.
>

Fixed in v2.

Thanks,
Jan


[dpdk-dev] [PATCH v2 8/8] ethdev: Decouple interrupt handling from PCI device

2016-11-21 Thread Jan Blunck
The struct rte_intr_handle is an abstraction layer for different types of
interrupt mechanisms. It is embedded in the low-level device (e.g. PCI).
On allocation of a struct rte_eth_dev a reference to the intr_handle
should be stored for devices supporting interrupts.

Signed-off-by: Jan Blunck 
---
 lib/librte_ether/rte_ethdev.c | 18 --
 lib/librte_ether/rte_ethdev.h |  1 +
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 4288577..4ecea50 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -258,6 +258,7 @@ rte_eth_dev_pci_probe(struct rte_pci_driver *pci_drv,
rte_panic("Cannot allocate memzone for private port 
data\n");
}
eth_dev->pci_dev = pci_dev;
+   eth_dev->intr_handle = _dev->intr_handle;
eth_dev->driver = eth_drv;
eth_dev->data->rx_mbuf_alloc_failed = 0;

@@ -2543,7 +2544,13 @@ rte_eth_dev_rx_intr_ctl(uint8_t port_id, int epfd, int 
op, void *data)
RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);

dev = _eth_devices[port_id];
-   intr_handle = >pci_dev->intr_handle;
+
+   if (!dev->intr_handle) {
+   RTE_PMD_DEBUG_TRACE("RX Intr handle unset\n");
+   return -ENOTSUP;
+   }
+
+   intr_handle = dev->intr_handle;
if (!intr_handle->intr_vec) {
RTE_PMD_DEBUG_TRACE("RX Intr vector unset\n");
return -EPERM;
@@ -2603,7 +2610,12 @@ rte_eth_dev_rx_intr_ctl_q(uint8_t port_id, uint16_t 
queue_id,
return -EINVAL;
}

-   intr_handle = >pci_dev->intr_handle;
+   if (!dev->intr_handle) {
+   RTE_PMD_DEBUG_TRACE("RX Intr handle unset\n");
+   return -ENOTSUP;
+   }
+
+   intr_handle = dev->intr_handle;
if (!intr_handle->intr_vec) {
RTE_PMD_DEBUG_TRACE("RX Intr vector unset\n");
return -EPERM;
@@ -3205,6 +3217,8 @@ rte_eth_copy_pci_info(struct rte_eth_dev *eth_dev, struct 
rte_pci_device *pci_de
return;
}

+   eth_dev->intr_handle = _dev->intr_handle;
+
eth_dev->data->dev_flags = 0;
if (pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_LSC)
eth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_LSC;
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 3adbb2b..f1f656a 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1629,6 +1629,7 @@ struct rte_eth_dev {
const struct eth_driver *driver;/**< Driver for this device */
const struct eth_dev_ops *dev_ops; /**< Functions exported by PMD */
struct rte_pci_device *pci_dev; /**< PCI info. supplied by probing */
+   struct rte_intr_handle *intr_handle; /**< Device interrupt handle */
/** User application callbacks for NIC interrupts */
struct rte_eth_dev_cb_list link_intr_cbs;
/**
-- 
2.7.4



[dpdk-dev] [PATCH v2 7/8] ethdev: Move filling of rte_eth_dev_info->pci_dev to dev_infos_get()

2016-11-21 Thread Jan Blunck
Only the device itself can decide its PCI or not.

Signed-off-by: Jan Blunck 
---
 drivers/net/bnx2x/bnx2x_ethdev.c| 1 +
 drivers/net/bnxt/bnxt_ethdev.c  | 2 ++
 drivers/net/cxgbe/cxgbe_ethdev.c| 2 ++
 drivers/net/e1000/em_ethdev.c   | 1 +
 drivers/net/e1000/igb_ethdev.c  | 2 ++
 drivers/net/ena/ena_ethdev.c| 2 ++
 drivers/net/enic/enic_ethdev.c  | 1 +
 drivers/net/fm10k/fm10k_ethdev.c| 1 +
 drivers/net/i40e/i40e_ethdev.c  | 1 +
 drivers/net/i40e/i40e_ethdev_vf.c   | 1 +
 drivers/net/ixgbe/ixgbe_ethdev.c| 2 ++
 drivers/net/mlx4/mlx4.c | 2 ++
 drivers/net/mlx5/mlx5_ethdev.c  | 2 ++
 drivers/net/nfp/nfp_net.c   | 1 +
 drivers/net/qede/qede_ethdev.c  | 1 +
 drivers/net/szedata2/rte_eth_szedata2.c | 1 +
 drivers/net/thunderx/nicvf_ethdev.c | 2 ++
 drivers/net/virtio/virtio_ethdev.c  | 1 +
 drivers/net/vmxnet3/vmxnet3_ethdev.c| 2 ++
 lib/librte_ether/rte_ethdev.c   | 1 -
 20 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/drivers/net/bnx2x/bnx2x_ethdev.c b/drivers/net/bnx2x/bnx2x_ethdev.c
index 0eae433..06453fe 100644
--- a/drivers/net/bnx2x/bnx2x_ethdev.c
+++ b/drivers/net/bnx2x/bnx2x_ethdev.c
@@ -431,6 +431,7 @@ static void
 bnx2x_dev_infos_get(struct rte_eth_dev *dev, __rte_unused struct 
rte_eth_dev_info *dev_info)
 {
struct bnx2x_softc *sc = dev->data->dev_private;
+   dev_info->pci_dev = ETH_DEV_PCI_DEV(dev);
dev_info->max_rx_queues  = sc->max_rx_queues;
dev_info->max_tx_queues  = sc->max_tx_queues;
dev_info->min_rx_bufsize = BNX2X_MIN_RX_BUF_SIZE;
diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index cd50f11..bf39fbe 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -303,6 +303,8 @@ static void bnxt_dev_info_get_op(struct rte_eth_dev 
*eth_dev,
struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private;
uint16_t max_vnics, i, j, vpool, vrxq;

+   dev_info->pci_dev = ETH_DEV_PCI_DEV(eth_dev);
+
/* MAC Specifics */
dev_info->max_mac_addrs = MAX_NUM_MAC_ADDR;
dev_info->max_hash_mac_addrs = 0;
diff --git a/drivers/net/cxgbe/cxgbe_ethdev.c b/drivers/net/cxgbe/cxgbe_ethdev.c
index 8bfdda8..8938b08 100644
--- a/drivers/net/cxgbe/cxgbe_ethdev.c
+++ b/drivers/net/cxgbe/cxgbe_ethdev.c
@@ -147,6 +147,8 @@ static void cxgbe_dev_info_get(struct rte_eth_dev *eth_dev,
.nb_align = 1,
};

+   device_info->pci_dev = ETH_DEV_PCI_DEV(eth_dev);
+
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;
diff --git a/drivers/net/e1000/em_ethdev.c b/drivers/net/e1000/em_ethdev.c
index 7f2f521..3d34e5b 100644
--- a/drivers/net/e1000/em_ethdev.c
+++ b/drivers/net/e1000/em_ethdev.c
@@ -1048,6 +1048,7 @@ eth_em_infos_get(struct rte_eth_dev *dev, struct 
rte_eth_dev_info *dev_info)
 {
struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);

+   dev_info->pci_dev = ETH_DEV_PCI_DEV(dev);
dev_info->min_rx_bufsize = 256; /* See BSIZE field of RCTL register. */
dev_info->max_rx_pktlen = em_get_max_pktlen(hw);
dev_info->max_mac_addrs = hw->mac.rar_entry_count;
diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
index b25c66e..7d77561 100644
--- a/drivers/net/e1000/igb_ethdev.c
+++ b/drivers/net/e1000/igb_ethdev.c
@@ -1983,6 +1983,7 @@ eth_igb_infos_get(struct rte_eth_dev *dev, struct 
rte_eth_dev_info *dev_info)
 {
struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);

+   dev_info->pci_dev = ETH_DEV_PCI_DEV(dev);
dev_info->min_rx_bufsize = 256; /* See BSIZE field of RCTL register. */
dev_info->max_rx_pktlen  = 0x3FFF; /* See RLPML register. */
dev_info->max_mac_addrs = hw->mac.rar_entry_count;
@@ -2111,6 +2112,7 @@ eth_igbvf_infos_get(struct rte_eth_dev *dev, struct 
rte_eth_dev_info *dev_info)
 {
struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);

+   dev_info->pci_dev = ETH_DEV_PCI_DEV(dev);
dev_info->min_rx_bufsize = 256; /* See BSIZE field of RCTL register. */
dev_info->max_rx_pktlen  = 0x3FFF; /* See RLPML register. */
dev_info->max_mac_addrs = hw->mac.rar_entry_count;
diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c
index c17d969..051275e 100644
--- a/drivers/net/ena/ena_ethdev.c
+++ b/drivers/net/ena/ena_ethdev.c
@@ -1436,6 +1436,8 @@ static void ena_infos_get(struct rte_eth_dev *dev,
ena_dev = >ena_dev;
ena_assert_msg(ena_dev != NULL, "Uninitialized device");

+   dev_info->pci_dev = ETH_DEV_PCI_DEV(dev);
+
dev_info->speed_capa =
ETH_LINK_SPEED_1G   |
ETH_LINK_SPEED_2_5G |
diff --git 

[dpdk-dev] [PATCH v2 6/8] virtio: Don't depend on struct rte_eth_dev's pci_dev

2016-11-21 Thread Jan Blunck
We don't need to depend on rte_eth_dev->pci_dev to differentiate between
the virtio_user and the virtio_pci case. Instead we can use the private
virtio_hw struct to get that information.

Signed-off-by: Jan Blunck 
---
 drivers/net/virtio/virtio_ethdev.c | 21 ++---
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/drivers/net/virtio/virtio_ethdev.c 
b/drivers/net/virtio/virtio_ethdev.c
index da9668e..023101d 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -483,11 +483,11 @@ virtio_init_queue(struct rte_eth_dev *dev, uint16_t 
vtpci_queue_idx)
hw->cvq = cvq;
}

-   /* For virtio_user case (that is when dev->pci_dev is NULL), we use
+   /* For virtio_user case (that is when hw->dev is NULL), we use
 * virtual address. And we need properly set _offset_, please see
 * VIRTIO_MBUF_DATA_DMA_ADDR in virtqueue.h for more information.
 */
-   if (dev->pci_dev)
+   if (hw->dev)
vq->offset = offsetof(struct rte_mbuf, buf_physaddr);
else {
vq->vq_ring_mem = (uintptr_t)mz->addr;
@@ -1190,7 +1190,7 @@ virtio_init_device(struct rte_eth_dev *eth_dev, uint64_t 
req_features)
struct virtio_hw *hw = eth_dev->data->dev_private;
struct virtio_net_config *config;
struct virtio_net_config local_config;
-   struct rte_pci_device *pci_dev = eth_dev->pci_dev;
+   struct rte_pci_device *pci_dev = hw->dev;
int ret;

/* Reset the device although not necessary at startup */
@@ -1294,7 +1294,6 @@ int
 eth_virtio_dev_init(struct rte_eth_dev *eth_dev)
 {
struct virtio_hw *hw = eth_dev->data->dev_private;
-   struct rte_pci_device *pci_dev;
uint32_t dev_flags = RTE_ETH_DEV_DETACHABLE;
int ret;

@@ -1317,10 +1316,11 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev)
return -ENOMEM;
}

-   pci_dev = eth_dev->pci_dev;
-
-   if (pci_dev) {
-   ret = vtpci_init(pci_dev, hw, _flags);
+   /* For virtio_user case the hw->virtio_user_dev is populated by
+* virtio_user_eth_dev_alloc() before eth_virtio_dev_init() is called.
+*/
+   if (!hw->virtio_user_dev) {
+   ret = vtpci_init(ETH_DEV_PCI_DEV(eth_dev), hw, _flags);
if (ret)
return ret;
}
@@ -1343,7 +1343,6 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev)
 static int
 eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev)
 {
-   struct rte_pci_device *pci_dev;
struct virtio_hw *hw = eth_dev->data->dev_private;

PMD_INIT_FUNC_TRACE();
@@ -1353,7 +1352,6 @@ eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev)

virtio_dev_stop(eth_dev);
virtio_dev_close(eth_dev);
-   pci_dev = eth_dev->pci_dev;

eth_dev->dev_ops = NULL;
eth_dev->tx_pkt_burst = NULL;
@@ -1367,7 +1365,8 @@ eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev)
rte_intr_callback_unregister(vtpci_intr_handle(hw),
virtio_interrupt_handler,
eth_dev);
-   rte_eal_pci_unmap_device(pci_dev);
+   if (hw->dev)
+   rte_eal_pci_unmap_device(hw->dev);

PMD_INIT_LOG(DEBUG, "dev_uninit completed");

-- 
2.7.4



[dpdk-dev] [PATCH v2 5/8] virtio: Add vtpci_intr_handle() helper to get rte_intr_handle

2016-11-21 Thread Jan Blunck
This adds a helper to get the rte_intr_handle from the virtio_hw. This is
safe to do since the usage of the helper is guarded by RTE_ETH_DEV_INTR_LSC
which is only set if we found a PCI device during initialization.

Signed-off-by: Jan Blunck 
---
 drivers/net/virtio/virtio_ethdev.c | 12 +++-
 drivers/net/virtio/virtio_pci.h|  6 ++
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/drivers/net/virtio/virtio_ethdev.c 
b/drivers/net/virtio/virtio_ethdev.c
index 741688e..da9668e 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -1162,7 +1162,7 @@ virtio_interrupt_handler(__rte_unused struct 
rte_intr_handle *handle,
isr = vtpci_isr(hw);
PMD_DRV_LOG(INFO, "interrupt status = %#x", isr);

-   if (rte_intr_enable(>pci_dev->intr_handle) < 0)
+   if (rte_intr_enable(vtpci_intr_handle(hw)) < 0)
PMD_DRV_LOG(ERR, "interrupt enable failed");

if (isr & VIRTIO_PCI_ISR_CONFIG) {
@@ -1334,7 +1334,7 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev)

/* Setup interrupt callback  */
if (eth_dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC)
-   rte_intr_callback_register(_dev->intr_handle,
+   rte_intr_callback_register(vtpci_intr_handle(hw),
virtio_interrupt_handler, eth_dev);

return 0;
@@ -1344,6 +1344,7 @@ static int
 eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev)
 {
struct rte_pci_device *pci_dev;
+   struct virtio_hw *hw = eth_dev->data->dev_private;

PMD_INIT_FUNC_TRACE();

@@ -1363,7 +1364,7 @@ eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev)

/* reset interrupt callback  */
if (eth_dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC)
-   rte_intr_callback_unregister(_dev->intr_handle,
+   rte_intr_callback_unregister(vtpci_intr_handle(hw),
virtio_interrupt_handler,
eth_dev);
rte_eal_pci_unmap_device(pci_dev);
@@ -1481,7 +1482,7 @@ virtio_dev_start(struct rte_eth_dev *dev)
return -ENOTSUP;
}

-   if (rte_intr_enable(>pci_dev->intr_handle) < 0) {
+   if (rte_intr_enable(vtpci_intr_handle(hw)) < 0) {
PMD_DRV_LOG(ERR, "interrupt enable failed");
return -EIO;
}
@@ -1573,12 +1574,13 @@ static void virtio_dev_free_mbufs(struct rte_eth_dev 
*dev)
 static void
 virtio_dev_stop(struct rte_eth_dev *dev)
 {
+   struct virtio_hw *hw = dev->data->dev_private;
struct rte_eth_link link;

PMD_INIT_LOG(DEBUG, "stop");

if (dev->data->dev_conf.intr_conf.lsc)
-   rte_intr_disable(>pci_dev->intr_handle);
+   rte_intr_disable(vtpci_intr_handle(hw));

memset(, 0, sizeof(link));
virtio_dev_atomic_write_link_status(dev, );
diff --git a/drivers/net/virtio/virtio_pci.h b/drivers/net/virtio/virtio_pci.h
index de271bf..5373e39 100644
--- a/drivers/net/virtio/virtio_pci.h
+++ b/drivers/net/virtio/virtio_pci.h
@@ -317,4 +317,10 @@ uint8_t vtpci_isr(struct virtio_hw *);

 uint16_t vtpci_irq_config(struct virtio_hw *, uint16_t);

+static inline struct rte_intr_handle *
+vtpci_intr_handle(struct virtio_hw *hw)
+{
+   return hw->dev ? >dev->intr_handle : NULL;
+}
+
 #endif /* _VIRTIO_PCI_H_ */
-- 
2.7.4



[dpdk-dev] [PATCH v2 3/8] drivers: Use ETH_DEV_PCI_DEV() helper

2016-11-21 Thread Jan Blunck
The drivers should not directly access the rte_eth_dev->pci_dev but use
a macro instead. This is a preparation for replacing the pci_dev with
a struct rte_device member in the future.

Signed-off-by: Jan Blunck 
---
 drivers/net/bnxt/bnxt_ethdev.c   | 19 ++-
 drivers/net/bnxt/bnxt_ring.c | 11 +++---
 drivers/net/cxgbe/cxgbe_ethdev.c |  2 +-
 drivers/net/e1000/em_ethdev.c| 20 ++-
 drivers/net/e1000/igb_ethdev.c   | 50 +++
 drivers/net/e1000/igb_pf.c   |  3 +-
 drivers/net/ena/ena_ethdev.c |  2 +-
 drivers/net/enic/enic_ethdev.c   |  2 +-
 drivers/net/fm10k/fm10k_ethdev.c | 49 ++-
 drivers/net/i40e/i40e_ethdev.c   | 44 
 drivers/net/i40e/i40e_ethdev.h   |  4 +++
 drivers/net/i40e/i40e_ethdev_vf.c| 38 ++---
 drivers/net/ixgbe/ixgbe_ethdev.c | 65 +---
 drivers/net/ixgbe/ixgbe_pf.c |  2 +-
 drivers/net/qede/qede_ethdev.c   | 17 +-
 drivers/net/vmxnet3/vmxnet3_ethdev.c |  4 +--
 16 files changed, 185 insertions(+), 147 deletions(-)

diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 035fe07..cd50f11 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -743,6 +743,7 @@ static int bnxt_reta_query_op(struct rte_eth_dev *eth_dev,
 {
struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private;
struct bnxt_vnic_info *vnic = >vnic_info[0];
+   struct rte_pci_device *pci_dev = ETH_DEV_PCI_DEV(eth_dev);

/* Retrieve from the default VNIC */
if (!vnic)
@@ -759,7 +760,7 @@ static int bnxt_reta_query_op(struct rte_eth_dev *eth_dev,
/* EW - need to revisit here copying from u64 to u16 */
memcpy(reta_conf, vnic->rss_table, reta_size);

-   if (rte_intr_allow_others(_dev->pci_dev->intr_handle)) {
+   if (rte_intr_allow_others(_dev->intr_handle)) {
if (eth_dev->data->dev_conf.intr_conf.lsc != 0)
bnxt_dev_lsc_intr_setup(eth_dev);
}
@@ -1011,9 +1012,10 @@ static int bnxt_init_board(struct rte_eth_dev *eth_dev)
 {
int rc;
struct bnxt *bp = eth_dev->data->dev_private;
+   struct rte_pci_device *pci_dev = ETH_DEV_PCI_DEV(eth_dev);

/* enable device (incl. PCI PM wakeup), and bus-mastering */
-   if (!eth_dev->pci_dev->mem_resource[0].addr) {
+   if (!pci_dev->mem_resource[0].addr) {
RTE_LOG(ERR, PMD,
"Cannot find PCI device base address, aborting\n");
rc = -ENODEV;
@@ -1021,9 +1023,9 @@ static int bnxt_init_board(struct rte_eth_dev *eth_dev)
}

bp->eth_dev = eth_dev;
-   bp->pdev = eth_dev->pci_dev;
+   bp->pdev = pci_dev;

-   bp->bar0 = (void *)eth_dev->pci_dev->mem_resource[0].addr;
+   bp->bar0 = (void *)pci_dev->mem_resource[0].addr;
if (!bp->bar0) {
RTE_LOG(ERR, PMD, "Cannot map device registers, aborting\n");
rc = -ENOMEM;
@@ -1043,6 +1045,7 @@ static int bnxt_init_board(struct rte_eth_dev *eth_dev)
 static int
 bnxt_dev_init(struct rte_eth_dev *eth_dev)
 {
+   struct rte_pci_device *pci_dev = ETH_DEV_PCI_DEV(eth_dev);
static int version_printed;
struct bnxt *bp;
int rc;
@@ -1050,10 +1053,10 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev)
if (version_printed++ == 0)
RTE_LOG(INFO, PMD, "%s", bnxt_version);

-   rte_eth_copy_pci_info(eth_dev, eth_dev->pci_dev);
+   rte_eth_copy_pci_info(eth_dev, pci_dev);
bp = eth_dev->data->dev_private;

-   if (bnxt_vf_pciid(eth_dev->pci_dev->id.device_id))
+   if (bnxt_vf_pciid(pci_dev->id.device_id))
bp->flags |= BNXT_FLAG_VF;

rc = bnxt_init_board(eth_dev);
@@ -1121,8 +1124,8 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev)

RTE_LOG(INFO, PMD,
DRV_MODULE_NAME " found at mem %" PRIx64 ", node addr %pM\n",
-   eth_dev->pci_dev->mem_resource[0].phys_addr,
-   eth_dev->pci_dev->mem_resource[0].addr);
+   pci_dev->mem_resource[0].phys_addr,
+   pci_dev->mem_resource[0].addr);

bp->dev_stopped = 0;

diff --git a/drivers/net/bnxt/bnxt_ring.c b/drivers/net/bnxt/bnxt_ring.c
index 3f81ffc..6793d75 100644
--- a/drivers/net/bnxt/bnxt_ring.c
+++ b/drivers/net/bnxt/bnxt_ring.c
@@ -209,6 +209,7 @@ int bnxt_alloc_rings(struct bnxt *bp, uint16_t qidx,
  */
 int bnxt_alloc_hwrm_rings(struct bnxt *bp)
 {
+   struct rte_pci_device *pci_dev = ETH_DEV_PCI_DEV(bp->eth_dev);
unsigned int i;
int rc = 0;

@@ -223,7 +224,7 @@ int bnxt_alloc_hwrm_rings(struct bnxt *bp)
if (rc)
goto err_out;
cpr->cp_doorbell =
-   (char *)bp->eth_dev->pci_dev->mem_resource[2].addr;
+   (char 

[dpdk-dev] [PATCH v2 2/8] ethdev: Helper to convert to struct rte_pci_device

2016-11-21 Thread Jan Blunck
Signed-off-by: Jan Blunck 
---
 lib/librte_ether/rte_ethdev.h | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 9678179..3adbb2b 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1644,6 +1644,12 @@ struct rte_eth_dev {
uint8_t attached; /**< Flag indicating the port is attached */
 } __rte_cache_aligned;

+/**
+ * @internal
+ * Helper for drivers that need to convert from rte_eth_dev to rte_pci_device.
+ */
+#define ETH_DEV_PCI_DEV(ptr) ((ptr)->pci_dev)
+
 struct rte_eth_dev_sriov {
uint8_t active;   /**< SRIOV is active with 16, 32 or 64 
pools */
uint8_t nb_q_per_pool;/**< rx queue number per pool */
-- 
2.7.4



[dpdk-dev] [PATCH v2 1/8] eal: define container_of macro

2016-11-21 Thread Jan Blunck
This macro is based on Jan Viktorin's original patch but also checks the
type of the passed pointer against the type of the member.

Signed-off-by: Jan Viktorin 
Signed-off-by: Shreyansh Jain 
[jblunck at infradead.org: add type checking and __extension__]
Signed-off-by: Jan Blunck 
---
 lib/librte_eal/common/include/rte_common.h | 20 
 1 file changed, 20 insertions(+)

diff --git a/lib/librte_eal/common/include/rte_common.h 
b/lib/librte_eal/common/include/rte_common.h
index db5ac91..8dda3e2 100644
--- a/lib/librte_eal/common/include/rte_common.h
+++ b/lib/librte_eal/common/include/rte_common.h
@@ -331,6 +331,26 @@ rte_bsf32(uint32_t v)
 #define offsetof(TYPE, MEMBER)  __builtin_offsetof (TYPE, MEMBER)
 #endif

+/**
+ * Return pointer to the wrapping struct instance.
+ *
+ * Example:
+ *
+ *  struct wrapper {
+ *  ...
+ *  struct child c;
+ *  ...
+ *  };
+ *
+ *  struct child *x = obtain(...);
+ *  struct wrapper *w = container_of(x, struct wrapper, c);
+ */
+#ifndef container_of
+#define container_of(ptr, type, member)__extension__ ({
\
+   typeof(((type *)0)->member) *_ptr = (ptr);  \
+   (type *)(((char *)_ptr) - offsetof(type, member)); })
+#endif
+
 #define _RTE_STR(x) #x
 /** Take a macro value and get a string version of it */
 #define RTE_STR(x) _RTE_STR(x)
-- 
2.7.4



[dpdk-dev] [PATCH 4/7] virtio: Don't fill dev_info->driver_name

2016-11-21 Thread David Marchand
On Mon, Nov 21, 2016 at 5:34 PM, Jan Blunck  wrote:
> On Sun, Nov 20, 2016 at 4:22 PM, David Marchand
>> I posted something similar [1], so looks good to me :-)
>>
>> [1]: http://dpdk.org/dev/patchwork/patch/16991/
>>
>
> Thanks for reviewing. Do we go with your proposal then? Do you plan to
> follow up on the comments?

Yes will do.
Out of curiosity how did you catch the qede driver ? Did you check all
other drivers ?


-- 
David Marchand


[dpdk-dev] [PATCH 2/4] eventdev: implement the northbound APIs

2016-11-21 Thread Eads, Gage
Hi Jerin,

I did a quick review and overall this implementation looks good. I noticed just 
one issue in rte_event_queue_setup(): the check of nb_atomic_order_sequences is 
being applied to atomic-type queues, but that field applies to ordered-type 
queues.

One open issue I noticed is the "typical workflow" description starting in 
rte_eventdev.h:204 conflicts with the centralized software PMD that Harry 
posted last week. Specifically, that PMD expects a single core to call the 
schedule function. We could extend the documentation to account for this 
alternative style of scheduler invocation, or discuss ways to make the software 
PMD work with the documented workflow. I prefer the former, but either way I 
think we ought to expose the scheduler's expected usage to the user -- perhaps 
through an RTE_EVENT_DEV_CAP flag?

Thanks,
Gage

>  -Original Message-
>  From: Jerin Jacob [mailto:jerin.jacob at caviumnetworks.com]
>  Sent: Thursday, November 17, 2016 11:45 PM
>  To: dev at dpdk.org
>  Cc: Richardson, Bruce ; Van Haaren, Harry
>  ; hemant.agrawal at nxp.com; Eads, Gage
>  ; Jerin Jacob 
>  Subject: [dpdk-dev] [PATCH 2/4] eventdev: implement the northbound APIs
>  
>  This patch set defines the southbound driver interface
>  and implements the common code required for northbound
>  eventdev API interface.
>  
>  Signed-off-by: Jerin Jacob 
>  ---
>   config/common_base   |6 +
>   lib/Makefile |1 +
>   lib/librte_eal/common/include/rte_log.h  |1 +
>   lib/librte_eventdev/Makefile |   57 ++
>   lib/librte_eventdev/rte_eventdev.c   | 1211
>  ++
>   lib/librte_eventdev/rte_eventdev_pmd.h   |  504 +++
>   lib/librte_eventdev/rte_eventdev_version.map |   39 +
>   mk/rte.app.mk|1 +
>   8 files changed, 1820 insertions(+)
>   create mode 100644 lib/librte_eventdev/Makefile
>   create mode 100644 lib/librte_eventdev/rte_eventdev.c
>   create mode 100644 lib/librte_eventdev/rte_eventdev_pmd.h
>   create mode 100644 lib/librte_eventdev/rte_eventdev_version.map
>  
>  diff --git a/config/common_base b/config/common_base
>  index 4bff83a..7a8814e 100644
>  --- a/config/common_base
>  +++ b/config/common_base
>  @@ -411,6 +411,12 @@ CONFIG_RTE_LIBRTE_PMD_ZUC_DEBUG=n
>   CONFIG_RTE_LIBRTE_PMD_NULL_CRYPTO=y
>  
>   #
>  +# Compile generic event device library
>  +#
>  +CONFIG_RTE_LIBRTE_EVENTDEV=y
>  +CONFIG_RTE_LIBRTE_EVENTDEV_DEBUG=n
>  +CONFIG_RTE_EVENT_MAX_DEVS=16
>  +CONFIG_RTE_EVENT_MAX_QUEUES_PER_DEV=64
>   # Compile librte_ring
>   #
>   CONFIG_RTE_LIBRTE_RING=y
>  diff --git a/lib/Makefile b/lib/Makefile
>  index 990f23a..1a067bf 100644
>  --- a/lib/Makefile
>  +++ b/lib/Makefile
>  @@ -41,6 +41,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_CFGFILE) += librte_cfgfile
>   DIRS-$(CONFIG_RTE_LIBRTE_CMDLINE) += librte_cmdline
>   DIRS-$(CONFIG_RTE_LIBRTE_ETHER) += librte_ether
>   DIRS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += librte_cryptodev
>  +DIRS-$(CONFIG_RTE_LIBRTE_EVENTDEV) += librte_eventdev
>   DIRS-$(CONFIG_RTE_LIBRTE_VHOST) += librte_vhost
>   DIRS-$(CONFIG_RTE_LIBRTE_HASH) += librte_hash
>   DIRS-$(CONFIG_RTE_LIBRTE_LPM) += librte_lpm
>  diff --git a/lib/librte_eal/common/include/rte_log.h
>  b/lib/librte_eal/common/include/rte_log.h
>  index 29f7d19..9a07d92 100644
>  --- a/lib/librte_eal/common/include/rte_log.h
>  +++ b/lib/librte_eal/common/include/rte_log.h
>  @@ -79,6 +79,7 @@ extern struct rte_logs rte_logs;
>   #define RTE_LOGTYPE_PIPELINE 0x8000 /**< Log related to pipeline. */
>   #define RTE_LOGTYPE_MBUF0x0001 /**< Log related to mbuf. */
>   #define RTE_LOGTYPE_CRYPTODEV 0x0002 /**< Log related to
>  cryptodev. */
>  +#define RTE_LOGTYPE_EVENTDEV 0x0004 /**< Log related to eventdev.
>  */
>  
>   /* these log types can be used in an application */
>   #define RTE_LOGTYPE_USER1   0x0100 /**< User-defined log type 1. */
>  diff --git a/lib/librte_eventdev/Makefile b/lib/librte_eventdev/Makefile
>  new file mode 100644
>  index 000..dac0663
>  --- /dev/null
>  +++ b/lib/librte_eventdev/Makefile
>  @@ -0,0 +1,57 @@
>  +#   BSD LICENSE
>  +#
>  +#   Copyright(c) 2016 Cavium networks. 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 Cavium networks nor the names of its
>  +#   contributors may be used to endorse or promote products derived

[dpdk-dev] [PATCH] eal: postpone vdev initialization

2016-11-21 Thread Ferruh Yigit
On 11/21/2016 5:02 PM, Jerin Jacob wrote:
> On Mon, Nov 21, 2016 at 09:54:57AM +, Ferruh Yigit wrote:
>> On 11/20/2016 8:00 AM, Jerin Jacob wrote:
>>> Some platform like octeontx may use pci and
>>> vdev based combined device to represent a logical
>>> dpdk functional device.In such case, postponing the
>>> vdev initialization after pci device
>>> initialization will provide the better view of
>>> the pci device resources in the system in
>>> vdev's probe function, and it allows better
>>> functional subsystem registration in vdev probe
>>> function.
>>>
>>> As a bonus, This patch fixes a bond device
>>> initialization use case.
>>>
>>> example command to reproduce the issue:
>>> ./testpmd -c 0x2  --vdev 'eth_bond0,mode=0,
>>> slave=:02:00.0,slave=:03:00.0' --
>>> --port-topology=chained
>>>
>>> root cause:
>>> In existing case(vdev initialization and then pci
>>> initialization), creates three Ethernet ports with
>>> following port ids
>>> 0 - Bond device
>>> 1 - PCI device 0
>>> 2 - PCI devive 1
>>>
>>> Since testpmd, calls the configure/start on all the ports on
>>> start up,it will translate to following illegal setup sequence
>>>
>>> 1)bond device configure/start
>>> 1.1) pci device0 stop/configure/start
>>> 1.2) pci device1 stop/configure/start
>>> 2)pci device 0 configure(illegal setup case,
>>> as device in start state)
>>>
>>> The fix changes the initialization sequence and
>>> allow initialization in following valid setup order
>>> 1) pcie device 0 configure/start
>>> 2) pcie device 1 configure/start
>>> 3) bond device 2 configure/start
>>> 3.1) pcie device 0/stop/configure/start
>>> 3.2) pcie device 1/stop/configure/start
>>>
>>> Signed-off-by: Jerin Jacob 
>>> ---
>>
>> This changes the port id assignments to the devices, right?
>>
>> Previously virtual devices get first available port ids (0..N1), later
>> physical devices (N1..N2). Now this becomes reverse.
>>
>> Can this change break some existing user applications?
> 
> I guess it may be effected only to ethdev bond pmd based application,
> which is broken anyway.

My concern is, this may effect the applications that use "--vdev" eal
parameter and has an assumption about port assignment.

And if this breaks any userspace application, does it require a
deprecation notice?

> Let me know what it takes to make forward progress on this patch. I can
> fix the same in v2.
> 
> Jerin
> 



[dpdk-dev] Adding API to force freeing consumed buffers in TX ring

2016-11-21 Thread Olivier Matz
Hi,

On 11/21/2016 03:33 PM, Wiles, Keith wrote:
> 
>> On Nov 21, 2016, at 4:48 AM, Damjan Marion (damarion) > cisco.com> wrote:
>>
>>
>> Hi,
>>
>> Currently in VPP we do memcpy of whole packet when we need to do 
>> replication as we cannot know if specific buffer is transmitted
>> from tx ring before we update it again (i.e. l2 header rewrite).
>>
>> Unless there is already a way to address this issue in DPDK which I?m not 
>> aware
>> of my proposal is that we provide mechanism for polling TX ring 
>> for consumed buffers. This can be either completely new API or 
>> extension of rte_etx_tx_burst (i.e. special case when nb_pkts=0).
>>
>> This will allows us to start polling tx ring when we expect some 
>> mbuf back, instead of waiting for next tx burst (which we don?t know
>> when it will happen) and hoping that we will reach free_threshold soon.
> 
> +1
> 
> In Pktgen I have the problem of not being able to reclaim all of the TX mbufs 
> to update them for the next set of packets to send. I know this is not a 
> common case, but I do see the case where the application needs its mbufs 
> freed off the TX ring. Currently you need to have at least a TX ring size of 
> mbufs on hand to make sure you can send to a TX ring. If you allocate too few 
> you run into a deadlock case as the number of mbufs  on a TX ring does not 
> hit the flush mark. If you are sending to multiple TX rings on the same numa 
> node from the a single TX pool you have to understand the total number of 
> mbufs you need to have allocated to hit the TX flush on each ring. Not a 
> clean way to handle the problems as you may have limited memory or require 
> some logic to add more mbufs for dynamic ports.
> 
> Anyway it would be great to require a way to clean up the TX done ring, using 
> nb_pkts == 0 is the simplest way, but a new API is fine too.
>>
>> Any thoughts?

Yes, it looks useful to have a such API.

I would prefer another function instead of diverting the meaning of
nb_pkts. Maybe this?

  void rte_eth_tx_free_bufs(uint8_t port_id, uint16_t queue_id);


Regards,
Olivier


[dpdk-dev] [dpdk-stable] [PATCH] Revert "bonding: use existing enslaved device queues"

2016-11-21 Thread Ilya Maximets
On 21.11.2016 14:39, Jan Blunck wrote:
> Ferruh,
> 
> I've been working on a patch but was distracted by other stuff and
> therefore haven't tested it yet.

Jan, on what patch are you working? I don't understand.

> 
> Stay tuned,
> Jan
> 
> On Mon, Nov 21, 2016 at 12:30 PM, Ferruh Yigit  
> wrote:
>>
>> Is there an update for this patch? Is a consensus reached?

Ferruh, I didn't receive any response on my e-mails. I've pinged this thread
few times, but didn't receive any feedback and I have no idea what patch Jan
talking about.

Best regards, Ilya Maximets.


[dpdk-dev] [PATCH 56/56] net/sfc: add callback to send bursts of packets

2016-11-21 Thread Andrew Rybchenko
From: Ivan Malov 

Reviewed-by: Andy Moreton 
Signed-off-by: Ivan Malov 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/efx/sfc_ethdev.c |   2 +
 drivers/net/sfc/efx/sfc_ev.c |  22 +++-
 drivers/net/sfc/efx/sfc_tweak.h  |   7 +++
 drivers/net/sfc/efx/sfc_tx.c | 115 +++
 drivers/net/sfc/efx/sfc_tx.h |  18 ++
 5 files changed, 162 insertions(+), 2 deletions(-)

diff --git a/drivers/net/sfc/efx/sfc_ethdev.c b/drivers/net/sfc/efx/sfc_ethdev.c
index 98e5d83..4f94653 100644
--- a/drivers/net/sfc/efx/sfc_ethdev.c
+++ b/drivers/net/sfc/efx/sfc_ethdev.c
@@ -386,6 +386,7 @@ sfc_eth_dev_init(struct rte_eth_dev *dev)

dev->dev_ops = _eth_dev_ops;
dev->rx_pkt_burst = _recv_pkts;
+   dev->tx_pkt_burst = _xmit_pkts;

sfc_adapter_unlock(sa);

@@ -424,6 +425,7 @@ sfc_eth_dev_uninit(struct rte_eth_dev *dev)

dev->dev_ops = NULL;
dev->rx_pkt_burst = NULL;
+   dev->tx_pkt_burst = NULL;

sfc_kvargs_cleanup(sa);

diff --git a/drivers/net/sfc/efx/sfc_ev.c b/drivers/net/sfc/efx/sfc_ev.c
index b3cecbb..8b3f098 100644
--- a/drivers/net/sfc/efx/sfc_ev.c
+++ b/drivers/net/sfc/efx/sfc_ev.c
@@ -142,9 +142,27 @@ static boolean_t
 sfc_ev_tx(void *arg, uint32_t label, uint32_t id)
 {
struct sfc_evq *evq = arg;
+   struct sfc_txq *txq;
+   unsigned int stop;
+   unsigned int delta;

-   sfc_err(evq->sa, "EVQ %u unexpected Tx event", evq->evq_index);
-   return B_TRUE;
+   txq = evq->txq;
+
+   SFC_ASSERT(txq != NULL);
+   SFC_ASSERT(txq->evq == evq);
+
+   if (unlikely((txq->state & SFC_TXQ_STARTED) == 0))
+   goto done;
+
+   stop = (id + 1) & txq->ptr_mask;
+   id = txq->pending & txq->ptr_mask;
+
+   delta = (stop >= id) ? (stop - id) : (txq->ptr_mask + 1 - id + stop);
+
+   txq->pending += delta;
+
+done:
+   return B_FALSE;
 }

 static boolean_t
diff --git a/drivers/net/sfc/efx/sfc_tweak.h b/drivers/net/sfc/efx/sfc_tweak.h
index 24cb9f4..60b618b 100644
--- a/drivers/net/sfc/efx/sfc_tweak.h
+++ b/drivers/net/sfc/efx/sfc_tweak.h
@@ -41,4 +41,11 @@
  */
 #defineSFC_RX_REFILL_BULK  (RTE_CACHE_LINE_SIZE / 
sizeof(efx_qword_t))

+/**
+ * Make the transmit path reap at least one time per a burst;
+ * this improves cache locality because the same mbufs may be used to send
+ * subsequent bursts in certain cases because of well-timed reap
+ */
+#defineSFC_TX_XMIT_PKTS_REAP_AT_LEAST_ONCE 0
+
 #endif /* _SFC_TWEAK_H_ */
diff --git a/drivers/net/sfc/efx/sfc_tx.c b/drivers/net/sfc/efx/sfc_tx.c
index 99d845a..92e81a8 100644
--- a/drivers/net/sfc/efx/sfc_tx.c
+++ b/drivers/net/sfc/efx/sfc_tx.c
@@ -32,6 +32,7 @@
 #include "sfc_log.h"
 #include "sfc_ev.h"
 #include "sfc_tx.h"
+#include "sfc_tweak.h"

 /*
  * Maximum number of TX queue flush attempts in case of
@@ -529,3 +530,117 @@ sfc_tx_stop(struct sfc_adapter *sa)

efx_tx_fini(sa->nic);
 }
+
+uint16_t
+sfc_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
+{
+   struct sfc_txq *txq = (struct sfc_txq *)tx_queue;
+   unsigned int added = txq->added;
+   unsigned int pushed = added;
+   unsigned int pkts_sent = 0;
+   efx_desc_t *pend = >pend_desc[0];
+   const unsigned int hard_max_fill = EFX_TXQ_LIMIT(txq->ptr_mask + 1);
+   const unsigned int soft_max_fill = hard_max_fill -
+  SFC_TX_MAX_PKT_DESC;
+   unsigned int fill_level = added - txq->completed;
+   boolean_t reap_done;
+   int rc;
+   struct rte_mbuf **pktp;
+
+   if (unlikely((txq->state & SFC_TXQ_RUNNING) == 0))
+   goto done;
+
+   /*
+* If insufficient space for a single packet is present,
+* we should reap; otherwise, we shouldn't do that all the time
+* to avoid latency increase
+*/
+   reap_done = (fill_level > soft_max_fill);
+
+   if (reap_done) {
+   sfc_tx_reap(txq);
+   /*
+* Recalculate fill level since 'txq->completed'
+* might have changed on reap
+*/
+   fill_level = added - txq->completed;
+   }
+
+   for (pkts_sent = 0, pktp = _pkts[0];
+(pkts_sent < nb_pkts) && (fill_level <= soft_max_fill);
+pkts_sent++, pktp++) {
+   struct rte_mbuf *m_seg = *pktp;
+   size_t  pkt_len = m_seg->pkt_len;
+   unsigned intpkt_descs = 0;
+
+   for (; m_seg != NULL; m_seg = m_seg->next) {
+   efsys_dma_addr_tnext_frag;
+   size_t  seg_len;
+
+   seg_len = m_seg->data_len;
+   next_frag = rte_mbuf_data_dma_addr(m_seg);
+
+   do {
+   efsys_dma_addr_tfrag_addr = next_frag;
+   

[dpdk-dev] [PATCH 54/56] net/sfc: add callbacks to set up and release Tx queues

2016-11-21 Thread Andrew Rybchenko
From: Ivan Malov 

Reviewed-by: Andy Moreton 
Signed-off-by: Ivan Malov 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/efx/sfc_ethdev.c |  58 ++
 drivers/net/sfc/efx/sfc_ev.h |   2 +
 drivers/net/sfc/efx/sfc_tx.c | 167 +++
 drivers/net/sfc/efx/sfc_tx.h |  36 +
 4 files changed, 263 insertions(+)

diff --git a/drivers/net/sfc/efx/sfc_ethdev.c b/drivers/net/sfc/efx/sfc_ethdev.c
index 4afd30c..98e5d83 100644
--- a/drivers/net/sfc/efx/sfc_ethdev.c
+++ b/drivers/net/sfc/efx/sfc_ethdev.c
@@ -39,6 +39,7 @@
 #include "sfc_kvargs.h"
 #include "sfc_ev.h"
 #include "sfc_rx.h"
+#include "sfc_tx.h"


 static void
@@ -266,6 +267,61 @@ sfc_rx_queue_release(void *queue)
sfc_adapter_unlock(sa);
 }

+static int
+sfc_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
+  uint16_t nb_tx_desc, unsigned int socket_id,
+  const struct rte_eth_txconf *tx_conf)
+{
+   struct sfc_adapter *sa = dev->data->dev_private;
+   int rc;
+
+   sfc_log_init(sa, "TxQ = %u, nb_tx_desc = %u, socket_id = %u",
+tx_queue_id, nb_tx_desc, socket_id);
+
+   sfc_adapter_lock(sa);
+
+   rc = sfc_tx_qinit(sa, tx_queue_id, nb_tx_desc, socket_id, tx_conf);
+   if (rc != 0)
+   goto fail_tx_qinit;
+
+   dev->data->tx_queues[tx_queue_id] = sa->txq_info[tx_queue_id].txq;
+
+   sfc_adapter_unlock(sa);
+   return 0;
+
+fail_tx_qinit:
+   sfc_adapter_unlock(sa);
+   SFC_ASSERT(rc > 0);
+   return -rc;
+}
+
+static void
+sfc_tx_queue_release(void *queue)
+{
+   struct sfc_txq *txq = queue;
+   unsigned int sw_index;
+   struct sfc_adapter *sa;
+
+   if (txq == NULL)
+   return;
+
+   sw_index = sfc_txq_sw_index(txq);
+
+   SFC_ASSERT(txq->evq != NULL);
+   sa = txq->evq->sa;
+
+   sfc_log_init(sa, "TxQ = %u", sw_index);
+
+   sfc_adapter_lock(sa);
+
+   SFC_ASSERT(sw_index < sa->eth_dev->data->nb_tx_queues);
+   sa->eth_dev->data->tx_queues[sw_index] = NULL;
+
+   sfc_tx_qfini(sa, sw_index);
+
+   sfc_adapter_unlock(sa);
+}
+
 static const struct eth_dev_ops sfc_eth_dev_ops = {
.dev_configure  = sfc_dev_configure,
.dev_start  = sfc_dev_start,
@@ -275,6 +331,8 @@ static const struct eth_dev_ops sfc_eth_dev_ops = {
.dev_infos_get  = sfc_dev_infos_get,
.rx_queue_setup = sfc_rx_queue_setup,
.rx_queue_release   = sfc_rx_queue_release,
+   .tx_queue_setup = sfc_tx_queue_setup,
+   .tx_queue_release   = sfc_tx_queue_release,
 };

 static int
diff --git a/drivers/net/sfc/efx/sfc_ev.h b/drivers/net/sfc/efx/sfc_ev.h
index d053182..71e51a5 100644
--- a/drivers/net/sfc/efx/sfc_ev.h
+++ b/drivers/net/sfc/efx/sfc_ev.h
@@ -41,6 +41,7 @@ extern "C" {

 struct sfc_adapter;
 struct sfc_rxq;
+struct sfc_txq;

 enum sfc_evq_state {
SFC_EVQ_UNINITIALIZED = 0,
@@ -58,6 +59,7 @@ struct sfc_evq {
boolean_t   exception;
efsys_mem_t mem;
struct sfc_rxq  *rxq;
+   struct sfc_txq  *txq;

/* Not used on datapath */
struct sfc_adapter  *sa;
diff --git a/drivers/net/sfc/efx/sfc_tx.c b/drivers/net/sfc/efx/sfc_tx.c
index fecd058..a4ffe9c 100644
--- a/drivers/net/sfc/efx/sfc_tx.c
+++ b/drivers/net/sfc/efx/sfc_tx.c
@@ -33,6 +33,165 @@
 #include "sfc_tx.h"

 static int
+sfc_tx_qcheck_conf(struct sfc_adapter *sa,
+  const struct rte_eth_txconf *tx_conf)
+{
+   unsigned int flags = tx_conf->txq_flags;
+   int rc = 0;
+
+   if (tx_conf->tx_rs_thresh != 0) {
+   sfc_err(sa, "RS bit in transmit descriptor is not supported");
+   rc = EINVAL;
+   }
+
+   if (tx_conf->tx_free_thresh != 0) {
+   sfc_err(sa,
+   "setting explicit TX free threshold is not supported");
+   rc = EINVAL;
+   }
+
+   if (tx_conf->tx_deferred_start != 0) {
+   sfc_err(sa, "TX queue deferred start is not supported (yet)");
+   rc = EINVAL;
+   }
+
+   if (tx_conf->tx_thresh.pthresh != 0 ||
+   tx_conf->tx_thresh.hthresh != 0 ||
+   tx_conf->tx_thresh.wthresh != 0) {
+   sfc_err(sa,
+   "prefetch/host/writeback thresholds are not supported");
+   rc = EINVAL;
+   }
+
+   if ((flags & ETH_TXQ_FLAGS_NOVLANOFFL) == 0) {
+   sfc_err(sa, "VLAN offload is not supported");
+   rc = EINVAL;
+   }
+
+   if ((flags & ETH_TXQ_FLAGS_NOXSUMSCTP) == 0) {
+   sfc_err(sa, "SCTP offload is not supported");
+   rc = EINVAL;
+   }
+
+   /* We either perform both TCP and UDP offload, or no offload at all */
+   if (((flags & 

[dpdk-dev] [PATCH 53/56] net/sfc: add function to check configured Tx mode

2016-11-21 Thread Andrew Rybchenko
From: Ivan Malov 

Reviewed-by: Andy Moreton 
Signed-off-by: Ivan Malov 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/efx/sfc_tx.c | 42 ++
 1 file changed, 42 insertions(+)

diff --git a/drivers/net/sfc/efx/sfc_tx.c b/drivers/net/sfc/efx/sfc_tx.c
index c418185..fecd058 100644
--- a/drivers/net/sfc/efx/sfc_tx.c
+++ b/drivers/net/sfc/efx/sfc_tx.c
@@ -43,12 +43,53 @@ sfc_tx_qinit_info(struct sfc_adapter *sa, unsigned int 
sw_index)
return 0;
 }

+static int
+sfc_tx_check_mode(struct sfc_adapter *sa, const struct rte_eth_txmode *txmode)
+{
+   int rc = 0;
+
+   switch (txmode->mq_mode) {
+   case ETH_MQ_TX_NONE:
+   break;
+   default:
+   sfc_err(sa, "Tx multi-queue mode %u not supported",
+   txmode->mq_mode);
+   rc = EINVAL;
+   }
+
+   /*
+* These features are claimed to be i40e-specific,
+* but it does make sense to double-check their absence
+*/
+   if (txmode->hw_vlan_reject_tagged) {
+   sfc_err(sa, "Rejecting tagged packets not supported");
+   rc = EINVAL;
+   }
+
+   if (txmode->hw_vlan_reject_untagged) {
+   sfc_err(sa, "Rejecting untagged packets not supported");
+   rc = EINVAL;
+   }
+
+   if (txmode->hw_vlan_insert_pvid) {
+   sfc_err(sa, "Port-based VLAN insertion not supported");
+   rc = EINVAL;
+   }
+
+   return rc;
+}
+
 int
 sfc_tx_init(struct sfc_adapter *sa)
 {
+   const struct rte_eth_conf *dev_conf = >eth_dev->data->dev_conf;
int sw_index;
int rc = 0;

+   rc = sfc_tx_check_mode(sa, _conf->txmode);
+   if (rc != 0)
+   goto fail_check_mode;
+
sa->txq_count = sa->eth_dev->data->nb_tx_queues;

sa->txq_info = rte_calloc_socket("sfc-txqs", sa->txq_count,
@@ -72,6 +113,7 @@ sfc_tx_init(struct sfc_adapter *sa)
 fail_txqs_alloc:
sa->txq_count = 0;

+fail_check_mode:
sfc_log_init(sa, "failed (rc = %d)", rc);
return rc;
 }
-- 
2.5.5



[dpdk-dev] [PATCH 52/56] net/sfc: provide basic stubs for Tx subsystem

2016-11-21 Thread Andrew Rybchenko
From: Ivan Malov 

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

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

 - Link state information

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

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

 VPATH += $(SRCDIR)/base

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


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

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

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

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

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

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

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

 struct sfc_evq_info;
 struct sfc_rxq_info;
+struct sfc_txq_info;

 struct sfc_port {
unsigned intflow_ctrl;
@@ -148,6 +149,8 @@ struct sfc_adapter {
unsigned intrxq_max;
unsigned inttxq_max;

+   unsigned inttxq_max_entries;
+
unsigned intevq_count;
struct sfc_evq_info *evq_info;

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

unsigned intrxq_count;
struct sfc_rxq_info *rxq_info;
+
+   unsigned inttxq_count;
+   struct sfc_txq_info *txq_info;
 };

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

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

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

+   dev_info->tx_offload_capa =
+   DEV_TX_OFFLOAD_IPV4_CKSUM |
+   DEV_TX_OFFLOAD_UDP_CKSUM |
+

[dpdk-dev] [PATCH 51/56] net/sfc: discard scattered packet on Rx correctly

2016-11-21 Thread Andrew Rybchenko
Since Rx scatter is not supported, all scattered packets are discarded.
It is not always possible to disable scatter on Huntington, so we
should handle scattered packets correctly in any case.

Reviewed-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/efx/sfc_ev.c | 22 +-
 drivers/net/sfc/efx/sfc_rx.c |  8 
 2 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/drivers/net/sfc/efx/sfc_ev.c b/drivers/net/sfc/efx/sfc_ev.c
index ae966fc..8f260e7 100644
--- a/drivers/net/sfc/efx/sfc_ev.c
+++ b/drivers/net/sfc/efx/sfc_ev.c
@@ -90,7 +90,27 @@ sfc_ev_rx(void *arg, uint32_t label, uint32_t id, uint32_t 
size, uint16_t flags)
delta = (stop >= pending_id) ? (stop - pending_id) :
(rxq->ptr_mask + 1 - pending_id + stop);

-   if (unlikely(delta > rxq->batch_max)) {
+   if (delta == 0) {
+   /*
+* Rx event with no new descriptors done and zero length
+* is used to abort scattered packet when there is no room
+* for the tail.
+*/
+   if (unlikely(size != 0)) {
+   evq->exception = B_TRUE;
+   sfc_err(evq->sa,
+   "EVQ %u RxQ %u invalid RX abort "
+   "(id=%#x size=%u flags=%#x); needs restart\n",
+   evq->evq_index, sfc_rxq_sw_index(rxq),
+   id, size, flags);
+   goto done;
+   }
+
+   /* Add discard flag to the first fragment */
+   rxq->sw_desc[pending_id].flags |= EFX_DISCARD;
+   /* Remove continue flag from the last fragment */
+   rxq->sw_desc[id].flags &= ~EFX_PKT_CONT;
+   } else if (unlikely(delta > rxq->batch_max)) {
evq->exception = B_TRUE;

sfc_err(evq->sa,
diff --git a/drivers/net/sfc/efx/sfc_rx.c b/drivers/net/sfc/efx/sfc_rx.c
index 307734e..ec4cbd4 100644
--- a/drivers/net/sfc/efx/sfc_rx.c
+++ b/drivers/net/sfc/efx/sfc_rx.c
@@ -137,6 +137,7 @@ sfc_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, 
uint16_t nb_pkts)
unsigned int completed;
unsigned int prefix_size = rxq->prefix_size;
unsigned int done_pkts = 0;
+   boolean_t discard_next = B_FALSE;

if (unlikely((rxq->state & SFC_RXQ_RUNNING) == 0))
return 0;
@@ -156,9 +157,15 @@ sfc_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, 
uint16_t nb_pkts)
m = rxd->mbuf;
desc_flags = rxd->flags;

+   if (discard_next)
+   goto discard;
+
if (desc_flags & (EFX_ADDR_MISMATCH | EFX_DISCARD))
goto discard;

+   if (desc_flags & EFX_PKT_CONT)
+   goto discard;
+
if (desc_flags & EFX_PKT_PREFIX_LEN) {
uint16_t tmp_size;
int rc;
@@ -182,6 +189,7 @@ sfc_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, 
uint16_t nb_pkts)
continue;

 discard:
+   discard_next = ((desc_flags & EFX_PKT_CONT) != 0);
rte_mempool_put(rxq->refill_mb_pool, m);
rxd->mbuf = NULL;
}
-- 
2.5.5



[dpdk-dev] [PATCH 50/56] net/sfc: implement device callback to Rx burst of packets

2016-11-21 Thread Andrew Rybchenko
Reviewed-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/efx/sfc_ethdev.c |  2 ++
 drivers/net/sfc/efx/sfc_ev.c | 47 --
 drivers/net/sfc/efx/sfc_rx.c | 72 +++-
 drivers/net/sfc/efx/sfc_rx.h |  7 
 4 files changed, 125 insertions(+), 3 deletions(-)

diff --git a/drivers/net/sfc/efx/sfc_ethdev.c b/drivers/net/sfc/efx/sfc_ethdev.c
index c889325..61ae1bd 100644
--- a/drivers/net/sfc/efx/sfc_ethdev.c
+++ b/drivers/net/sfc/efx/sfc_ethdev.c
@@ -310,6 +310,7 @@ sfc_eth_dev_init(struct rte_eth_dev *dev)
ether_addr_copy(from, >data->mac_addrs[0]);

dev->dev_ops = _eth_dev_ops;
+   dev->rx_pkt_burst = _recv_pkts;

sfc_adapter_unlock(sa);

@@ -347,6 +348,7 @@ sfc_eth_dev_uninit(struct rte_eth_dev *dev)
dev->data->mac_addrs = NULL;

dev->dev_ops = NULL;
+   dev->rx_pkt_burst = NULL;

sfc_kvargs_cleanup(sa);

diff --git a/drivers/net/sfc/efx/sfc_ev.c b/drivers/net/sfc/efx/sfc_ev.c
index 6750bfb..ae966fc 100644
--- a/drivers/net/sfc/efx/sfc_ev.c
+++ b/drivers/net/sfc/efx/sfc_ev.c
@@ -69,9 +69,52 @@ static boolean_t
 sfc_ev_rx(void *arg, uint32_t label, uint32_t id, uint32_t size, uint16_t 
flags)
 {
struct sfc_evq *evq = arg;
+   struct sfc_rxq *rxq;
+   unsigned int stop;
+   unsigned int pending_id;
+   unsigned int delta;
+   unsigned int i;
+   struct sfc_rx_sw_desc *rxd;

-   sfc_err(evq->sa, "EVQ %u unexpected Rx event", evq->evq_index);
-   return B_TRUE;
+   if (unlikely(evq->exception))
+   goto done;
+
+   rxq = evq->rxq;
+
+   SFC_ASSERT(rxq != NULL);
+   SFC_ASSERT(rxq->evq == evq);
+   SFC_ASSERT(rxq->state & SFC_RXQ_STARTED);
+
+   stop = (id + 1) & rxq->ptr_mask;
+   pending_id = rxq->pending & rxq->ptr_mask;
+   delta = (stop >= pending_id) ? (stop - pending_id) :
+   (rxq->ptr_mask + 1 - pending_id + stop);
+
+   if (unlikely(delta > rxq->batch_max)) {
+   evq->exception = B_TRUE;
+
+   sfc_err(evq->sa,
+   "EVQ %u RxQ %u completion out of order "
+   "(id=%#x delta=%u flags=%#x); needs restart\n",
+   evq->evq_index, sfc_rxq_sw_index(rxq), id, delta,
+   flags);
+
+   goto done;
+   }
+
+   for (i = pending_id; i != stop; i = (i + 1) & rxq->ptr_mask) {
+   rxd = >sw_desc[i];
+
+   rxd->flags = flags;
+
+   SFC_ASSERT(size < (1 << 16));
+   rxd->size = (uint16_t)size;
+   }
+
+   rxq->pending += delta;
+
+done:
+   return B_FALSE;
 }

 static boolean_t
diff --git a/drivers/net/sfc/efx/sfc_rx.c b/drivers/net/sfc/efx/sfc_rx.c
index 8e82ee0..307734e 100644
--- a/drivers/net/sfc/efx/sfc_rx.c
+++ b/drivers/net/sfc/efx/sfc_rx.c
@@ -32,6 +32,7 @@
 #include "efx.h"

 #include "sfc.h"
+#include "sfc_debug.h"
 #include "sfc_log.h"
 #include "sfc_ev.h"
 #include "sfc_rx.h"
@@ -129,6 +130,69 @@ sfc_rx_qrefill(struct sfc_rxq *rxq)
}
 }

+uint16_t
+sfc_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
+{
+   struct sfc_rxq *rxq = rx_queue;
+   unsigned int completed;
+   unsigned int prefix_size = rxq->prefix_size;
+   unsigned int done_pkts = 0;
+
+   if (unlikely((rxq->state & SFC_RXQ_RUNNING) == 0))
+   return 0;
+
+   sfc_ev_qpoll(rxq->evq);
+
+   completed = rxq->completed;
+   while (completed != rxq->pending && done_pkts < nb_pkts) {
+   unsigned int id;
+   struct sfc_rx_sw_desc *rxd;
+   struct rte_mbuf *m;
+   unsigned int seg_len;
+   unsigned int desc_flags;
+
+   id = completed++ & rxq->ptr_mask;
+   rxd = >sw_desc[id];
+   m = rxd->mbuf;
+   desc_flags = rxd->flags;
+
+   if (desc_flags & (EFX_ADDR_MISMATCH | EFX_DISCARD))
+   goto discard;
+
+   if (desc_flags & EFX_PKT_PREFIX_LEN) {
+   uint16_t tmp_size;
+   int rc;
+
+   rc = efx_psuedo_hdr_pkt_length_get(rxq->common,
+   rte_pktmbuf_mtod(m, uint8_t *), _size);
+   SFC_ASSERT(rc == 0);
+   seg_len = tmp_size;
+   } else {
+   seg_len = rxd->size - prefix_size;
+   }
+
+   m->data_off += prefix_size;
+   rte_pktmbuf_data_len(m) = seg_len;
+   rte_pktmbuf_pkt_len(m) = seg_len;
+
+   m->packet_type = RTE_PTYPE_L2_ETHER;
+
+   *rx_pkts++ = m;
+   done_pkts++;
+   continue;
+
+discard:
+   rte_mempool_put(rxq->refill_mb_pool, m);
+   rxd->mbuf = NULL;
+   }
+
+   rxq->completed = completed;
+
+   

[dpdk-dev] [PATCH 49/56] net/sfc: implement Rx queue start and stop operations

2016-11-21 Thread Andrew Rybchenko
These functions should set the queue state in dev->data->rx_queue_state
array.

Reviewed-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/efx/sfc.c   |   8 ++
 drivers/net/sfc/efx/sfc_ev.c|  23 +++-
 drivers/net/sfc/efx/sfc_rx.c| 297 
 drivers/net/sfc/efx/sfc_rx.h|  20 +++
 drivers/net/sfc/efx/sfc_tweak.h |  44 ++
 5 files changed, 386 insertions(+), 6 deletions(-)
 create mode 100644 drivers/net/sfc/efx/sfc_tweak.h

diff --git a/drivers/net/sfc/efx/sfc.c b/drivers/net/sfc/efx/sfc.c
index c0f48a8..1c0f59d 100644
--- a/drivers/net/sfc/efx/sfc.c
+++ b/drivers/net/sfc/efx/sfc.c
@@ -271,10 +271,17 @@ sfc_start(struct sfc_adapter *sa)
if (rc != 0)
goto fail_port_start;

+   rc = sfc_rx_start(sa);
+   if (rc != 0)
+   goto fail_rx_start;
+
sa->state = SFC_ADAPTER_STARTED;
sfc_log_init(sa, "done");
return 0;

+fail_rx_start:
+   sfc_port_stop(sa);
+
 fail_port_start:
sfc_ev_stop(sa);

@@ -313,6 +320,7 @@ sfc_stop(struct sfc_adapter *sa)

sa->state = SFC_ADAPTER_STOPPING;

+   sfc_rx_stop(sa);
sfc_port_stop(sa);
sfc_ev_stop(sa);
sfc_intr_stop(sa);
diff --git a/drivers/net/sfc/efx/sfc_ev.c b/drivers/net/sfc/efx/sfc_ev.c
index 8e2fc94..6750bfb 100644
--- a/drivers/net/sfc/efx/sfc_ev.c
+++ b/drivers/net/sfc/efx/sfc_ev.c
@@ -37,6 +37,7 @@
 #include "sfc_debug.h"
 #include "sfc_log.h"
 #include "sfc_ev.h"
+#include "sfc_rx.h"


 /* Initial delay when waiting for event queue init complete event */
@@ -112,20 +113,30 @@ static boolean_t
 sfc_ev_rxq_flush_done(void *arg, uint32_t rxq_hw_index)
 {
struct sfc_evq *evq = arg;
+   struct sfc_rxq *rxq;

-   sfc_err(evq->sa, "EVQ %u unexpected Rx flush done event",
-   evq->evq_index);
-   return B_TRUE;
+   rxq = evq->rxq;
+   SFC_ASSERT(rxq != NULL);
+   SFC_ASSERT(rxq->hw_index == rxq_hw_index);
+   SFC_ASSERT(rxq->evq == evq);
+   sfc_rx_qflush_done(rxq);
+
+   return B_FALSE;
 }

 static boolean_t
 sfc_ev_rxq_flush_failed(void *arg, uint32_t rxq_hw_index)
 {
struct sfc_evq *evq = arg;
+   struct sfc_rxq *rxq;

-   sfc_err(evq->sa, "EVQ %u unexpected Rx flush failed event",
-   evq->evq_index);
-   return B_TRUE;
+   rxq = evq->rxq;
+   SFC_ASSERT(rxq != NULL);
+   SFC_ASSERT(rxq->hw_index == rxq_hw_index);
+   SFC_ASSERT(rxq->evq == evq);
+   sfc_rx_qflush_failed(rxq);
+
+   return B_FALSE;
 }

 static boolean_t
diff --git a/drivers/net/sfc/efx/sfc_rx.c b/drivers/net/sfc/efx/sfc_rx.c
index 0e1e399..8e82ee0 100644
--- a/drivers/net/sfc/efx/sfc_rx.c
+++ b/drivers/net/sfc/efx/sfc_rx.c
@@ -27,12 +27,261 @@
  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */

+#include 
+
 #include "efx.h"

 #include "sfc.h"
 #include "sfc_log.h"
 #include "sfc_ev.h"
 #include "sfc_rx.h"
+#include "sfc_tweak.h"
+
+/*
+ * Maximum number of Rx queue flush attempt in the case of failure or
+ * flush timeout
+ */
+#defineSFC_RX_QFLUSH_ATTEMPTS  (3)
+
+/*
+ * Time to wait between event queue polling attempts when waiting for Rx
+ * queue flush done or failed events.
+ */
+#defineSFC_RX_QFLUSH_POLL_WAIT_MS  (1)
+
+/*
+ * Maximum number of event queue polling attempts when wating for Rx queue
+ * flush done or failed events. It defines Rx queue flush attempt timeout
+ * together with SFC_RX_QFLUSH_POLL_WAIT_MS.
+ */
+#defineSFC_RX_QFLUSH_POLL_ATTEMPTS (2000)
+
+void
+sfc_rx_qflush_done(struct sfc_rxq *rxq)
+{
+   rxq->state |= SFC_RXQ_FLUSHED;
+   rxq->state &= ~SFC_RXQ_FLUSHING;
+}
+
+void
+sfc_rx_qflush_failed(struct sfc_rxq *rxq)
+{
+   rxq->state |= SFC_RXQ_FLUSH_FAILED;
+   rxq->state &= ~SFC_RXQ_FLUSHING;
+}
+
+static void
+sfc_rx_qrefill(struct sfc_rxq *rxq)
+{
+   unsigned int free_space;
+   unsigned int bulks;
+   void *objs[SFC_RX_REFILL_BULK];
+   efsys_dma_addr_t addr[RTE_DIM(objs)];
+   unsigned int added = rxq->added;
+   unsigned int id;
+   unsigned int i;
+   struct sfc_rx_sw_desc *rxd;
+   struct rte_mbuf *m;
+   uint8_t port_id = rxq->port_id;
+
+   free_space = EFX_RXQ_LIMIT(rxq->ptr_mask + 1) -
+   (added - rxq->completed);
+   bulks = free_space / RTE_DIM(objs);
+
+   id = added & rxq->ptr_mask;
+   while (bulks-- > 0) {
+   if (rte_mempool_get_bulk(rxq->refill_mb_pool, objs,
+RTE_DIM(objs)) < 0) {
+   /*
+* It is hardly a safe way to increment counter
+* from different contexts, but all PMDs do it.
+*/
+   rxq->evq->sa->eth_dev->data->rx_mbuf_alloc_failed +=
+   RTE_DIM(objs);
+   break;
+   }
+
+   for (i = 0; 

[dpdk-dev] [PATCH 48/56] net/sfc: validate Rx queue buffers setup

2016-11-21 Thread Andrew Rybchenko
Check that Rx mbuf pool, MTU and Rx scatter config are in sync.

Reviewed-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 doc/guides/nics/sfc_efx.rst  | 10 ++
 drivers/net/sfc/efx/sfc_rx.c | 14 ++
 2 files changed, 24 insertions(+)

diff --git a/doc/guides/nics/sfc_efx.rst b/doc/guides/nics/sfc_efx.rst
index 87b217f8..8145a6b 100644
--- a/doc/guides/nics/sfc_efx.rst
+++ b/doc/guides/nics/sfc_efx.rst
@@ -73,6 +73,16 @@ The features not yet supported include:
 - LRO


+Limitations
+---
+
+Due to requirements on receive buffer alignment and usage of the receive
+buffer for the auxiliary packet information provided by the NIC up to
+extra 269 (14 bytes prefix plus up to 255 bytes for end padding) bytes may be
+required in the receive buffer.
+It should be taken into account when mbuf pool for receive is created.
+
+
 Supported NICs
 --

diff --git a/drivers/net/sfc/efx/sfc_rx.c b/drivers/net/sfc/efx/sfc_rx.c
index bfe92bf..0e1e399 100644
--- a/drivers/net/sfc/efx/sfc_rx.c
+++ b/drivers/net/sfc/efx/sfc_rx.c
@@ -172,6 +172,7 @@ sfc_rx_qinit(struct sfc_adapter *sa, unsigned int sw_index,
 const struct rte_eth_rxconf *rx_conf,
 struct rte_mempool *mb_pool)
 {
+   const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic);
int rc;
uint16_t buf_size;
struct sfc_rxq_info *rxq_info;
@@ -187,6 +188,19 @@ sfc_rx_qinit(struct sfc_adapter *sa, unsigned int sw_index,
if (buf_size == 0) {
sfc_err(sa, "RxQ %u mbuf pool object size is too small",
sw_index);
+   rc = EINVAL;
+   goto fail_bad_conf;
+   }
+
+   if ((buf_size < sa->port.pdu + encp->enc_rx_prefix_size) &&
+   !sa->eth_dev->data->dev_conf.rxmode.enable_scatter) {
+   sfc_err(sa, "Rx scatter is disabled and RxQ %u mbuf pool "
+   "object size is too small", sw_index);
+   sfc_err(sa, "RxQ %u calculated Rx buffer size is %u vs "
+   "PDU size %u plus Rx prefix %u bytes",
+   sw_index, buf_size, (unsigned int)sa->port.pdu,
+   encp->enc_rx_prefix_size);
+   rc = EINVAL;
goto fail_bad_conf;
}

-- 
2.5.5



[dpdk-dev] [PATCH 47/56] net/sfc: calculate Rx buffer size which may be used

2016-11-21 Thread Andrew Rybchenko
Take Rx buffer start alignment and end-padding into account.

Reviewed-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/efx/sfc_rx.c | 110 +--
 drivers/net/sfc/efx/sfc_rx.h |   1 +
 2 files changed, 107 insertions(+), 4 deletions(-)

diff --git a/drivers/net/sfc/efx/sfc_rx.c b/drivers/net/sfc/efx/sfc_rx.c
index d4a1a02..bfe92bf 100644
--- a/drivers/net/sfc/efx/sfc_rx.c
+++ b/drivers/net/sfc/efx/sfc_rx.c
@@ -66,6 +66,106 @@ sfc_rx_qcheck_conf(struct sfc_adapter *sa,
return rc;
 }

+static unsigned int
+sfc_rx_mbuf_data_alignment(struct rte_mempool *mb_pool)
+{
+   int data_off;
+   int order;
+
+   /* The mbuf object itself is always cache line aligned */
+   order = rte_bsf32(RTE_CACHE_LINE_SIZE);
+
+   /* Data offset from mbuf object start */
+   data_off = sizeof(struct rte_mbuf) + rte_pktmbuf_priv_size(mb_pool) +
+   RTE_PKTMBUF_HEADROOM;
+
+   order = MIN(order, rte_bsf32(data_off));
+
+   return 1u << (order - 1);
+}
+
+static uint16_t
+sfc_rx_mb_pool_buf_size(struct sfc_adapter *sa, struct rte_mempool *mb_pool)
+{
+   const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic);
+   const uint32_t nic_align_start = MAX(1, encp->enc_rx_buf_align_start);
+   const uint32_t nic_align_end = MAX(1, encp->enc_rx_buf_align_end);
+   uint16_t buf_size;
+   unsigned int buf_aligned;
+   unsigned int start_alignment;
+   unsigned int end_padding_alignment;
+
+   /* Below it is assumed that both alignments are power of 2 */
+   SFC_ASSERT(rte_is_power_of_2(nic_align_start));
+   SFC_ASSERT(rte_is_power_of_2(nic_align_end));
+
+   /*
+* mbuf is always cache line aligned, double-check
+* that it meets rx buffer start alignment requirements.
+*/
+
+   /* Start from mbuf pool data room size */
+   buf_size = rte_pktmbuf_data_room_size(mb_pool);
+
+   /* Remove headroom */
+   if (buf_size <= RTE_PKTMBUF_HEADROOM) {
+   sfc_err(sa,
+   "RxQ mbuf pool %s object data room size %u is smaller 
than headroom %u",
+   mb_pool->name, buf_size, RTE_PKTMBUF_HEADROOM);
+   return 0;
+   }
+   buf_size -= RTE_PKTMBUF_HEADROOM;
+
+   /* Calculate guaranteed data start alignment */
+   buf_aligned = sfc_rx_mbuf_data_alignment(mb_pool);
+
+   /* Reserve space for start alignment */
+   if (buf_aligned < nic_align_start) {
+   start_alignment = nic_align_start - buf_aligned;
+   if (buf_size <= start_alignment) {
+   sfc_err(sa,
+   "RxQ mbuf pool %s object data room size %u is 
insufficient for headroom %u and buffer start alignment %u required by NIC",
+   mb_pool->name,
+   rte_pktmbuf_data_room_size(mb_pool),
+   RTE_PKTMBUF_HEADROOM, start_alignment);
+   return 0;
+   }
+   buf_aligned = nic_align_start;
+   buf_size -= start_alignment;
+   } else {
+   start_alignment = 0;
+   }
+
+   /* Make sure that end padding does not write beyond the buffer */
+   if (buf_aligned < nic_align_end) {
+   /*
+* Estimate space which can be lost. If guarnteed buffer
+* size is odd, lost space is (nic_align_end - 1). More
+* accurate formula is below.
+*/
+   end_padding_alignment = nic_align_end -
+   MIN(buf_aligned, 1 << (rte_bsf32(buf_size) - 1));
+   if (buf_size <= end_padding_alignment) {
+   sfc_err(sa,
+   "RxQ mbuf pool %s object data room size %u is 
insufficient for headroom %u, buffer start alignment %u and end padding 
alignment %u required by NIC",
+   mb_pool->name,
+   rte_pktmbuf_data_room_size(mb_pool),
+   RTE_PKTMBUF_HEADROOM, start_alignment,
+   end_padding_alignment);
+   return 0;
+   }
+   buf_size -= end_padding_alignment;
+   } else {
+   /*
+* Start is aligned the same or better than end,
+* just align length.
+*/
+   buf_size = P2ALIGN(buf_size, nic_align_end);
+   }
+
+   return buf_size;
+}
+
 int
 sfc_rx_qinit(struct sfc_adapter *sa, unsigned int sw_index,
 uint16_t nb_rx_desc, unsigned int socket_id,
@@ -73,6 +173,7 @@ sfc_rx_qinit(struct sfc_adapter *sa, unsigned int sw_index,
 struct rte_mempool *mb_pool)
 {
int rc;
+   uint16_t buf_size;
struct sfc_rxq_info *rxq_info;
unsigned int evq_index;
struct sfc_evq *evq;
@@ -82,10 +183,10 @@ 

[dpdk-dev] [PATCH 46/56] net/sfc: implement Rx queue setup release operations

2016-11-21 Thread Andrew Rybchenko
Reviewed-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/efx/sfc_ethdev.c |  60 
 drivers/net/sfc/efx/sfc_ev.h |   2 +
 drivers/net/sfc/efx/sfc_rx.c | 147 +++
 drivers/net/sfc/efx/sfc_rx.h |  64 +
 4 files changed, 273 insertions(+)

diff --git a/drivers/net/sfc/efx/sfc_ethdev.c b/drivers/net/sfc/efx/sfc_ethdev.c
index 8d628fe..c889325 100644
--- a/drivers/net/sfc/efx/sfc_ethdev.c
+++ b/drivers/net/sfc/efx/sfc_ethdev.c
@@ -38,6 +38,7 @@
 #include "sfc_log.h"
 #include "sfc_kvargs.h"
 #include "sfc_ev.h"
+#include "sfc_rx.h"


 static void
@@ -49,6 +50,8 @@ sfc_dev_infos_get(struct rte_eth_dev *dev, struct 
rte_eth_dev_info *dev_info)

dev_info->max_rx_pktlen = EFX_MAC_PDU_MAX;

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

@@ -191,6 +194,61 @@ sfc_dev_close(struct rte_eth_dev *dev)
sfc_log_init(sa, "done");
 }

+static int
+sfc_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id,
+  uint16_t nb_rx_desc, unsigned int socket_id,
+  const struct rte_eth_rxconf *rx_conf,
+  struct rte_mempool *mb_pool)
+{
+   struct sfc_adapter *sa = dev->data->dev_private;
+   int rc;
+
+   sfc_log_init(sa, "RxQ=%u nb_rx_desc=%u socket_id=%u",
+rx_queue_id, nb_rx_desc, socket_id);
+
+   sfc_adapter_lock(sa);
+
+   rc = sfc_rx_qinit(sa, rx_queue_id, nb_rx_desc, socket_id,
+ rx_conf, mb_pool);
+   if (rc != 0)
+   goto fail_rx_qinit;
+
+   dev->data->rx_queues[rx_queue_id] = sa->rxq_info[rx_queue_id].rxq;
+
+   sfc_adapter_unlock(sa);
+
+   return 0;
+
+fail_rx_qinit:
+   sfc_adapter_unlock(sa);
+   SFC_ASSERT(rc > 0);
+   return -rc;
+}
+
+static void
+sfc_rx_queue_release(void *queue)
+{
+   struct sfc_rxq *rxq = queue;
+   struct sfc_adapter *sa;
+   unsigned int sw_index;
+
+   if (rxq == NULL)
+   return;
+
+   sa = rxq->evq->sa;
+   sfc_adapter_lock(sa);
+
+   sw_index = sfc_rxq_sw_index(rxq);
+
+   sfc_log_init(sa, "RxQ=%u", sw_index);
+
+   sa->eth_dev->data->rx_queues[sw_index] = NULL;
+
+   sfc_rx_qfini(sa, sw_index);
+
+   sfc_adapter_unlock(sa);
+}
+
 static const struct eth_dev_ops sfc_eth_dev_ops = {
.dev_configure  = sfc_dev_configure,
.dev_start  = sfc_dev_start,
@@ -198,6 +256,8 @@ static const struct eth_dev_ops sfc_eth_dev_ops = {
.dev_close  = sfc_dev_close,
.link_update= sfc_dev_link_update,
.dev_infos_get  = sfc_dev_infos_get,
+   .rx_queue_setup = sfc_rx_queue_setup,
+   .rx_queue_release   = sfc_rx_queue_release,
 };

 static int
diff --git a/drivers/net/sfc/efx/sfc_ev.h b/drivers/net/sfc/efx/sfc_ev.h
index f7bcf01..d053182 100644
--- a/drivers/net/sfc/efx/sfc_ev.h
+++ b/drivers/net/sfc/efx/sfc_ev.h
@@ -40,6 +40,7 @@ extern "C" {
 #defineSFC_MGMT_EVQ_ENTRIES(EFX_EVQ_MINNEVS)

 struct sfc_adapter;
+struct sfc_rxq;

 enum sfc_evq_state {
SFC_EVQ_UNINITIALIZED = 0,
@@ -56,6 +57,7 @@ struct sfc_evq {
unsigned intread_ptr;
boolean_t   exception;
efsys_mem_t mem;
+   struct sfc_rxq  *rxq;

/* Not used on datapath */
struct sfc_adapter  *sa;
diff --git a/drivers/net/sfc/efx/sfc_rx.c b/drivers/net/sfc/efx/sfc_rx.c
index bc43e4e..d4a1a02 100644
--- a/drivers/net/sfc/efx/sfc_rx.c
+++ b/drivers/net/sfc/efx/sfc_rx.c
@@ -31,9 +31,148 @@

 #include "sfc.h"
 #include "sfc_log.h"
+#include "sfc_ev.h"
 #include "sfc_rx.h"

 static int
+sfc_rx_qcheck_conf(struct sfc_adapter *sa,
+  const struct rte_eth_rxconf *rx_conf)
+{
+   int rc = 0;
+
+   if (rx_conf->rx_thresh.pthresh != 0 ||
+   rx_conf->rx_thresh.hthresh != 0 ||
+   rx_conf->rx_thresh.wthresh != 0) {
+   sfc_err(sa,
+   "RxQ prefetch/host/writeback thresholds are not 
supported");
+   rc = EINVAL;
+   }
+
+   if (rx_conf->rx_free_thresh != 0) {
+   sfc_err(sa, "RxQ free threshold is not supported");
+   rc = EINVAL;
+   }
+
+   if (rx_conf->rx_drop_en == 0) {
+   sfc_err(sa, "RxQ drop disable is not supported");
+   rc = EINVAL;
+   }
+
+   if (rx_conf->rx_deferred_start != 0) {
+   sfc_err(sa, "RxQ deferred start is not supported");
+   rc = EINVAL;
+   }
+
+   return rc;
+}
+
+int
+sfc_rx_qinit(struct sfc_adapter *sa, unsigned int sw_index,
+uint16_t nb_rx_desc, unsigned int socket_id,
+const struct rte_eth_rxconf 

[dpdk-dev] [PATCH 45/56] net/sfc: check configured rxmode

2016-11-21 Thread Andrew Rybchenko
Reviewed-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 doc/guides/nics/sfc_efx.rst  | 12 +
 drivers/net/sfc/efx/sfc_rx.c | 61 
 2 files changed, 73 insertions(+)

diff --git a/doc/guides/nics/sfc_efx.rst b/doc/guides/nics/sfc_efx.rst
index 46c892b..87b217f8 100644
--- a/doc/guides/nics/sfc_efx.rst
+++ b/doc/guides/nics/sfc_efx.rst
@@ -60,6 +60,18 @@ The features not yet supported include:

 - Loopback

+- Configurable RX CRC stripping (always stripped)
+
+- Header split on receive
+
+- VLAN filtering
+
+- VLAN stripping
+
+- Scattered receive
+
+- LRO
+

 Supported NICs
 --
diff --git a/drivers/net/sfc/efx/sfc_rx.c b/drivers/net/sfc/efx/sfc_rx.c
index 961e6b6..bc43e4e 100644
--- a/drivers/net/sfc/efx/sfc_rx.c
+++ b/drivers/net/sfc/efx/sfc_rx.c
@@ -48,6 +48,61 @@ sfc_rx_qinit_info(struct sfc_adapter *sa, unsigned int 
sw_index)
return 0;
 }

+static int
+sfc_rx_check_mode(struct sfc_adapter *sa, struct rte_eth_rxmode *rxmode)
+{
+   int rc = 0;
+
+   switch (rxmode->mq_mode) {
+   case ETH_MQ_RX_NONE:
+   /* No special checks are required */
+   break;
+   default:
+   sfc_err(sa, "Rx multi-queue mode %u not supported",
+   rxmode->mq_mode);
+   rc = EINVAL;
+   }
+
+   if (rxmode->header_split) {
+   sfc_err(sa, "Header split on Rx not supported");
+   rc = EINVAL;
+   }
+
+   if (rxmode->hw_vlan_filter) {
+   sfc_err(sa, "HW VLAN filtering not supported");
+   rc = EINVAL;
+   }
+
+   if (rxmode->hw_vlan_strip) {
+   sfc_err(sa, "HW VLAN stripping not supported");
+   rc = EINVAL;
+   }
+
+   if (rxmode->hw_vlan_extend) {
+   sfc_err(sa,
+   "Q-in-Q HW VLAN stripping not supported");
+   rc = EINVAL;
+   }
+
+   if (!rxmode->hw_strip_crc) {
+   sfc_warn(sa,
+"FCS stripping control not supported - always 
stripped");
+   rxmode->hw_strip_crc = 1;
+   }
+
+   if (rxmode->enable_scatter) {
+   sfc_err(sa, "Scatter on Rx not supported");
+   rc = EINVAL;
+   }
+
+   if (rxmode->enable_lro) {
+   sfc_err(sa, "LRO not supported");
+   rc = EINVAL;
+   }
+
+   return rc;
+}
+
 /**
  * Initialize Rx subsystem.
  *
@@ -59,9 +114,14 @@ sfc_rx_qinit_info(struct sfc_adapter *sa, unsigned int 
sw_index)
 int
 sfc_rx_init(struct sfc_adapter *sa)
 {
+   struct rte_eth_conf *dev_conf = >eth_dev->data->dev_conf;
unsigned int sw_index;
int rc;

+   rc = sfc_rx_check_mode(sa, _conf->rxmode);
+   if (rc != 0)
+   goto fail_check_mode;
+
sa->rxq_count = sa->eth_dev->data->nb_rx_queues;

rc = ENOMEM;
@@ -85,6 +145,7 @@ sfc_rx_init(struct sfc_adapter *sa)

 fail_rxqs_alloc:
sa->rxq_count = 0;
+fail_check_mode:
sfc_log_init(sa, "failed %d", rc);
return rc;
 }
-- 
2.5.5



[dpdk-dev] [PATCH 44/56] net/sfc: implement Rx subsystem stubs

2016-11-21 Thread Andrew Rybchenko
Reviewed-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/efx/Makefile |   1 +
 drivers/net/sfc/efx/sfc.c|   9 
 drivers/net/sfc/efx/sfc.h|   4 ++
 drivers/net/sfc/efx/sfc_ethdev.c |  10 
 drivers/net/sfc/efx/sfc_rx.c | 104 +++
 drivers/net/sfc/efx/sfc_rx.h |  53 
 6 files changed, 181 insertions(+)
 create mode 100644 drivers/net/sfc/efx/sfc_rx.c
 create mode 100644 drivers/net/sfc/efx/sfc_rx.h

diff --git a/drivers/net/sfc/efx/Makefile b/drivers/net/sfc/efx/Makefile
index 6e860b8..eb82c89 100644
--- a/drivers/net/sfc/efx/Makefile
+++ b/drivers/net/sfc/efx/Makefile
@@ -87,6 +87,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += sfc_mcdi.c
 SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += sfc_intr.c
 SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += sfc_ev.c
 SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += sfc_port.c
+SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += sfc_rx.c

 VPATH += $(SRCDIR)/base

diff --git a/drivers/net/sfc/efx/sfc.c b/drivers/net/sfc/efx/sfc.c
index 01e0c94..c0f48a8 100644
--- a/drivers/net/sfc/efx/sfc.c
+++ b/drivers/net/sfc/efx/sfc.c
@@ -37,6 +37,7 @@
 #include "sfc.h"
 #include "sfc_log.h"
 #include "sfc_ev.h"
+#include "sfc_rx.h"


 int
@@ -349,10 +350,17 @@ sfc_configure(struct sfc_adapter *sa)
if (rc != 0)
goto fail_port_init;

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

+fail_rx_init:
+   sfc_port_fini(sa);
+
 fail_port_init:
sfc_ev_fini(sa);

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

+   sfc_rx_fini(sa);
sfc_port_fini(sa);
sfc_ev_fini(sa);
sfc_intr_fini(sa);
diff --git a/drivers/net/sfc/efx/sfc.h b/drivers/net/sfc/efx/sfc.h
index f328482..a592b53 100644
--- a/drivers/net/sfc/efx/sfc.h
+++ b/drivers/net/sfc/efx/sfc.h
@@ -114,6 +114,7 @@ struct sfc_intr {
 };

 struct sfc_evq_info;
+struct sfc_rxq_info;

 struct sfc_port {
unsigned intflow_ctrl;
@@ -152,6 +153,9 @@ struct sfc_adapter {

unsigned intmgmt_evq_index;
rte_spinlock_t  mgmt_evq_lock;
+
+   unsigned intrxq_count;
+   struct sfc_rxq_info *rxq_info;
 };

 /*
diff --git a/drivers/net/sfc/efx/sfc_ethdev.c b/drivers/net/sfc/efx/sfc_ethdev.c
index a8a6a17..8d628fe 100644
--- a/drivers/net/sfc/efx/sfc_ethdev.c
+++ b/drivers/net/sfc/efx/sfc_ethdev.c
@@ -48,6 +48,16 @@ sfc_dev_infos_get(struct rte_eth_dev *dev, struct 
rte_eth_dev_info *dev_info)
sfc_log_init(sa, "entry");

dev_info->max_rx_pktlen = EFX_MAC_PDU_MAX;
+
+   /* By default packets are dropped if no descriptors are available */
+   dev_info->default_rxconf.rx_drop_en = 1;
+
+   dev_info->rx_desc_lim.nb_max = EFX_RXQ_MAXNDESCS;
+   dev_info->rx_desc_lim.nb_min = EFX_RXQ_MINNDESCS;
+   /* The RXQ hardware requires that the descriptor count is a power
+* of 2, but rx_desc_lim cannot properly describe that constraint.
+*/
+   dev_info->rx_desc_lim.nb_align = EFX_RXQ_MINNDESCS;
 }

 static int
diff --git a/drivers/net/sfc/efx/sfc_rx.c b/drivers/net/sfc/efx/sfc_rx.c
new file mode 100644
index 000..961e6b6
--- /dev/null
+++ b/drivers/net/sfc/efx/sfc_rx.c
@@ -0,0 +1,104 @@
+/*-
+ * Copyright (c) 2016 Solarflare Communications Inc.
+ * All rights reserved.
+ *
+ * This software was jointly developed between OKTET Labs (under contract
+ * for Solarflare) and Solarflare Communications, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *this list of conditions and the following disclaimer in the documentation
+ *and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF 

[dpdk-dev] [PATCH 42/56] net/sfc: minimum port control sufficient to receive traffic

2016-11-21 Thread Andrew Rybchenko
Reviewed-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/efx/Makefile |   1 +
 drivers/net/sfc/efx/sfc.c|  16 +
 drivers/net/sfc/efx/sfc.h|  12 
 drivers/net/sfc/efx/sfc_ethdev.c |   2 +
 drivers/net/sfc/efx/sfc_port.c   | 131 +++
 5 files changed, 162 insertions(+)
 create mode 100644 drivers/net/sfc/efx/sfc_port.c

diff --git a/drivers/net/sfc/efx/Makefile b/drivers/net/sfc/efx/Makefile
index a0b388f..6e860b8 100644
--- a/drivers/net/sfc/efx/Makefile
+++ b/drivers/net/sfc/efx/Makefile
@@ -86,6 +86,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += sfc.c
 SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += sfc_mcdi.c
 SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += sfc_intr.c
 SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += sfc_ev.c
+SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += sfc_port.c

 VPATH += $(SRCDIR)/base

diff --git a/drivers/net/sfc/efx/sfc.c b/drivers/net/sfc/efx/sfc.c
index 6870efe..01e0c94 100644
--- a/drivers/net/sfc/efx/sfc.c
+++ b/drivers/net/sfc/efx/sfc.c
@@ -266,10 +266,17 @@ sfc_start(struct sfc_adapter *sa)
if (rc != 0)
goto fail_ev_start;

+   rc = sfc_port_start(sa);
+   if (rc != 0)
+   goto fail_port_start;
+
sa->state = SFC_ADAPTER_STARTED;
sfc_log_init(sa, "done");
return 0;

+fail_port_start:
+   sfc_ev_stop(sa);
+
 fail_ev_start:
sfc_intr_stop(sa);

@@ -305,6 +312,7 @@ sfc_stop(struct sfc_adapter *sa)

sa->state = SFC_ADAPTER_STOPPING;

+   sfc_port_stop(sa);
sfc_ev_stop(sa);
sfc_intr_stop(sa);
efx_nic_fini(sa->nic);
@@ -337,10 +345,17 @@ sfc_configure(struct sfc_adapter *sa)
if (rc != 0)
goto fail_ev_init;

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

+fail_port_init:
+   sfc_ev_fini(sa);
+
 fail_ev_init:
sfc_intr_fini(sa);

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

+   sfc_port_fini(sa);
sfc_ev_fini(sa);
sfc_intr_fini(sa);

diff --git a/drivers/net/sfc/efx/sfc.h b/drivers/net/sfc/efx/sfc.h
index 39f15b1..ab867da 100644
--- a/drivers/net/sfc/efx/sfc.h
+++ b/drivers/net/sfc/efx/sfc.h
@@ -115,6 +115,12 @@ struct sfc_intr {

 struct sfc_evq_info;

+struct sfc_port {
+   unsigned intflow_ctrl;
+   boolean_t   flow_ctrl_autoneg;
+   size_t  pdu;
+};
+
 /* Adapter private data */
 struct sfc_adapter {
/*
@@ -136,6 +142,7 @@ struct sfc_adapter {

struct sfc_mcdi mcdi;
struct sfc_intr intr;
+   struct sfc_port port;

unsigned intrxq_max;
unsigned inttxq_max;
@@ -204,6 +211,11 @@ void sfc_intr_fini(struct sfc_adapter *sa);
 int sfc_intr_start(struct sfc_adapter *sa);
 void sfc_intr_stop(struct sfc_adapter *sa);

+int sfc_port_init(struct sfc_adapter *sa);
+void sfc_port_fini(struct sfc_adapter *sa);
+int sfc_port_start(struct sfc_adapter *sa);
+void sfc_port_stop(struct sfc_adapter *sa);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/drivers/net/sfc/efx/sfc_ethdev.c b/drivers/net/sfc/efx/sfc_ethdev.c
index ba99516..a328232 100644
--- a/drivers/net/sfc/efx/sfc_ethdev.c
+++ b/drivers/net/sfc/efx/sfc_ethdev.c
@@ -45,6 +45,8 @@ sfc_dev_infos_get(struct rte_eth_dev *dev, struct 
rte_eth_dev_info *dev_info)
struct sfc_adapter *sa = dev->data->dev_private;

sfc_log_init(sa, "entry");
+
+   dev_info->max_rx_pktlen = EFX_MAC_PDU_MAX;
 }

 static int
diff --git a/drivers/net/sfc/efx/sfc_port.c b/drivers/net/sfc/efx/sfc_port.c
new file mode 100644
index 000..844363c
--- /dev/null
+++ b/drivers/net/sfc/efx/sfc_port.c
@@ -0,0 +1,131 @@
+/*-
+ * Copyright (c) 2016 Solarflare Communications Inc.
+ * All rights reserved.
+ *
+ * This software was jointly developed between OKTET Labs (under contract
+ * for Solarflare) and Solarflare Communications, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *this list of conditions and the following disclaimer in the documentation
+ *and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * 

[dpdk-dev] [PATCH 41/56] net/sfc: periodic management EVQ polling using alarm

2016-11-21 Thread Andrew Rybchenko
Timers cannot be used to implement periodic polling, since it implies
requirement on application to process timers in the main loop.

Reviewed-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/efx/sfc_ev.c | 42 ++
 1 file changed, 42 insertions(+)

diff --git a/drivers/net/sfc/efx/sfc_ev.c b/drivers/net/sfc/efx/sfc_ev.c
index 1734b1e..1cb9771 100644
--- a/drivers/net/sfc/efx/sfc_ev.c
+++ b/drivers/net/sfc/efx/sfc_ev.c
@@ -29,6 +29,7 @@

 #include 
 #include 
+#include 

 #include "efx.h"

@@ -45,6 +46,9 @@
 /* Event queue init approx timeout */
 #defineSFC_EVQ_INIT_TIMEOUT_US (2 * US_PER_S)

+/* Management event queue polling period in microseconds */
+#defineSFC_MGMT_EV_QPOLL_PERIOD_US (US_PER_S)
+

 static boolean_t
 sfc_ev_initialized(void *arg)
@@ -326,6 +330,34 @@ sfc_ev_qstop(struct sfc_adapter *sa, unsigned int sw_index)
efx_ev_qdestroy(evq->common);
 }

+static void
+sfc_ev_mgmt_periodic_qpoll(void *arg)
+{
+   struct sfc_adapter *sa = arg;
+   int rc;
+
+   sfc_ev_mgmt_qpoll(sa);
+
+   rc = rte_eal_alarm_set(SFC_MGMT_EV_QPOLL_PERIOD_US,
+  sfc_ev_mgmt_periodic_qpoll, sa);
+   if (rc != 0)
+   sfc_panic(sa,
+ "cannot rearm management EVQ polling alarm (rc=%d)",
+ rc);
+}
+
+static void
+sfc_ev_mgmt_periodic_qpoll_start(struct sfc_adapter *sa)
+{
+   sfc_ev_mgmt_periodic_qpoll(sa);
+}
+
+static void
+sfc_ev_mgmt_periodic_qpoll_stop(struct sfc_adapter *sa)
+{
+   rte_eal_alarm_cancel(sfc_ev_mgmt_periodic_qpoll, sa);
+}
+
 int
 sfc_ev_start(struct sfc_adapter *sa)
 {
@@ -347,6 +379,14 @@ sfc_ev_start(struct sfc_adapter *sa)
rte_spinlock_unlock(>mgmt_evq_lock);

/*
+* Start management EVQ polling. If interrupts are disabled
+* (not used), it is required to process link status change
+* and other device level events to avoid unrecoverable
+* error because the event queue overflow.
+*/
+   sfc_ev_mgmt_periodic_qpoll_start(sa);
+
+   /*
 * Rx/Tx event queues are started/stopped when corresponding
 * Rx/Tx queue is started/stopped.
 */
@@ -369,6 +409,8 @@ sfc_ev_stop(struct sfc_adapter *sa)

sfc_log_init(sa, "entry");

+   sfc_ev_mgmt_periodic_qpoll_stop(sa);
+
/* Make sure that all event queues are stopped */
sw_index = sa->evq_count;
while (--sw_index >= 0) {
-- 
2.5.5



[dpdk-dev] [PATCH 40/56] net/sfc: maintain management event queue

2016-11-21 Thread Andrew Rybchenko
The event queue is required for device level events (e.g. link status
change) and flush events.
Provide thread-safe function to poll the event queue since it may be
really done from different contexts.

Reviewed-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/efx/sfc.h|  1 +
 drivers/net/sfc/efx/sfc_ev.c | 50 
 drivers/net/sfc/efx/sfc_ev.h |  2 ++
 3 files changed, 49 insertions(+), 4 deletions(-)

diff --git a/drivers/net/sfc/efx/sfc.h b/drivers/net/sfc/efx/sfc.h
index eb8c071..39f15b1 100644
--- a/drivers/net/sfc/efx/sfc.h
+++ b/drivers/net/sfc/efx/sfc.h
@@ -144,6 +144,7 @@ struct sfc_adapter {
struct sfc_evq_info *evq_info;

unsigned intmgmt_evq_index;
+   rte_spinlock_t  mgmt_evq_lock;
 };

 /*
diff --git a/drivers/net/sfc/efx/sfc_ev.c b/drivers/net/sfc/efx/sfc_ev.c
index aa04b34..1734b1e 100644
--- a/drivers/net/sfc/efx/sfc_ev.c
+++ b/drivers/net/sfc/efx/sfc_ev.c
@@ -213,6 +213,19 @@ sfc_ev_qpoll(struct sfc_evq *evq)
/* Poll-mode driver does not re-prime the event queue for interrupts */
 }

+void
+sfc_ev_mgmt_qpoll(struct sfc_adapter *sa)
+{
+   if (rte_spinlock_trylock(>mgmt_evq_lock)) {
+   struct sfc_evq *mgmt_evq = sa->evq_info[sa->mgmt_evq_index].evq;
+
+   if (mgmt_evq->init_state == SFC_EVQ_STARTED)
+   sfc_ev_qpoll(mgmt_evq);
+
+   rte_spinlock_unlock(>mgmt_evq_lock);
+   }
+}
+
 int
 sfc_ev_qprime(struct sfc_evq *evq)
 {
@@ -324,13 +337,26 @@ sfc_ev_start(struct sfc_adapter *sa)
if (rc != 0)
goto fail_ev_init;

+   /* Start management EVQ used for global events */
+   rte_spinlock_lock(>mgmt_evq_lock);
+
+   rc = sfc_ev_qstart(sa, sa->mgmt_evq_index);
+   if (rc != 0)
+   goto fail_mgmt_evq_start;
+
+   rte_spinlock_unlock(>mgmt_evq_lock);
+
/*
-* Rx/Tx event queues are started/stopped when corresponding queue
-* is started/stopped.
+* Rx/Tx event queues are started/stopped when corresponding
+* Rx/Tx queue is started/stopped.
 */

return 0;

+fail_mgmt_evq_start:
+   rte_spinlock_unlock(>mgmt_evq_lock);
+   efx_ev_fini(sa->nic);
+
 fail_ev_init:
sfc_log_init(sa, "failed %d", rc);
return rc;
@@ -345,8 +371,17 @@ sfc_ev_stop(struct sfc_adapter *sa)

/* Make sure that all event queues are stopped */
sw_index = sa->evq_count;
-   while (--sw_index >= 0)
-   sfc_ev_qstop(sa, sw_index);
+   while (--sw_index >= 0) {
+   if (sw_index == sa->mgmt_evq_index) {
+   /* Locks are required for the management EVQ */
+   rte_spinlock_lock(>mgmt_evq_lock);
+   sfc_ev_qstop(sa, sa->mgmt_evq_index);
+   rte_spinlock_unlock(>mgmt_evq_lock);
+   } else {
+   sfc_ev_qstop(sa, sw_index);
+   }
+   }
+

efx_ev_fini(sa->nic);
 }
@@ -444,6 +479,7 @@ sfc_ev_init(struct sfc_adapter *sa)

sa->evq_count = sfc_ev_qcount(sa);
sa->mgmt_evq_index = 0;
+   rte_spinlock_init(>mgmt_evq_lock);

/* Allocate EVQ info array */
rc = ENOMEM;
@@ -459,6 +495,11 @@ sfc_ev_init(struct sfc_adapter *sa)
goto fail_ev_qinit_info;
}

+   rc = sfc_ev_qinit(sa, sa->mgmt_evq_index, SFC_MGMT_EVQ_ENTRIES,
+ sa->socket_id);
+   if (rc != 0)
+   goto fail_mgmt_evq_init;
+
/*
 * Rx/Tx event queues are created/destroyed when corresponding
 * Rx/Tx queue is created/destroyed.
@@ -466,6 +507,7 @@ sfc_ev_init(struct sfc_adapter *sa)

return 0;

+fail_mgmt_evq_init:
 fail_ev_qinit_info:
while (sw_index-- > 0)
sfc_ev_qfini_info(sa, sw_index);
diff --git a/drivers/net/sfc/efx/sfc_ev.h b/drivers/net/sfc/efx/sfc_ev.h
index 140a436..f7bcf01 100644
--- a/drivers/net/sfc/efx/sfc_ev.h
+++ b/drivers/net/sfc/efx/sfc_ev.h
@@ -132,6 +132,8 @@ void sfc_ev_qstop(struct sfc_adapter *sa, unsigned int 
sw_index);
 int sfc_ev_qprime(struct sfc_evq *evq);
 void sfc_ev_qpoll(struct sfc_evq *evq);

+void sfc_ev_mgmt_qpoll(struct sfc_adapter *sa);
+
 #ifdef __cplusplus
 }
 #endif
-- 
2.5.5



[dpdk-dev] [PATCH 39/56] net/sfc: implement EVQ dummy exception handling

2016-11-21 Thread Andrew Rybchenko
Right now the code just logs the exception and sets flag to notify
subsequent event handlers and poller that recovery is required.

Reviewed-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/efx/sfc_ev.c | 20 ++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/drivers/net/sfc/efx/sfc_ev.c b/drivers/net/sfc/efx/sfc_ev.c
index 852051c..aa04b34 100644
--- a/drivers/net/sfc/efx/sfc_ev.c
+++ b/drivers/net/sfc/efx/sfc_ev.c
@@ -83,8 +83,24 @@ sfc_ev_exception(void *arg, uint32_t code, uint32_t data)
 {
struct sfc_evq *evq = arg;

-   sfc_err(evq->sa, "EVQ %u unexpected exception event",
-   evq->evq_index);
+   if (code == EFX_EXCEPTION_UNKNOWN_SENSOREVT)
+   return B_FALSE;
+
+   evq->exception = B_TRUE;
+   sfc_warn(evq->sa,
+"hardware exception %s (code=%u, data=%#x) on EVQ %u;"
+" needs recovery",
+(code == EFX_EXCEPTION_RX_RECOVERY) ? "RX_RECOVERY" :
+(code == EFX_EXCEPTION_RX_DSC_ERROR) ? "RX_DSC_ERROR" :
+(code == EFX_EXCEPTION_TX_DSC_ERROR) ? "TX_DSC_ERROR" :
+(code == EFX_EXCEPTION_FWALERT_SRAM) ? "FWALERT_SRAM" :
+(code == EFX_EXCEPTION_UNKNOWN_FWALERT) ? "UNKNOWN_FWALERT" :
+(code == EFX_EXCEPTION_RX_ERROR) ? "RX_ERROR" :
+(code == EFX_EXCEPTION_TX_ERROR) ? "TX_ERROR" :
+(code == EFX_EXCEPTION_EV_ERROR) ? "EV_ERROR" :
+"UNKNOWN",
+code, data, evq->evq_index);
+
return B_TRUE;
 }

-- 
2.5.5



[dpdk-dev] [PATCH 38/56] net/sfc: implement event queue support

2016-11-21 Thread Andrew Rybchenko
Reviewed-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/efx/Makefile |   1 +
 drivers/net/sfc/efx/sfc.c|  17 ++
 drivers/net/sfc/efx/sfc.h|   7 +
 drivers/net/sfc/efx/sfc_ev.c | 484 +++
 drivers/net/sfc/efx/sfc_ev.h | 138 
 5 files changed, 647 insertions(+)
 create mode 100644 drivers/net/sfc/efx/sfc_ev.c
 create mode 100644 drivers/net/sfc/efx/sfc_ev.h

diff --git a/drivers/net/sfc/efx/Makefile b/drivers/net/sfc/efx/Makefile
index 2d2f9b8..a0b388f 100644
--- a/drivers/net/sfc/efx/Makefile
+++ b/drivers/net/sfc/efx/Makefile
@@ -85,6 +85,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += sfc_kvargs.c
 SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += sfc.c
 SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += sfc_mcdi.c
 SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += sfc_intr.c
+SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += sfc_ev.c

 VPATH += $(SRCDIR)/base

diff --git a/drivers/net/sfc/efx/sfc.c b/drivers/net/sfc/efx/sfc.c
index d66ea4a..6870efe 100644
--- a/drivers/net/sfc/efx/sfc.c
+++ b/drivers/net/sfc/efx/sfc.c
@@ -36,6 +36,7 @@

 #include "sfc.h"
 #include "sfc_log.h"
+#include "sfc_ev.h"


 int
@@ -261,10 +262,17 @@ sfc_start(struct sfc_adapter *sa)
if (rc != 0)
goto fail_intr_start;

+   rc = sfc_ev_start(sa);
+   if (rc != 0)
+   goto fail_ev_start;
+
sa->state = SFC_ADAPTER_STARTED;
sfc_log_init(sa, "done");
return 0;

+fail_ev_start:
+   sfc_intr_stop(sa);
+
 fail_intr_start:
efx_nic_fini(sa->nic);

@@ -297,6 +305,7 @@ sfc_stop(struct sfc_adapter *sa)

sa->state = SFC_ADAPTER_STOPPING;

+   sfc_ev_stop(sa);
sfc_intr_stop(sa);
efx_nic_fini(sa->nic);

@@ -324,10 +333,17 @@ sfc_configure(struct sfc_adapter *sa)
if (rc != 0)
goto fail_intr_init;

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

+fail_ev_init:
+   sfc_intr_fini(sa);
+
 fail_intr_init:
 fail_check_conf:
sa->state = SFC_ADAPTER_INITIALIZED;
@@ -345,6 +361,7 @@ sfc_close(struct sfc_adapter *sa)
SFC_ASSERT(sa->state == SFC_ADAPTER_CONFIGURED);
sa->state = SFC_ADAPTER_CLOSING;

+   sfc_ev_fini(sa);
sfc_intr_fini(sa);

sa->state = SFC_ADAPTER_INITIALIZED;
diff --git a/drivers/net/sfc/efx/sfc.h b/drivers/net/sfc/efx/sfc.h
index 2b1c784..eb8c071 100644
--- a/drivers/net/sfc/efx/sfc.h
+++ b/drivers/net/sfc/efx/sfc.h
@@ -113,6 +113,8 @@ struct sfc_intr {
efx_intr_type_t type;
 };

+struct sfc_evq_info;
+
 /* Adapter private data */
 struct sfc_adapter {
/*
@@ -137,6 +139,11 @@ struct sfc_adapter {

unsigned intrxq_max;
unsigned inttxq_max;
+
+   unsigned intevq_count;
+   struct sfc_evq_info *evq_info;
+
+   unsigned intmgmt_evq_index;
 };

 /*
diff --git a/drivers/net/sfc/efx/sfc_ev.c b/drivers/net/sfc/efx/sfc_ev.c
new file mode 100644
index 000..852051c
--- /dev/null
+++ b/drivers/net/sfc/efx/sfc_ev.c
@@ -0,0 +1,484 @@
+/*-
+ * Copyright (c) 2016 Solarflare Communications Inc.
+ * All rights reserved.
+ *
+ * This software was jointly developed between OKTET Labs (under contract
+ * for Solarflare) and Solarflare Communications, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *this list of conditions and the following disclaimer in the documentation
+ *and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+#include 
+
+#include "efx.h"
+
+#include "sfc.h"
+#include "sfc_debug.h"
+#include "sfc_log.h"
+#include "sfc_ev.h"
+
+
+/* Initial delay when waiting for event queue init complete 

[dpdk-dev] [PATCH 37/56] net/sfc: interrupts support sufficient for event queue init

2016-11-21 Thread Andrew Rybchenko
Reviewed-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/efx/Makefile   |   1 +
 drivers/net/sfc/efx/sfc.c  |  22 +++
 drivers/net/sfc/efx/sfc.h  |  12 
 drivers/net/sfc/efx/sfc_intr.c | 129 +
 4 files changed, 164 insertions(+)
 create mode 100644 drivers/net/sfc/efx/sfc_intr.c

diff --git a/drivers/net/sfc/efx/Makefile b/drivers/net/sfc/efx/Makefile
index eadb1ea..2d2f9b8 100644
--- a/drivers/net/sfc/efx/Makefile
+++ b/drivers/net/sfc/efx/Makefile
@@ -84,6 +84,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += sfc_ethdev.c
 SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += sfc_kvargs.c
 SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += sfc.c
 SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += sfc_mcdi.c
+SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += sfc_intr.c

 VPATH += $(SRCDIR)/base

diff --git a/drivers/net/sfc/efx/sfc.c b/drivers/net/sfc/efx/sfc.c
index 6d5fb9a..d66ea4a 100644
--- a/drivers/net/sfc/efx/sfc.c
+++ b/drivers/net/sfc/efx/sfc.c
@@ -257,10 +257,17 @@ sfc_start(struct sfc_adapter *sa)
if (rc != 0)
goto fail_nic_init;

+   rc = sfc_intr_start(sa);
+   if (rc != 0)
+   goto fail_intr_start;
+
sa->state = SFC_ADAPTER_STARTED;
sfc_log_init(sa, "done");
return 0;

+fail_intr_start:
+   efx_nic_fini(sa->nic);
+
 fail_nic_init:
 fail_set_drv_limits:
sa->state = SFC_ADAPTER_CONFIGURED;
@@ -290,6 +297,7 @@ sfc_stop(struct sfc_adapter *sa)

sa->state = SFC_ADAPTER_STOPPING;

+   sfc_intr_stop(sa);
efx_nic_fini(sa->nic);

sa->state = SFC_ADAPTER_CONFIGURED;
@@ -312,10 +320,15 @@ sfc_configure(struct sfc_adapter *sa)
if (rc != 0)
goto fail_check_conf;

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

+fail_intr_init:
 fail_check_conf:
sa->state = SFC_ADAPTER_INITIALIZED;
sfc_log_init(sa, "failed %d", rc);
@@ -332,6 +345,8 @@ sfc_close(struct sfc_adapter *sa)
SFC_ASSERT(sa->state == SFC_ADAPTER_CONFIGURED);
sa->state = SFC_ADAPTER_CLOSING;

+   sfc_intr_fini(sa);
+
sa->state = SFC_ADAPTER_INITIALIZED;
sfc_log_init(sa, "done");
 }
@@ -423,6 +438,10 @@ sfc_attach(struct sfc_adapter *sa)
if (rc != 0)
goto fail_estimate_rsrc_limits;

+   rc = sfc_intr_attach(sa);
+   if (rc != 0)
+   goto fail_intr_attach;
+
sfc_log_init(sa, "fini nic");
efx_nic_fini(enp);

@@ -431,6 +450,7 @@ sfc_attach(struct sfc_adapter *sa)
sfc_log_init(sa, "done");
return 0;

+fail_intr_attach:
 fail_estimate_rsrc_limits:
 fail_nic_reset:
sfc_log_init(sa, "unprobe nic");
@@ -462,6 +482,8 @@ sfc_detach(struct sfc_adapter *sa)

SFC_ASSERT(sfc_adapter_is_locked(sa));

+   sfc_intr_detach(sa);
+
sfc_log_init(sa, "unprobe nic");
efx_nic_unprobe(enp);

diff --git a/drivers/net/sfc/efx/sfc.h b/drivers/net/sfc/efx/sfc.h
index 42d6898..2b1c784 100644
--- a/drivers/net/sfc/efx/sfc.h
+++ b/drivers/net/sfc/efx/sfc.h
@@ -109,6 +109,10 @@ struct sfc_mcdi {
efx_mcdi_transport_ttransport;
 };

+struct sfc_intr {
+   efx_intr_type_t type;
+};
+
 /* Adapter private data */
 struct sfc_adapter {
/*
@@ -129,6 +133,7 @@ struct sfc_adapter {
rte_spinlock_t  nic_lock;

struct sfc_mcdi mcdi;
+   struct sfc_intr intr;

unsigned intrxq_max;
unsigned inttxq_max;
@@ -184,6 +189,13 @@ void sfc_mcdi_fini(struct sfc_adapter *sa);
 int sfc_configure(struct sfc_adapter *sa);
 void sfc_close(struct sfc_adapter *sa);

+int sfc_intr_attach(struct sfc_adapter *sa);
+void sfc_intr_detach(struct sfc_adapter *sa);
+int sfc_intr_init(struct sfc_adapter *sa);
+void sfc_intr_fini(struct sfc_adapter *sa);
+int sfc_intr_start(struct sfc_adapter *sa);
+void sfc_intr_stop(struct sfc_adapter *sa);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/drivers/net/sfc/efx/sfc_intr.c b/drivers/net/sfc/efx/sfc_intr.c
new file mode 100644
index 000..ad92ada
--- /dev/null
+++ b/drivers/net/sfc/efx/sfc_intr.c
@@ -0,0 +1,129 @@
+/*-
+ * Copyright (c) 2016 Solarflare Communications Inc.
+ * All rights reserved.
+ *
+ * This software was jointly developed between OKTET Labs (under contract
+ * for Solarflare) and Solarflare Communications, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *this list of conditions and the 

[dpdk-dev] [PATCH 36/56] net/sfc: make available resources estimation and allocation

2016-11-21 Thread Andrew Rybchenko
Resources required in accordance with configuration are
allocated only.

Reviewed-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 doc/guides/nics/sfc_efx.rst |   8 +++
 drivers/net/sfc/efx/sfc.c   | 117 +---
 2 files changed, 117 insertions(+), 8 deletions(-)

diff --git a/doc/guides/nics/sfc_efx.rst b/doc/guides/nics/sfc_efx.rst
index 31e86a7..271c8c6 100644
--- a/doc/guides/nics/sfc_efx.rst
+++ b/doc/guides/nics/sfc_efx.rst
@@ -37,6 +37,14 @@ More information can be found at `Solarflare Communications 
website
 `_.


+Features
+
+
+SFC EFX PMD has support for:
+
+- Multiple transmit and receive queues
+
+
 Non-supported Features
 --

diff --git a/drivers/net/sfc/efx/sfc.c b/drivers/net/sfc/efx/sfc.c
index 8c780ac..6d5fb9a 100644
--- a/drivers/net/sfc/efx/sfc.c
+++ b/drivers/net/sfc/efx/sfc.c
@@ -126,6 +126,105 @@ sfc_check_conf(struct sfc_adapter *sa)
return rc;
 }

+/*
+ * Find out maximum number of receive and transmit queues which could be
+ * advertised.
+ *
+ * NIC is kept initialized on success to allow other modules acquire
+ * defaults and capabilities.
+ */
+static int
+sfc_estimate_resource_limits(struct sfc_adapter *sa)
+{
+   const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic);
+   efx_drv_limits_t limits;
+   int rc;
+   uint32_t evq_allocated;
+   uint32_t rxq_allocated;
+   uint32_t txq_allocated;
+
+   memset(, 0, sizeof(limits));
+
+   /* Request at least one Rx and Tx queue */
+   limits.edl_min_rxq_count = 1;
+   limits.edl_min_txq_count = 1;
+   /* Management event queue plus event queue for each Tx and Rx queue */
+   limits.edl_min_evq_count =
+   1 + limits.edl_min_rxq_count + limits.edl_min_txq_count;
+
+   /* Divide by number of functions to guarantee that all functions
+* will get promised resources
+*/
+   /* FIXME Divide by number of functions (not 2) below */
+   limits.edl_max_evq_count = encp->enc_evq_limit / 2;
+   SFC_ASSERT(limits.edl_max_evq_count >= limits.edl_min_rxq_count);
+
+   /* Split equally between receive and transmit */
+   limits.edl_max_rxq_count =
+   MIN(encp->enc_rxq_limit, (limits.edl_max_evq_count - 1) / 2);
+   SFC_ASSERT(limits.edl_max_rxq_count >= limits.edl_min_rxq_count);
+
+   limits.edl_max_txq_count =
+   MIN(encp->enc_txq_limit,
+   limits.edl_max_evq_count - 1 - limits.edl_max_rxq_count);
+   SFC_ASSERT(limits.edl_max_txq_count >= limits.edl_min_rxq_count);
+
+   /* Configure the minimum required resources needed for the
+* driver to operate, and the maximum desired resources that the
+* driver is capable of using.
+*/
+   efx_nic_set_drv_limits(sa->nic, );
+
+   sfc_log_init(sa, "init nic");
+   rc = efx_nic_init(sa->nic);
+   if (rc != 0)
+   goto fail_nic_init;
+
+   /* Find resource dimensions assigned by firmware to this function */
+   rc = efx_nic_get_vi_pool(sa->nic, _allocated, _allocated,
+_allocated);
+   if (rc != 0)
+   goto fail_get_vi_pool;
+
+   /* It still may allocate more than maximum, ensure limit */
+   evq_allocated = MIN(evq_allocated, limits.edl_max_evq_count);
+   rxq_allocated = MIN(rxq_allocated, limits.edl_max_rxq_count);
+   txq_allocated = MIN(txq_allocated, limits.edl_max_txq_count);
+
+   /* Subtract management EVQ not used for traffic */
+   SFC_ASSERT(evq_allocated > 0);
+   evq_allocated--;
+
+   /* Right now we use separate EVQ for Rx and Tx */
+   sa->rxq_max = MIN(rxq_allocated, evq_allocated / 2);
+   sa->txq_max = MIN(txq_allocated, evq_allocated - sa->rxq_max);
+
+   /* Keep NIC initialized */
+   return 0;
+
+fail_get_vi_pool:
+fail_nic_init:
+   efx_nic_fini(sa->nic);
+   return rc;
+}
+
+static int
+sfc_set_drv_limits(struct sfc_adapter *sa)
+{
+   const struct rte_eth_dev_data *data = sa->eth_dev->data;
+   efx_drv_limits_t lim;
+
+   memset(, 0, sizeof(lim));
+
+   /* Limits are strict since take into account initial estimation */
+   lim.edl_min_evq_count = lim.edl_max_evq_count =
+   1 + data->nb_rx_queues + data->nb_tx_queues;
+   lim.edl_min_rxq_count = lim.edl_max_rxq_count = data->nb_rx_queues;
+   lim.edl_min_txq_count = lim.edl_max_txq_count = data->nb_tx_queues;
+
+   return efx_nic_set_drv_limits(sa->nic, );
+}
+
 int
 sfc_start(struct sfc_adapter *sa)
 {
@@ -148,6 +247,11 @@ sfc_start(struct sfc_adapter *sa)

sa->state = SFC_ADAPTER_STARTING;

+   sfc_log_init(sa, "set resource limits");
+   rc = sfc_set_drv_limits(sa);
+   if (rc != 0)
+   goto fail_set_drv_limits;
+
sfc_log_init(sa, "init nic");
rc = efx_nic_init(sa->nic);
if (rc != 0)
@@ -158,6 +262,7 @@ 

[dpdk-dev] [PATCH 35/56] net/sfc: implement device start and stop operations

2016-11-21 Thread Andrew Rybchenko
Reviewed-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/efx/sfc.c| 65 
 drivers/net/sfc/efx/sfc.h| 19 
 drivers/net/sfc/efx/sfc_ethdev.c | 37 +++
 3 files changed, 121 insertions(+)

diff --git a/drivers/net/sfc/efx/sfc.c b/drivers/net/sfc/efx/sfc.c
index befe68d..8c780ac 100644
--- a/drivers/net/sfc/efx/sfc.c
+++ b/drivers/net/sfc/efx/sfc.c
@@ -127,6 +127,71 @@ sfc_check_conf(struct sfc_adapter *sa)
 }

 int
+sfc_start(struct sfc_adapter *sa)
+{
+   int rc;
+
+   sfc_log_init(sa, "entry");
+
+   SFC_ASSERT(sfc_adapter_is_locked(sa));
+
+   switch (sa->state) {
+   case SFC_ADAPTER_CONFIGURED:
+   break;
+   case SFC_ADAPTER_STARTED:
+   sfc_info(sa, "already started");
+   return 0;
+   default:
+   rc = EINVAL;
+   goto fail_bad_state;
+   }
+
+   sa->state = SFC_ADAPTER_STARTING;
+
+   sfc_log_init(sa, "init nic");
+   rc = efx_nic_init(sa->nic);
+   if (rc != 0)
+   goto fail_nic_init;
+
+   sa->state = SFC_ADAPTER_STARTED;
+   sfc_log_init(sa, "done");
+   return 0;
+
+fail_nic_init:
+   sa->state = SFC_ADAPTER_CONFIGURED;
+fail_bad_state:
+   sfc_log_init(sa, "failed %d", rc);
+   return rc;
+}
+
+void
+sfc_stop(struct sfc_adapter *sa)
+{
+   sfc_log_init(sa, "entry");
+
+   SFC_ASSERT(sfc_adapter_is_locked(sa));
+
+   switch (sa->state) {
+   case SFC_ADAPTER_STARTED:
+   break;
+   case SFC_ADAPTER_CONFIGURED:
+   sfc_info(sa, "already stopped");
+   return;
+   default:
+   sfc_err(sa, "stop in unexpected state %u", sa->state);
+   SFC_ASSERT(B_FALSE);
+   return;
+   }
+
+   sa->state = SFC_ADAPTER_STOPPING;
+
+   efx_nic_fini(sa->nic);
+
+   sa->state = SFC_ADAPTER_CONFIGURED;
+   sfc_log_init(sa, "done");
+}
+
+int
 sfc_configure(struct sfc_adapter *sa)
 {
int rc;
diff --git a/drivers/net/sfc/efx/sfc.h b/drivers/net/sfc/efx/sfc.h
index d040f98..42d6898 100644
--- a/drivers/net/sfc/efx/sfc.h
+++ b/drivers/net/sfc/efx/sfc.h
@@ -64,6 +64,20 @@ extern "C" {
  * V   |.dev_close
  * +---++
  * |  CONFIGURED   |
+ * +---+<---+
+ * |.dev_start |
+ * V   |
+ * +---+   |
+ * |   STARTING|^
+ * +---+ failed|
+ * |success|
+ * |   +---+
+ * |   |   STOPPING|
+ * |   +---+
+ * |   ^
+ * V   |.dev_stop
+ * +---++
+ * |STARTED|
  * +---+
  */
 enum sfc_adapter_state {
@@ -72,6 +86,9 @@ enum sfc_adapter_state {
SFC_ADAPTER_CONFIGURING,
SFC_ADAPTER_CONFIGURED,
SFC_ADAPTER_CLOSING,
+   SFC_ADAPTER_STARTING,
+   SFC_ADAPTER_STARTED,
+   SFC_ADAPTER_STOPPING,

SFC_ADAPTER_NSTATES
 };
@@ -158,6 +175,8 @@ void sfc_dma_free(const struct sfc_adapter *sa, efsys_mem_t 
*esmp);

 int sfc_attach(struct sfc_adapter *sa);
 void sfc_detach(struct sfc_adapter *sa);
+int sfc_start(struct sfc_adapter *sa);
+void sfc_stop(struct sfc_adapter *sa);

 int sfc_mcdi_init(struct sfc_adapter *sa);
 void sfc_mcdi_fini(struct sfc_adapter *sa);
diff --git a/drivers/net/sfc/efx/sfc_ethdev.c b/drivers/net/sfc/efx/sfc_ethdev.c
index 120ee45..ba99516 100644
--- a/drivers/net/sfc/efx/sfc_ethdev.c
+++ b/drivers/net/sfc/efx/sfc_ethdev.c
@@ -79,6 +79,37 @@ sfc_dev_configure(struct rte_eth_dev *dev)
return -rc;
 }

+static int
+sfc_dev_start(struct rte_eth_dev *dev)
+{
+   struct sfc_adapter *sa = dev->data->dev_private;
+   int rc;
+
+   sfc_log_init(sa, "entry");
+
+   sfc_adapter_lock(sa);
+   rc = sfc_start(sa);
+   sfc_adapter_unlock(sa);
+
+   sfc_log_init(sa, "done %d", rc);
+   SFC_ASSERT(rc >= 0);
+   return -rc;
+}
+
+static void
+sfc_dev_stop(struct rte_eth_dev *dev)
+{
+   struct sfc_adapter *sa = dev->data->dev_private;
+
+   sfc_log_init(sa, "entry");
+
+   sfc_adapter_lock(sa);
+   sfc_stop(sa);
+   sfc_adapter_unlock(sa);
+
+   sfc_log_init(sa, "done");
+}
+
 static void
 sfc_dev_close(struct rte_eth_dev *dev)
 {
@@ -88,6 +119,10 @@ sfc_dev_close(struct rte_eth_dev *dev)

sfc_adapter_lock(sa);
switch (sa->state) {
+   case SFC_ADAPTER_STARTED:
+   sfc_stop(sa);
+   SFC_ASSERT(sa->state == SFC_ADAPTER_CONFIGURED);
+   /* FALLTHROUGH */
case SFC_ADAPTER_CONFIGURED:
sfc_close(sa);
SFC_ASSERT(sa->state == SFC_ADAPTER_INITIALIZED);
@@ -105,6 +140,8 @@ sfc_dev_close(struct rte_eth_dev *dev)

 static const struct 

[dpdk-dev] [PATCH 34/56] net/sfc: add device configuration checks

2016-11-21 Thread Andrew Rybchenko
Manual link speed/duplex configuration is not supported yet.
Loopback is not supported yet.
Flow Director is not supported.
Link status change notification using interrupt is not supported yet.
Receive data notification using interrupts is not supported yet.

Reviewed-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 doc/guides/nics/sfc_efx.rst | 14 
 drivers/net/sfc/efx/sfc.c   | 55 +
 2 files changed, 69 insertions(+)

diff --git a/doc/guides/nics/sfc_efx.rst b/doc/guides/nics/sfc_efx.rst
index 2eebcd7..31e86a7 100644
--- a/doc/guides/nics/sfc_efx.rst
+++ b/doc/guides/nics/sfc_efx.rst
@@ -37,6 +37,20 @@ More information can be found at `Solarflare Communications 
website
 `_.


+Non-supported Features
+--
+
+The features not yet supported include:
+
+- Link status change interrupt
+
+- Receive queue interupts
+
+- Priority-based flow control
+
+- Loopback
+
+
 Supported NICs
 --

diff --git a/drivers/net/sfc/efx/sfc.c b/drivers/net/sfc/efx/sfc.c
index cbb14d7..befe68d 100644
--- a/drivers/net/sfc/efx/sfc.c
+++ b/drivers/net/sfc/efx/sfc.c
@@ -82,9 +82,55 @@ sfc_dma_free(const struct sfc_adapter *sa, efsys_mem_t *esmp)
memset(esmp, 0, sizeof(*esmp));
 }

+/*
+ * Check requested device level configuration.
+ * Receive and transmit configuration is checked in corresponding
+ * modules.
+ */
+static int
+sfc_check_conf(struct sfc_adapter *sa)
+{
+   const struct rte_eth_conf *conf = >eth_dev->data->dev_conf;
+   int rc = 0;
+
+   if (conf->link_speeds != ETH_LINK_SPEED_AUTONEG) {
+   sfc_err(sa, "Manual link speed/duplex choice not supported");
+   rc = EINVAL;
+   }
+
+   if (conf->lpbk_mode != 0) {
+   sfc_err(sa, "Loopback not supported");
+   rc = EINVAL;
+   }
+
+   if (conf->dcb_capability_en != 0) {
+   sfc_err(sa, "Priority-based flow control not supported");
+   rc = EINVAL;
+   }
+
+   if (conf->fdir_conf.mode != RTE_FDIR_MODE_NONE) {
+   sfc_err(sa, "Flow Director not supported");
+   rc = EINVAL;
+   }
+
+   if (conf->intr_conf.lsc != 0) {
+   sfc_err(sa, "Link status change interrupt not supported");
+   rc = EINVAL;
+   }
+
+   if (conf->intr_conf.rxq != 0) {
+   sfc_err(sa, "Receive queue interrupt not supported");
+   rc = EINVAL;
+   }
+
+   return rc;
+}
+
 int
 sfc_configure(struct sfc_adapter *sa)
 {
+   int rc;
+
sfc_log_init(sa, "entry");

SFC_ASSERT(sfc_adapter_is_locked(sa));
@@ -92,9 +138,18 @@ sfc_configure(struct sfc_adapter *sa)
SFC_ASSERT(sa->state == SFC_ADAPTER_INITIALIZED);
sa->state = SFC_ADAPTER_CONFIGURING;

+   rc = sfc_check_conf(sa);
+   if (rc != 0)
+   goto fail_check_conf;
+
sa->state = SFC_ADAPTER_CONFIGURED;
sfc_log_init(sa, "done");
return 0;
+
+fail_check_conf:
+   sa->state = SFC_ADAPTER_INITIALIZED;
+   sfc_log_init(sa, "failed %d", rc);
+   return rc;
 }

 void
-- 
2.5.5



[dpdk-dev] [PATCH 33/56] net/sfc: add device configure and close stubs

2016-11-21 Thread Andrew Rybchenko
Reviewed-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/efx/sfc.c| 29 +++
 drivers/net/sfc/efx/sfc.h| 31 
 drivers/net/sfc/efx/sfc_ethdev.c | 62 ++--
 3 files changed, 114 insertions(+), 8 deletions(-)

diff --git a/drivers/net/sfc/efx/sfc.c b/drivers/net/sfc/efx/sfc.c
index 2a17d26..cbb14d7 100644
--- a/drivers/net/sfc/efx/sfc.c
+++ b/drivers/net/sfc/efx/sfc.c
@@ -82,6 +82,35 @@ sfc_dma_free(const struct sfc_adapter *sa, efsys_mem_t *esmp)
memset(esmp, 0, sizeof(*esmp));
 }

+int
+sfc_configure(struct sfc_adapter *sa)
+{
+   sfc_log_init(sa, "entry");
+
+   SFC_ASSERT(sfc_adapter_is_locked(sa));
+
+   SFC_ASSERT(sa->state == SFC_ADAPTER_INITIALIZED);
+   sa->state = SFC_ADAPTER_CONFIGURING;
+
+   sa->state = SFC_ADAPTER_CONFIGURED;
+   sfc_log_init(sa, "done");
+   return 0;
+}
+
+void
+sfc_close(struct sfc_adapter *sa)
+{
+   sfc_log_init(sa, "entry");
+
+   SFC_ASSERT(sfc_adapter_is_locked(sa));
+
+   SFC_ASSERT(sa->state == SFC_ADAPTER_CONFIGURED);
+   sa->state = SFC_ADAPTER_CLOSING;
+
+   sa->state = SFC_ADAPTER_INITIALIZED;
+   sfc_log_init(sa, "done");
+}
+
 static int
 sfc_mem_bar_init(struct sfc_adapter *sa)
 {
diff --git a/drivers/net/sfc/efx/sfc.h b/drivers/net/sfc/efx/sfc.h
index 01d652d..d040f98 100644
--- a/drivers/net/sfc/efx/sfc.h
+++ b/drivers/net/sfc/efx/sfc.h
@@ -50,11 +50,28 @@ extern "C" {
  * V   |
  * +---++
  * |  INITIALIZED  |
+ * +---+<---+
+ * |.dev_configure |
+ * V   |
+ * +---+   |
+ * |  CONFIGURING  |^
+ * +---+ failed|
+ * |success|
+ * |   +---+
+ * |   |CLOSING|
+ * |   +---+
+ * |   ^
+ * V   |.dev_close
+ * +---++
+ * |  CONFIGURED   |
  * +---+
  */
 enum sfc_adapter_state {
SFC_ADAPTER_UNINITIALIZED = 0,
SFC_ADAPTER_INITIALIZED,
+   SFC_ADAPTER_CONFIGURING,
+   SFC_ADAPTER_CONFIGURED,
+   SFC_ADAPTER_CLOSING,

SFC_ADAPTER_NSTATES
 };
@@ -78,11 +95,10 @@ struct sfc_mcdi {
 /* Adapter private data */
 struct sfc_adapter {
/*
-* PMD setup and configuration is not thread safe.
-* Since it is not performance sensitive, it is better to guarantee
-* thread-safety and add device level lock.
-* Adapter control operations which change its state should
-* acquire the lock.
+* PMD setup and configuration is not thread safe. Since it is not
+* performance sensitive, it is better to guarantee thread-safety
+* and add device level lock. Adapter control operations which
+* change its state should acquire the lock.
 */
rte_spinlock_t  lock;
enum sfc_adapter_state  state;
@@ -131,7 +147,7 @@ sfc_adapter_unlock(struct sfc_adapter *sa)
 }

 static inline void
-sfc_adapter_lock_destroy(struct sfc_adapter *sa)
+sfc_adapter_lock_fini(struct sfc_adapter *sa)
 {
/* Just for symmetry of the API */
 }
@@ -146,6 +162,9 @@ void sfc_detach(struct sfc_adapter *sa);
 int sfc_mcdi_init(struct sfc_adapter *sa);
 void sfc_mcdi_fini(struct sfc_adapter *sa);

+int sfc_configure(struct sfc_adapter *sa);
+void sfc_close(struct sfc_adapter *sa);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/drivers/net/sfc/efx/sfc_ethdev.c b/drivers/net/sfc/efx/sfc_ethdev.c
index e5b609c..120ee45 100644
--- a/drivers/net/sfc/efx/sfc_ethdev.c
+++ b/drivers/net/sfc/efx/sfc_ethdev.c
@@ -47,7 +47,65 @@ sfc_dev_infos_get(struct rte_eth_dev *dev, struct 
rte_eth_dev_info *dev_info)
sfc_log_init(sa, "entry");
 }

+static int
+sfc_dev_configure(struct rte_eth_dev *dev)
+{
+   struct rte_eth_dev_data *dev_data = dev->data;
+   struct sfc_adapter *sa = dev_data->dev_private;
+   int rc;
+
+   sfc_log_init(sa, "entry n_rxq=%u n_txq=%u",
+dev_data->nb_rx_queues, dev_data->nb_tx_queues);
+
+   sfc_adapter_lock(sa);
+   switch (sa->state) {
+   case SFC_ADAPTER_CONFIGURED:
+   sfc_close(sa);
+   SFC_ASSERT(sa->state == SFC_ADAPTER_INITIALIZED);
+   /* FALLTHROUGH */
+   case SFC_ADAPTER_INITIALIZED:
+   rc = sfc_configure(sa);
+   break;
+   default:
+   sfc_err(sa, "unexpected adapter state %u to configure",
+   sa->state);
+   rc = EINVAL;
+   break;
+   }
+   sfc_adapter_unlock(sa);
+
+   sfc_log_init(sa, "done %d", rc);
+   SFC_ASSERT(rc >= 0);
+   return -rc;
+}
+
+static void
+sfc_dev_close(struct rte_eth_dev *dev)
+{
+   struct sfc_adapter *sa = 

[dpdk-dev] [PATCH 31/56] net/sfc: implement dummy callback to get device information

2016-11-21 Thread Andrew Rybchenko
Just a stub to be filled in when corresponding functionality is
implemented.

Reviewed-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/efx/sfc_ethdev.c | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/net/sfc/efx/sfc_ethdev.c b/drivers/net/sfc/efx/sfc_ethdev.c
index ff20a13..0deff07 100644
--- a/drivers/net/sfc/efx/sfc_ethdev.c
+++ b/drivers/net/sfc/efx/sfc_ethdev.c
@@ -37,9 +37,16 @@
 #include "sfc_kvargs.h"


+static void
+sfc_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
+{
+   struct sfc_adapter *sa = dev->data->dev_private;
+
+   sfc_log_init(sa, "entry");
+}
+
 static const struct eth_dev_ops sfc_eth_dev_ops = {
-   /* Just dummy init to avoid build-time warning */
-   .dev_configure  = NULL,
+   .dev_infos_get  = sfc_dev_infos_get,
 };

 static int
-- 
2.5.5



[dpdk-dev] [PATCH 30/56] net/sfc: include libefx in build

2016-11-21 Thread Andrew Rybchenko
From: Artem Andreev 

Implement efsys.h for the PMD.

Reviewed-by: Andy Moreton 
Signed-off-by: Artem Andreev 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/efx/Makefile |  54 +++
 drivers/net/sfc/efx/efsys.h  | 767 +++
 2 files changed, 821 insertions(+)
 create mode 100644 drivers/net/sfc/efx/efsys.h

diff --git a/drivers/net/sfc/efx/Makefile b/drivers/net/sfc/efx/Makefile
index 71f07ca..de95ea8 100644
--- a/drivers/net/sfc/efx/Makefile
+++ b/drivers/net/sfc/efx/Makefile
@@ -33,6 +33,8 @@ include $(RTE_SDK)/mk/rte.vars.mk
 #
 LIB = librte_pmd_sfc_efx.a

+CFLAGS += -I$(SRCDIR)/base/
+CFLAGS += -I$(SRCDIR)
 CFLAGS += -O3

 # Enable basic warnings but disable some which are accepted
@@ -60,6 +62,17 @@ CFLAGS += -Wstrict-prototypes
 CFLAGS += -Wundef
 CFLAGS += -Wwrite-strings

+# Extra CFLAGS for base driver files
+CFLAGS_BASE_DRIVER += -Wno-unused-variable
+CFLAGS_BASE_DRIVER += -Wno-unused-but-set-variable
+
+#
+# List of base driver object files for which
+# special CFLAGS above should be applied
+#
+BASE_DRIVER_OBJS=$(patsubst %.c,%.o,$(notdir $(wildcard $(SRCDIR)/base/*.c)))
+$(foreach obj, $(BASE_DRIVER_OBJS), $(eval CFLAGS+=$(CFLAGS_BASE_DRIVER)))
+
 EXPORT_MAP := rte_pmd_sfc_efx_version.map

 LIBABIVER := 1
@@ -70,6 +83,47 @@ LIBABIVER := 1
 SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += sfc_ethdev.c
 SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += sfc_kvargs.c

+VPATH += $(SRCDIR)/base
+
+SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_bootcfg.c
+SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_crc32.c
+SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_ev.c
+SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_filter.c
+SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_hash.c
+SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_intr.c
+SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_lic.c
+SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_mac.c
+SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_mcdi.c
+SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_mon.c
+SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_nic.c
+SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_nvram.c
+SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_phy.c
+SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_port.c
+SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_rx.c
+SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_sram.c
+SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_tx.c
+SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_vpd.c
+SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += mcdi_mon.c
+SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += siena_mac.c
+SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += siena_mcdi.c
+SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += siena_nic.c
+SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += siena_nvram.c
+SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += siena_phy.c
+SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += siena_sram.c
+SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += siena_vpd.c
+SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += ef10_ev.c
+SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += ef10_filter.c
+SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += ef10_intr.c
+SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += ef10_mac.c
+SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += ef10_mcdi.c
+SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += ef10_nic.c
+SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += ef10_nvram.c
+SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += ef10_phy.c
+SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += ef10_rx.c
+SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += ef10_tx.c
+SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += ef10_vpd.c
+SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += hunt_nic.c
+SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += medford_nic.c

 # this lib depends upon:
 DEPDIRS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += lib/librte_eal
diff --git a/drivers/net/sfc/efx/efsys.h b/drivers/net/sfc/efx/efsys.h
new file mode 100644
index 000..2eef996
--- /dev/null
+++ b/drivers/net/sfc/efx/efsys.h
@@ -0,0 +1,767 @@
+/*-
+ * Copyright (c) 2016 Solarflare Communications Inc.
+ * All rights reserved.
+ *
+ * This software was jointly developed between OKTET Labs (under contract
+ * for Solarflare) and Solarflare Communications, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *this list of conditions and the following disclaimer in the documentation
+ *and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 

[dpdk-dev] [PATCH 29/56] net/sfc: import libefx licensing support

2016-11-21 Thread Andrew Rybchenko
Provide API to deal with licences on SFN7xxx and SFN8xxx
family adapaters.

EFSYS_OPT_LICENSING should be enabled to use it.

>From Solarflare Communications Inc.

Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/efx/base/efx.h   |  145 +++
 drivers/net/sfc/efx/base/efx_check.h |   10 +
 drivers/net/sfc/efx/base/efx_impl.h  |   37 +
 drivers/net/sfc/efx/base/efx_lic.c   | 1751 ++
 4 files changed, 1943 insertions(+)
 create mode 100644 drivers/net/sfc/efx/base/efx_lic.c

diff --git a/drivers/net/sfc/efx/base/efx.h b/drivers/net/sfc/efx/base/efx.h
index 8f22eab..f324ee2 100644
--- a/drivers/net/sfc/efx/base/efx.h
+++ b/drivers/net/sfc/efx/base/efx.h
@@ -2349,6 +2349,151 @@ efx_hash_bytes(
__insize_t length,
__inuint32_t init);

+#if EFSYS_OPT_LICENSING
+
+/* LICENSING */
+
+typedef struct efx_key_stats_s {
+   uint32_teks_valid;
+   uint32_teks_invalid;
+   uint32_teks_blacklisted;
+   uint32_teks_unverifiable;
+   uint32_teks_wrong_node;
+   uint32_teks_licensed_apps_lo;
+   uint32_teks_licensed_apps_hi;
+   uint32_teks_licensed_features_lo;
+   uint32_teks_licensed_features_hi;
+} efx_key_stats_t;
+
+extern __checkReturn   efx_rc_t
+efx_lic_init(
+   __inefx_nic_t *enp);
+
+extern void
+efx_lic_fini(
+   __inefx_nic_t *enp);
+
+extern __checkReturn   boolean_t
+efx_lic_check_support(
+   __inefx_nic_t *enp);
+
+extern __checkReturn   efx_rc_t
+efx_lic_update_licenses(
+   __inefx_nic_t *enp);
+
+extern __checkReturn   efx_rc_t
+efx_lic_get_key_stats(
+   __inefx_nic_t *enp,
+   __out   efx_key_stats_t *ksp);
+
+extern __checkReturn   efx_rc_t
+efx_lic_app_state(
+   __inefx_nic_t *enp,
+   __inuint64_t app_id,
+   __out   boolean_t *licensedp);
+
+extern __checkReturn   efx_rc_t
+efx_lic_get_id(
+   __inefx_nic_t *enp,
+   __insize_t buffer_size,
+   __out   uint32_t *typep,
+   __out   size_t *lengthp,
+   __out_opt   uint8_t *bufferp);
+
+
+extern __checkReturn   efx_rc_t
+efx_lic_find_start(
+   __inefx_nic_t *enp,
+   __in_bcount(buffer_size)
+   caddr_t bufferp,
+   __insize_t buffer_size,
+   __out   uint32_t *startp
+   );
+
+extern __checkReturn   efx_rc_t
+efx_lic_find_end(
+   __inefx_nic_t *enp,
+   __in_bcount(buffer_size)
+   caddr_t bufferp,
+   __insize_t buffer_size,
+   __inuint32_t offset,
+   __out   uint32_t *endp
+   );
+
+extern __checkReturn   __success(return != B_FALSE)boolean_t
+efx_lic_find_key(
+   __inefx_nic_t *enp,
+   __in_bcount(buffer_size)
+   caddr_t bufferp,
+   __insize_t buffer_size,
+   __inuint32_t offset,
+   __out   uint32_t *startp,
+   __out   uint32_t *lengthp
+   );
+
+extern __checkReturn   __success(return != B_FALSE)boolean_t
+efx_lic_validate_key(
+   __inefx_nic_t *enp,
+   __in_bcount(length) caddr_t keyp,
+   __inuint32_t length
+   );
+
+extern __checkReturn   efx_rc_t
+efx_lic_read_key(
+   __inefx_nic_t *enp,
+   __in_bcount(buffer_size)
+   caddr_t bufferp,
+   __insize_t buffer_size,
+   __inuint32_t offset,
+   __inuint32_t length,
+   __out_bcount_part(key_max_size, *lengthp)
+   caddr_t keyp,
+   __insize_t key_max_size,
+   __out   uint32_t *lengthp
+   );
+
+extern __checkReturn   efx_rc_t
+efx_lic_write_key(
+   __inefx_nic_t *enp,
+   __in_bcount(buffer_size)
+   caddr_t bufferp,
+   __insize_t buffer_size,
+   __inuint32_t offset,
+   __in_bcount(length) caddr_t keyp,
+   __inuint32_t length,
+   __out   uint32_t *lengthp
+   );
+
+   __checkReturn   efx_rc_t
+efx_lic_delete_key(
+   __inefx_nic_t *enp,
+   __in_bcount(buffer_size)
+   caddr_t bufferp,
+   __insize_t buffer_size,
+   __inuint32_t offset,
+   __in

[dpdk-dev] [PATCH 28/56] net/sfc: import libefx bootrom configuration support

2016-11-21 Thread Andrew Rybchenko
Provide API to read/write bootrom configuration from/to NVRAM.

EFSYS_OPT_BOOTROM should be enabled to use it.

>From Solarflare Communications Inc.

Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/efx/base/efx.h |  39 +++
 drivers/net/sfc/efx/base/efx_bootcfg.c | 563 +
 drivers/net/sfc/efx/base/efx_check.h   |   7 +
 3 files changed, 609 insertions(+)
 create mode 100644 drivers/net/sfc/efx/base/efx_bootcfg.c

diff --git a/drivers/net/sfc/efx/base/efx.h b/drivers/net/sfc/efx/base/efx.h
index 1811879..8f22eab 100644
--- a/drivers/net/sfc/efx/base/efx.h
+++ b/drivers/net/sfc/efx/base/efx.h
@@ -1421,6 +1421,45 @@ efx_nvram_fini(

 #endif /* EFSYS_OPT_NVRAM */

+#if EFSYS_OPT_BOOTCFG
+
+/* Report size and offset of bootcfg sector in NVRAM partition. */
+extern __checkReturn   efx_rc_t
+efx_bootcfg_sector_info(
+   __inefx_nic_t *enp,
+   __inuint32_t pf,
+   __out_opt   uint32_t *sector_countp,
+   __out   size_t *offsetp,
+   __out   size_t *max_sizep);
+
+/*
+ * Copy bootcfg sector data to a target buffer which may differ in size.
+ * Optionally corrects format errors in source buffer.
+ */
+extern efx_rc_t
+efx_bootcfg_copy_sector(
+   __inefx_nic_t *enp,
+   __inout_bcount(sector_length)
+   uint8_t *sector,
+   __insize_t sector_length,
+   __out_bcount(data_size) uint8_t *data,
+   __insize_t data_size,
+   __inboolean_t handle_format_errors);
+
+extern efx_rc_t
+efx_bootcfg_read(
+   __inefx_nic_t *enp,
+   __out_bcount(size)  caddr_t data,
+   __insize_t size);
+
+extern efx_rc_t
+efx_bootcfg_write(
+   __inefx_nic_t *enp,
+   __in_bcount(size)   caddr_t data,
+   __insize_t size);
+
+#endif /* EFSYS_OPT_BOOTCFG */
+
 #if EFSYS_OPT_DIAG

 typedef enum efx_pattern_type_t {
diff --git a/drivers/net/sfc/efx/base/efx_bootcfg.c 
b/drivers/net/sfc/efx/base/efx_bootcfg.c
new file mode 100644
index 000..d589c86
--- /dev/null
+++ b/drivers/net/sfc/efx/base/efx_bootcfg.c
@@ -0,0 +1,563 @@
+/*
+ * Copyright (c) 2009-2016 Solarflare Communications Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *this list of conditions and the following disclaimer in the documentation
+ *and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are
+ * those of the authors and should not be interpreted as representing official
+ * policies, either expressed or implied, of the FreeBSD Project.
+ */
+
+#include "efx.h"
+#include "efx_impl.h"
+
+#if EFSYS_OPT_BOOTCFG
+
+/*
+ * Maximum size of BOOTCFG block across all nics as understood by SFCgPXE.
+ * NOTE: This is larger than the Medford per-PF bootcfg sector.
+ */
+#defineBOOTCFG_MAX_SIZE 0x1000
+
+/* Medford per-PF bootcfg sector */
+#defineBOOTCFG_PER_PF   0x800
+#defineBOOTCFG_PF_COUNT 16
+
+#defineDHCP_END ((uint8_t)0xff)
+#defineDHCP_PAD ((uint8_t)0)
+
+
+/* Report the layout of bootcfg sectors in NVRAM partition. */
+   __checkReturn   efx_rc_t
+efx_bootcfg_sector_info(
+   __inefx_nic_t *enp,
+   __inuint32_t pf,
+   __out_opt   uint32_t *sector_countp,
+   __out   size_t *offsetp,
+   __out   size_t *max_sizep)
+{
+   uint32_t count;
+   size_t max_size;
+   size_t offset;
+   int rc;
+
+   switch 

[dpdk-dev] [PATCH 27/56] net/sfc: import libefx VPD support

2016-11-21 Thread Andrew Rybchenko
Provide API to read/write PCI Vital Product Data.

EFSYS_OPT_VPD should be enabled to use it.

>From Solarflare Communications Inc.

Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/efx/base/ef10_impl.h  |   63 ++
 drivers/net/sfc/efx/base/ef10_vpd.c   |  463 +++
 drivers/net/sfc/efx/base/efx.h|   82 +++
 drivers/net/sfc/efx/base/efx_check.h  |7 +
 drivers/net/sfc/efx/base/efx_impl.h   |   78 +++
 drivers/net/sfc/efx/base/efx_vpd.c| 1016 +
 drivers/net/sfc/efx/base/siena_impl.h |   63 ++
 drivers/net/sfc/efx/base/siena_vpd.c  |  618 
 8 files changed, 2390 insertions(+)
 create mode 100644 drivers/net/sfc/efx/base/ef10_vpd.c
 create mode 100644 drivers/net/sfc/efx/base/efx_vpd.c
 create mode 100644 drivers/net/sfc/efx/base/siena_vpd.c

diff --git a/drivers/net/sfc/efx/base/ef10_impl.h 
b/drivers/net/sfc/efx/base/ef10_impl.h
index d533b15..f13534c 100644
--- a/drivers/net/sfc/efx/base/ef10_impl.h
+++ b/drivers/net/sfc/efx/base/ef10_impl.h
@@ -817,6 +817,69 @@ ef10_nic_pio_unlink(

 /* VPD */

+#if EFSYS_OPT_VPD
+
+extern __checkReturn   efx_rc_t
+ef10_vpd_init(
+   __inefx_nic_t *enp);
+
+extern __checkReturn   efx_rc_t
+ef10_vpd_size(
+   __inefx_nic_t *enp,
+   __out   size_t *sizep);
+
+extern __checkReturn   efx_rc_t
+ef10_vpd_read(
+   __inefx_nic_t *enp,
+   __out_bcount(size)  caddr_t data,
+   __insize_t size);
+
+extern __checkReturn   efx_rc_t
+ef10_vpd_verify(
+   __inefx_nic_t *enp,
+   __in_bcount(size)   caddr_t data,
+   __insize_t size);
+
+extern __checkReturn   efx_rc_t
+ef10_vpd_reinit(
+   __inefx_nic_t *enp,
+   __in_bcount(size)   caddr_t data,
+   __insize_t size);
+
+extern __checkReturn   efx_rc_t
+ef10_vpd_get(
+   __inefx_nic_t *enp,
+   __in_bcount(size)   caddr_t data,
+   __insize_t size,
+   __inout efx_vpd_value_t *evvp);
+
+extern __checkReturn   efx_rc_t
+ef10_vpd_set(
+   __inefx_nic_t *enp,
+   __in_bcount(size)   caddr_t data,
+   __insize_t size,
+   __inefx_vpd_value_t *evvp);
+
+extern __checkReturn   efx_rc_t
+ef10_vpd_next(
+   __inefx_nic_t *enp,
+   __in_bcount(size)   caddr_t data,
+   __insize_t size,
+   __out   efx_vpd_value_t *evvp,
+   __inout unsigned int *contp);
+
+extern __checkReturn   efx_rc_t
+ef10_vpd_write(
+   __inefx_nic_t *enp,
+   __in_bcount(size)   caddr_t data,
+   __insize_t size);
+
+extern void
+ef10_vpd_fini(
+   __inefx_nic_t *enp);
+
+#endif /* EFSYS_OPT_VPD */
+

 /* RX */

diff --git a/drivers/net/sfc/efx/base/ef10_vpd.c 
b/drivers/net/sfc/efx/base/ef10_vpd.c
new file mode 100644
index 000..71123a9
--- /dev/null
+++ b/drivers/net/sfc/efx/base/ef10_vpd.c
@@ -0,0 +1,463 @@
+/*
+ * Copyright (c) 2009-2016 Solarflare Communications Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *this list of conditions and the following disclaimer in the documentation
+ *and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are
+ * those of the authors and should not be interpreted as representing official
+ * policies, either expressed or implied, of the FreeBSD Project.
+ */
+

[dpdk-dev] [PATCH 26/56] net/sfc: import libefx NVRAM support

2016-11-21 Thread Andrew Rybchenko
Provide API to work with NIC non-volatile memory. It is used
to update firmware, configure NIC including bootrom parameters,
manage licenses, store PCI Vital Product Data etc.

EFSYS_OPT_NVRAM should be enabled to use it.

>From Solarflare Communications Inc.

Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/efx/base/ef10_impl.h   |  222 +++
 drivers/net/sfc/efx/base/ef10_nvram.c  | 2385 
 drivers/net/sfc/efx/base/efx.h |   96 ++
 drivers/net/sfc/efx/base/efx_check.h   |7 +
 drivers/net/sfc/efx/base/efx_impl.h|  106 ++
 drivers/net/sfc/efx/base/efx_nvram.c   | 1044 ++
 drivers/net/sfc/efx/base/siena_impl.h  |   99 ++
 drivers/net/sfc/efx/base/siena_nic.c   |   55 +
 drivers/net/sfc/efx/base/siena_nvram.c |  734 ++
 9 files changed, 4748 insertions(+)
 create mode 100644 drivers/net/sfc/efx/base/ef10_nvram.c
 create mode 100644 drivers/net/sfc/efx/base/efx_nvram.c
 create mode 100644 drivers/net/sfc/efx/base/siena_nvram.c

diff --git a/drivers/net/sfc/efx/base/ef10_impl.h 
b/drivers/net/sfc/efx/base/ef10_impl.h
index 8c527b1..d533b15 100644
--- a/drivers/net/sfc/efx/base/ef10_impl.h
+++ b/drivers/net/sfc/efx/base/ef10_impl.h
@@ -339,6 +339,228 @@ ef10_mcdi_get_timeout(

 /* NVRAM */

+#if EFSYS_OPT_NVRAM || EFSYS_OPT_VPD
+
+extern __checkReturn   efx_rc_t
+ef10_nvram_buf_read_tlv(
+   __inefx_nic_t *enp,
+   __in_bcount(max_seg_size)   caddr_t seg_data,
+   __insize_t max_seg_size,
+   __inuint32_t tag,
+   __deref_out_bcount_opt(*sizep)  caddr_t *datap,
+   __out   size_t *sizep);
+
+extern __checkReturn   efx_rc_t
+ef10_nvram_buf_write_tlv(
+   __inout_bcount(partn_size)  caddr_t partn_data,
+   __insize_t partn_size,
+   __inuint32_t tag,
+   __in_bcount(tag_size)   caddr_t tag_data,
+   __insize_t tag_size,
+   __out   size_t *total_lengthp);
+
+extern __checkReturn   efx_rc_t
+ef10_nvram_partn_read_tlv(
+   __inefx_nic_t *enp,
+   __inuint32_t partn,
+   __inuint32_t tag,
+   __deref_out_bcount_opt(*sizep)  caddr_t *datap,
+   __out   size_t *sizep);
+
+extern __checkReturn   efx_rc_t
+ef10_nvram_partn_write_tlv(
+   __inefx_nic_t *enp,
+   __inuint32_t partn,
+   __inuint32_t tag,
+   __in_bcount(size)   caddr_t data,
+   __insize_t size);
+
+extern __checkReturn   efx_rc_t
+ef10_nvram_partn_write_segment_tlv(
+   __inefx_nic_t *enp,
+   __inuint32_t partn,
+   __inuint32_t tag,
+   __in_bcount(size)   caddr_t data,
+   __insize_t size,
+   __inboolean_t all_segments);
+
+extern __checkReturn   efx_rc_t
+ef10_nvram_partn_lock(
+   __inefx_nic_t *enp,
+   __inuint32_t partn);
+
+extern __checkReturn   efx_rc_t
+ef10_nvram_partn_unlock(
+   __inefx_nic_t *enp,
+   __inuint32_t partn,
+   __out_opt   uint32_t *resultp);
+
+#endif /* EFSYS_OPT_NVRAM || EFSYS_OPT_VPD */
+
+#if EFSYS_OPT_NVRAM
+
+#if EFSYS_OPT_DIAG
+
+extern __checkReturn   efx_rc_t
+ef10_nvram_test(
+   __inefx_nic_t *enp);
+
+#endif /* EFSYS_OPT_DIAG */
+
+extern __checkReturn   efx_rc_t
+ef10_nvram_type_to_partn(
+   __inefx_nic_t *enp,
+   __inefx_nvram_type_t type,
+   __out   uint32_t *partnp);
+
+extern __checkReturn   efx_rc_t
+ef10_nvram_partn_size(
+   __inefx_nic_t *enp,
+   __inuint32_t partn,
+   __out   size_t *sizep);
+
+extern __checkReturn   efx_rc_t
+ef10_nvram_partn_rw_start(
+   __inefx_nic_t *enp,
+   __inuint32_t partn,
+   __out   size_t *chunk_sizep);
+
+extern __checkReturn   efx_rc_t
+ef10_nvram_partn_read_mode(
+   __inefx_nic_t *enp,
+   __inuint32_t partn,
+   __inunsigned int offset,
+   __out_bcount(size)  caddr_t data,
+   __insize_t size,
+   __inuint32_t mode);
+
+extern __checkReturn   efx_rc_t
+ef10_nvram_partn_read(
+   __inefx_nic_t *enp,
+   __inuint32_t partn,
+   __in

[dpdk-dev] [PATCH 25/56] net/sfc: import libefx support for Rx packed stream mode

2016-11-21 Thread Andrew Rybchenko
In packed stream mode, large buffers are provided to the NIC
into which many packets can be delivered. This reduces the
number of queue refills needed compared to delivering every
packet into a separate buffer.

EFSYS_OPT_RX_PACKED_STREAM should be enabled to use it.

>From Solarflare Communications Inc.

Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/efx/base/ef10_ev.c   | 124 +++
 drivers/net/sfc/efx/base/ef10_impl.h |  46 +
 drivers/net/sfc/efx/base/ef10_rx.c   | 114 
 drivers/net/sfc/efx/base/efx.h   |  48 ++
 drivers/net/sfc/efx/base/efx_check.h |   7 ++
 drivers/net/sfc/efx/base/efx_impl.h  |  11 
 drivers/net/sfc/efx/base/efx_rx.c|  84 
 7 files changed, 434 insertions(+)

diff --git a/drivers/net/sfc/efx/base/ef10_ev.c 
b/drivers/net/sfc/efx/base/ef10_ev.c
index e93b458..3522674 100644
--- a/drivers/net/sfc/efx/base/ef10_ev.c
+++ b/drivers/net/sfc/efx/base/ef10_ev.c
@@ -759,6 +759,84 @@ ef10_ev_qstats_update(
 }
 #endif /* EFSYS_OPT_QSTATS */

+#if EFSYS_OPT_RX_PACKED_STREAM
+
+static __checkReturn   boolean_t
+ef10_ev_rx_packed_stream(
+   __inefx_evq_t *eep,
+   __inefx_qword_t *eqp,
+   __inconst efx_ev_callbacks_t *eecp,
+   __in_optvoid *arg)
+{
+   uint32_t label;
+   uint32_t next_read_lbits;
+   uint16_t flags;
+   boolean_t should_abort;
+   efx_evq_rxq_state_t *eersp;
+   unsigned int pkt_count;
+   unsigned int current_id;
+   boolean_t new_buffer;
+
+   next_read_lbits = EFX_QWORD_FIELD(*eqp, ESF_DZ_RX_DSC_PTR_LBITS);
+   label = EFX_QWORD_FIELD(*eqp, ESF_DZ_RX_QLABEL);
+   new_buffer = EFX_QWORD_FIELD(*eqp, ESF_DZ_RX_EV_ROTATE);
+
+   flags = 0;
+
+   eersp = >ee_rxq_state[label];
+   pkt_count = (EFX_MASK32(ESF_DZ_RX_DSC_PTR_LBITS) + 1 +
+   next_read_lbits - eersp->eers_rx_stream_npackets) &
+   EFX_MASK32(ESF_DZ_RX_DSC_PTR_LBITS);
+   eersp->eers_rx_stream_npackets += pkt_count;
+
+   if (new_buffer) {
+   flags |= EFX_PKT_PACKED_STREAM_NEW_BUFFER;
+   if (eersp->eers_rx_packed_stream_credits <
+   EFX_RX_PACKED_STREAM_MAX_CREDITS)
+   eersp->eers_rx_packed_stream_credits++;
+   eersp->eers_rx_read_ptr++;
+   }
+   current_id = eersp->eers_rx_read_ptr & eersp->eers_rx_mask;
+
+   /* Check for errors that invalidate checksum and L3/L4 fields */
+   if (EFX_QWORD_FIELD(*eqp, ESF_DZ_RX_ECC_ERR) != 0) {
+   /* RX frame truncated (error flag is misnamed) */
+   EFX_EV_QSTAT_INCR(eep, EV_RX_FRM_TRUNC);
+   flags |= EFX_DISCARD;
+   goto deliver;
+   }
+   if (EFX_QWORD_FIELD(*eqp, ESF_DZ_RX_ECRC_ERR) != 0) {
+   /* Bad Ethernet frame CRC */
+   EFX_EV_QSTAT_INCR(eep, EV_RX_ETH_CRC_ERR);
+   flags |= EFX_DISCARD;
+   goto deliver;
+   }
+
+   if (EFX_QWORD_FIELD(*eqp, ESF_DZ_RX_PARSE_INCOMPLETE)) {
+   flags |= EFX_PKT_PACKED_STREAM_PARSE_INCOMPLETE;
+   goto deliver;
+   }
+
+   if (EFX_QWORD_FIELD(*eqp, ESF_DZ_RX_IPCKSUM_ERR))
+   EFX_EV_QSTAT_INCR(eep, EV_RX_IPV4_HDR_CHKSUM_ERR);
+
+   if (EFX_QWORD_FIELD(*eqp, ESF_DZ_RX_TCPUDP_CKSUM_ERR))
+   EFX_EV_QSTAT_INCR(eep, EV_RX_TCP_UDP_CHKSUM_ERR);
+
+deliver:
+   /* If we're not discarding the packet then it is ok */
+   if (~flags & EFX_DISCARD)
+   EFX_EV_QSTAT_INCR(eep, EV_RX_OK);
+
+   EFSYS_ASSERT(eecp->eec_rx_ps != NULL);
+   should_abort = eecp->eec_rx_ps(arg, label, current_id, pkt_count,
+   flags);
+
+   return (should_abort);
+}
+
+#endif /* EFSYS_OPT_RX_PACKED_STREAM */
+
 static __checkReturn   boolean_t
 ef10_ev_rx(
__inefx_evq_t *eep,
@@ -791,6 +869,15 @@ ef10_ev_rx(
label = EFX_QWORD_FIELD(*eqp, ESF_DZ_RX_QLABEL);
eersp = >ee_rxq_state[label];

+#if EFSYS_OPT_RX_PACKED_STREAM
+   /*
+* Packed stream events are very different,
+* so handle them separately
+*/
+   if (eersp->eers_rx_packed_stream)
+   return (ef10_ev_rx_packed_stream(eep, eqp, eecp, arg));
+#endif
+
size = EFX_QWORD_FIELD(*eqp, ESF_DZ_RX_BYTES);
next_read_lbits = EFX_QWORD_FIELD(*eqp, ESF_DZ_RX_DSC_PTR_LBITS);
eth_tag_class = EFX_QWORD_FIELD(*eqp, ESF_DZ_RX_ETH_TAG_CLASS);
@@ -1253,9 +1340,41 @@ ef10_ev_rxlabel_init(

EFSYS_ASSERT3U(eersp->eers_rx_mask, ==, 0);

+#if EFSYS_OPT_RX_PACKED_STREAM
+   /*
+* For packed stream modes, the very first event will
+* have a new buffer flag set, so it will be incremented,
+* yielding the correct pointer. That results in a simpler
+* code than trying to detect start-of-the-world condition
+* in the event 

[dpdk-dev] [PATCH 24/56] net/sfc: import libefx support to access monitors via MCDI

2016-11-21 Thread Andrew Rybchenko
EFSYS_OPT_MON_MCDI should be enabled to use it.

>From Solarflare Communications Inc.

Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/efx/base/ef10_nic.c  |   3 +
 drivers/net/sfc/efx/base/efx_check.h |   7 +
 drivers/net/sfc/efx/base/efx_ev.c|   3 +
 drivers/net/sfc/efx/base/efx_mon.c   |  21 +-
 drivers/net/sfc/efx/base/hunt_nic.c  |   3 +
 drivers/net/sfc/efx/base/mcdi_mon.c  | 565 +++
 drivers/net/sfc/efx/base/mcdi_mon.h  |  74 +
 7 files changed, 675 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/sfc/efx/base/mcdi_mon.c
 create mode 100644 drivers/net/sfc/efx/base/mcdi_mon.h

diff --git a/drivers/net/sfc/efx/base/ef10_nic.c 
b/drivers/net/sfc/efx/base/ef10_nic.c
index 32706f4..7af8935 100644
--- a/drivers/net/sfc/efx/base/ef10_nic.c
+++ b/drivers/net/sfc/efx/base/ef10_nic.c
@@ -30,6 +30,9 @@

 #include "efx.h"
 #include "efx_impl.h"
+#if EFSYS_OPT_MON_MCDI
+#include "mcdi_mon.h"
+#endif

 #if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD

diff --git a/drivers/net/sfc/efx/base/efx_check.h 
b/drivers/net/sfc/efx/base/efx_check.h
index 3e4e9ba..35615e6 100644
--- a/drivers/net/sfc/efx/base/efx_check.h
+++ b/drivers/net/sfc/efx/base/efx_check.h
@@ -166,6 +166,13 @@
 # endif
 #endif /* EFSYS_OPT_MON_STATS */

+#if EFSYS_OPT_MON_MCDI
+/* Support Monitor via mcdi */
+# if !(EFSYS_OPT_SIENA || EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD)
+#  error "MON_MCDI requires SIENA or HUNTINGTON or MEDFORD"
+# endif
+#endif /* EFSYS_OPT_MON_MCDI*/
+
 #if EFSYS_OPT_NAMES
 /* Support printable names for statistics */
 # if !(EFSYS_OPT_LOOPBACK || EFSYS_OPT_MAC_STATS || EFSYS_OPT_MCDI || \
diff --git a/drivers/net/sfc/efx/base/efx_ev.c 
b/drivers/net/sfc/efx/base/efx_ev.c
index ac3ebe3..42ded5a 100644
--- a/drivers/net/sfc/efx/base/efx_ev.c
+++ b/drivers/net/sfc/efx/base/efx_ev.c
@@ -30,6 +30,9 @@

 #include "efx.h"
 #include "efx_impl.h"
+#if EFSYS_OPT_MON_MCDI
+#include "mcdi_mon.h"
+#endif

 #if EFSYS_OPT_QSTATS
 #defineEFX_EV_QSTAT_INCR(_eep, _stat)  
\
diff --git a/drivers/net/sfc/efx/base/efx_mon.c 
b/drivers/net/sfc/efx/base/efx_mon.c
index 68314cf..c2f1e97 100644
--- a/drivers/net/sfc/efx/base/efx_mon.c
+++ b/drivers/net/sfc/efx/base/efx_mon.c
@@ -31,6 +31,10 @@
 #include "efx.h"
 #include "efx_impl.h"

+#if EFSYS_OPT_MON_MCDI
+#include "mcdi_mon.h"
+#endif
+
 #if EFSYS_OPT_NAMES

 static const char * const __efx_mon_name[] = {
@@ -55,6 +59,14 @@ efx_mon_name(

 #endif /* EFSYS_OPT_NAMES */

+#if EFSYS_OPT_MON_MCDI
+static const efx_mon_ops_t __efx_mon_mcdi_ops = {
+#if EFSYS_OPT_MON_STATS
+   mcdi_mon_stats_update   /* emo_stats_update */
+#endif /* EFSYS_OPT_MON_STATS */
+};
+#endif
+

__checkReturn   efx_rc_t
 efx_mon_init(
@@ -79,6 +91,13 @@ efx_mon_init(

EFSYS_ASSERT(encp->enc_mon_type != EFX_MON_INVALID);
switch (emp->em_type) {
+#if EFSYS_OPT_MON_MCDI
+   case EFX_MON_SFC90X0:
+   case EFX_MON_SFC91X0:
+   case EFX_MON_SFC92X0:
+   emop = &__efx_mon_mcdi_ops;
+   break;
+#endif
default:
rc = ENOTSUP;
goto fail2;
@@ -104,7 +123,7 @@ efx_mon_init(

 #if EFSYS_OPT_NAMES

-/* START MKCONFIG GENERATED MonitorStatNamesBlock 31f437eafb0b0437 */
+/* START MKCONFIG GENERATED MonitorStatNamesBlock 5daa2a5725ba734b */
 static const char * const __mon_stat_name[] = {
"value_2_5v",
"value_vccp1",
diff --git a/drivers/net/sfc/efx/base/hunt_nic.c 
b/drivers/net/sfc/efx/base/hunt_nic.c
index 263f474..c2c4d74 100644
--- a/drivers/net/sfc/efx/base/hunt_nic.c
+++ b/drivers/net/sfc/efx/base/hunt_nic.c
@@ -30,6 +30,9 @@

 #include "efx.h"
 #include "efx_impl.h"
+#if EFSYS_OPT_MON_MCDI
+#include "mcdi_mon.h"
+#endif

 #if EFSYS_OPT_HUNTINGTON

diff --git a/drivers/net/sfc/efx/base/mcdi_mon.c 
b/drivers/net/sfc/efx/base/mcdi_mon.c
new file mode 100644
index 000..c5360c3
--- /dev/null
+++ b/drivers/net/sfc/efx/base/mcdi_mon.c
@@ -0,0 +1,565 @@
+/*
+ * Copyright (c) 2009-2016 Solarflare Communications Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *this list of conditions and the following disclaimer in the documentation
+ *and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 

[dpdk-dev] [PATCH 23/56] net/sfc: import libefx monitors statistics support

2016-11-21 Thread Andrew Rybchenko
EFSYS_OPT_MON_STATS should be enabled to use it.

>From Solarflare Communications Inc.

Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/efx/base/ef10_ev.c   |  20 +
 drivers/net/sfc/efx/base/ef10_nic.c  |  15 
 drivers/net/sfc/efx/base/efx.h   | 140 +++
 drivers/net/sfc/efx/base/efx_check.h |   7 ++
 drivers/net/sfc/efx/base/efx_ev.c|  18 +
 drivers/net/sfc/efx/base/efx_impl.h  |   4 +
 drivers/net/sfc/efx/base/efx_mon.c   | 118 +
 drivers/net/sfc/efx/base/siena_nic.c |  12 +++
 8 files changed, 334 insertions(+)

diff --git a/drivers/net/sfc/efx/base/ef10_ev.c 
b/drivers/net/sfc/efx/base/ef10_ev.c
index f58ccc6..e93b458 100644
--- a/drivers/net/sfc/efx/base/ef10_ev.c
+++ b/drivers/net/sfc/efx/base/ef10_ev.c
@@ -30,6 +30,9 @@

 #include "efx.h"
 #include "efx_impl.h"
+#if EFSYS_OPT_MON_STATS
+#include "mcdi_mon.h"
+#endif

 #if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD

@@ -1085,6 +1088,23 @@ ef10_ev_mcdi(
}

case MCDI_EVENT_CODE_SENSOREVT: {
+#if EFSYS_OPT_MON_STATS
+   efx_mon_stat_t id;
+   efx_mon_stat_value_t value;
+   efx_rc_t rc;
+
+   /* Decode monitor stat for MCDI sensor (if supported) */
+   if ((rc = mcdi_mon_ev(enp, eqp, , )) == 0) {
+   /* Report monitor stat change */
+   should_abort = eecp->eec_monitor(arg, id, value);
+   } else if (rc == ENOTSUP) {
+   should_abort = eecp->eec_exception(arg,
+   EFX_EXCEPTION_UNKNOWN_SENSOREVT,
+   MCDI_EV_FIELD(eqp, DATA));
+   } else {
+   EFSYS_ASSERT(rc == ENODEV); /* Wrong port */
+   }
+#endif
break;
}

diff --git a/drivers/net/sfc/efx/base/ef10_nic.c 
b/drivers/net/sfc/efx/base/ef10_nic.c
index fec6a69..32706f4 100644
--- a/drivers/net/sfc/efx/base/ef10_nic.c
+++ b/drivers/net/sfc/efx/base/ef10_nic.c
@@ -1382,10 +1382,22 @@ ef10_nic_probe(
goto fail6;
 #endif

+#if EFSYS_OPT_MON_STATS
+   if ((rc = mcdi_mon_cfg_build(enp)) != 0) {
+   /* Unprivileged functions do not have access to sensors */
+   if (rc != EACCES)
+   goto fail7;
+   }
+#endif
+
encp->enc_features = enp->en_features;

return (0);

+#if EFSYS_OPT_MON_STATS
+fail7:
+   EFSYS_PROBE(fail7);
+#endif
 #if EFSYS_OPT_LOOPBACK
 fail6:
EFSYS_PROBE(fail6);
@@ -1781,6 +1793,9 @@ ef10_nic_fini(
 ef10_nic_unprobe(
__inefx_nic_t *enp)
 {
+#if EFSYS_OPT_MON_STATS
+   mcdi_mon_cfg_free(enp);
+#endif /* EFSYS_OPT_MON_STATS */
(void) efx_mcdi_drv_attach(enp, B_FALSE);
 }

diff --git a/drivers/net/sfc/efx/base/efx.h b/drivers/net/sfc/efx/base/efx.h
index 70569e7..4fc0207 100644
--- a/drivers/net/sfc/efx/base/efx.h
+++ b/drivers/net/sfc/efx/base/efx.h
@@ -615,6 +615,125 @@ extern__checkReturn   efx_rc_t
 efx_mon_init(
__inefx_nic_t *enp);

+#if EFSYS_OPT_MON_STATS
+
+#defineEFX_MON_STATS_PAGE_SIZE 0x100
+#defineEFX_MON_MASK_ELEMENT_SIZE 32
+
+/* START MKCONFIG GENERATED MonitorHeaderStatsBlock 5d4ee5185e419abe */
+typedef enum efx_mon_stat_e {
+   EFX_MON_STAT_2_5V,
+   EFX_MON_STAT_VCCP1,
+   EFX_MON_STAT_VCC,
+   EFX_MON_STAT_5V,
+   EFX_MON_STAT_12V,
+   EFX_MON_STAT_VCCP2,
+   EFX_MON_STAT_EXT_TEMP,
+   EFX_MON_STAT_INT_TEMP,
+   EFX_MON_STAT_AIN1,
+   EFX_MON_STAT_AIN2,
+   EFX_MON_STAT_INT_COOLING,
+   EFX_MON_STAT_EXT_COOLING,
+   EFX_MON_STAT_1V,
+   EFX_MON_STAT_1_2V,
+   EFX_MON_STAT_1_8V,
+   EFX_MON_STAT_3_3V,
+   EFX_MON_STAT_1_2VA,
+   EFX_MON_STAT_VREF,
+   EFX_MON_STAT_VAOE,
+   EFX_MON_STAT_AOE_TEMP,
+   EFX_MON_STAT_PSU_AOE_TEMP,
+   EFX_MON_STAT_PSU_TEMP,
+   EFX_MON_STAT_FAN0,
+   EFX_MON_STAT_FAN1,
+   EFX_MON_STAT_FAN2,
+   EFX_MON_STAT_FAN3,
+   EFX_MON_STAT_FAN4,
+   EFX_MON_STAT_VAOE_IN,
+   EFX_MON_STAT_IAOE,
+   EFX_MON_STAT_IAOE_IN,
+   EFX_MON_STAT_NIC_POWER,
+   EFX_MON_STAT_0_9V,
+   EFX_MON_STAT_I0_9V,
+   EFX_MON_STAT_I1_2V,
+   EFX_MON_STAT_0_9V_ADC,
+   EFX_MON_STAT_INT_TEMP2,
+   EFX_MON_STAT_VREG_TEMP,
+   EFX_MON_STAT_VREG_0_9V_TEMP,
+   EFX_MON_STAT_VREG_1_2V_TEMP,
+   EFX_MON_STAT_INT_VPTAT,
+   EFX_MON_STAT_INT_ADC_TEMP,
+   EFX_MON_STAT_EXT_VPTAT,
+   EFX_MON_STAT_EXT_ADC_TEMP,
+   EFX_MON_STAT_AMBIENT_TEMP,
+   EFX_MON_STAT_AIRFLOW,
+   EFX_MON_STAT_VDD08D_VSS08D_CSR,
+   EFX_MON_STAT_VDD08D_VSS08D_CSR_EXTADC,
+   EFX_MON_STAT_HOTPOINT_TEMP,
+   EFX_MON_STAT_PHY_POWER_SWITCH_PORT0,
+   EFX_MON_STAT_PHY_POWER_SWITCH_PORT1,
+   EFX_MON_STAT_MUM_VCC,
+   EFX_MON_STAT_0V9_A,
+   EFX_MON_STAT_I0V9_A,
+   EFX_MON_STAT_0V9_A_TEMP,
+ 

[dpdk-dev] [PATCH 22/56] net/sfc: import libefx loopback control support

2016-11-21 Thread Andrew Rybchenko
EFSYS_OPT_LOOPBACK should be enabled to use it.

>From Solarflare Communications Inc.

Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/efx/base/ef10_impl.h  |  13 +++
 drivers/net/sfc/efx/base/ef10_mac.c   |  36 +++
 drivers/net/sfc/efx/base/ef10_nic.c   |   9 ++
 drivers/net/sfc/efx/base/ef10_phy.c   |  45 
 drivers/net/sfc/efx/base/efx.h|  74 +
 drivers/net/sfc/efx/base/efx_check.h  |   7 ++
 drivers/net/sfc/efx/base/efx_impl.h   |   8 ++
 drivers/net/sfc/efx/base/efx_mac.c|   6 ++
 drivers/net/sfc/efx/base/efx_mcdi.h   |   6 ++
 drivers/net/sfc/efx/base/efx_nic.c| 188 ++
 drivers/net/sfc/efx/base/efx_port.c   | 101 ++
 drivers/net/sfc/efx/base/siena_impl.h |  13 +++
 drivers/net/sfc/efx/base/siena_mac.c  |  36 +++
 drivers/net/sfc/efx/base/siena_nic.c  |   9 ++
 drivers/net/sfc/efx/base/siena_phy.c  |  42 
 15 files changed, 593 insertions(+)

diff --git a/drivers/net/sfc/efx/base/ef10_impl.h 
b/drivers/net/sfc/efx/base/ef10_impl.h
index f70773c..e468b24 100644
--- a/drivers/net/sfc/efx/base/ef10_impl.h
+++ b/drivers/net/sfc/efx/base/ef10_impl.h
@@ -259,6 +259,16 @@ extern void
 ef10_mac_filter_default_rxq_clear(
__inefx_nic_t *enp);

+#if EFSYS_OPT_LOOPBACK
+
+extern __checkReturn   efx_rc_t
+ef10_mac_loopback_set(
+   __inefx_nic_t *enp,
+   __inefx_link_mode_t link_mode,
+   __inefx_loopback_type_t loopback_type);
+
+#endif /* EFSYS_OPT_LOOPBACK */
+
 #if EFSYS_OPT_MAC_STATS

 extern __checkReturn   efx_rc_t
@@ -337,6 +347,9 @@ typedef struct ef10_link_state_s {
uint32_tels_lp_cap_mask;
unsigned intels_fcntl;
efx_link_mode_t els_link_mode;
+#if EFSYS_OPT_LOOPBACK
+   efx_loopback_type_t els_loopback;
+#endif
boolean_t   els_mac_up;
 } ef10_link_state_t;

diff --git a/drivers/net/sfc/efx/base/ef10_mac.c 
b/drivers/net/sfc/efx/base/ef10_mac.c
index 477d0e7..488633f 100644
--- a/drivers/net/sfc/efx/base/ef10_mac.c
+++ b/drivers/net/sfc/efx/base/ef10_mac.c
@@ -443,6 +443,42 @@ ef10_mac_filter_default_rxq_clear(
 }


+#if EFSYS_OPT_LOOPBACK
+
+   __checkReturn   efx_rc_t
+ef10_mac_loopback_set(
+   __inefx_nic_t *enp,
+   __inefx_link_mode_t link_mode,
+   __inefx_loopback_type_t loopback_type)
+{
+   efx_port_t *epp = &(enp->en_port);
+   const efx_phy_ops_t *epop = epp->ep_epop;
+   efx_loopback_type_t old_loopback_type;
+   efx_link_mode_t old_loopback_link_mode;
+   efx_rc_t rc;
+
+   /* The PHY object handles this on EF10 */
+   old_loopback_type = epp->ep_loopback_type;
+   old_loopback_link_mode = epp->ep_loopback_link_mode;
+   epp->ep_loopback_type = loopback_type;
+   epp->ep_loopback_link_mode = link_mode;
+
+   if ((rc = epop->epo_reconfigure(enp)) != 0)
+   goto fail1;
+
+   return (0);
+
+fail1:
+   EFSYS_PROBE1(fail1, efx_rc_t, rc);
+
+   epp->ep_loopback_type = old_loopback_type;
+   epp->ep_loopback_link_mode = old_loopback_link_mode;
+
+   return (rc);
+}
+
+#endif /* EFSYS_OPT_LOOPBACK */
+
 #if EFSYS_OPT_MAC_STATS

__checkReturn   efx_rc_t
diff --git a/drivers/net/sfc/efx/base/ef10_nic.c 
b/drivers/net/sfc/efx/base/ef10_nic.c
index f28edd2..fec6a69 100644
--- a/drivers/net/sfc/efx/base/ef10_nic.c
+++ b/drivers/net/sfc/efx/base/ef10_nic.c
@@ -1377,10 +1377,19 @@ ef10_nic_probe(
goto fail5;
 #endif

+#if EFSYS_OPT_LOOPBACK
+   if ((rc = efx_mcdi_get_loopback_modes(enp)) != 0)
+   goto fail6;
+#endif
+
encp->enc_features = enp->en_features;

return (0);

+#if EFSYS_OPT_LOOPBACK
+fail6:
+   EFSYS_PROBE(fail6);
+#endif
 #if EFSYS_OPT_MAC_STATS
 fail5:
EFSYS_PROBE(fail5);
diff --git a/drivers/net/sfc/efx/base/ef10_phy.c 
b/drivers/net/sfc/efx/base/ef10_phy.c
index cc00250..81309f2 100644
--- a/drivers/net/sfc/efx/base/ef10_phy.c
+++ b/drivers/net/sfc/efx/base/ef10_phy.c
@@ -235,6 +235,30 @@ ef10_phy_get_link(
MCDI_OUT_DWORD(req, GET_LINK_OUT_FCNTL),
>els_link_mode, >els_fcntl);

+#if EFSYS_OPT_LOOPBACK
+   /* Assert the MC_CMD_LOOPBACK and EFX_LOOPBACK namespace agree */
+   EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_NONE == EFX_LOOPBACK_OFF);
+   EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_DATA == EFX_LOOPBACK_DATA);
+   EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_GMAC == EFX_LOOPBACK_GMAC);
+   EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_XGMII == EFX_LOOPBACK_XGMII);
+   EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_XGXS == EFX_LOOPBACK_XGXS);
+   EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_XAUI == EFX_LOOPBACK_XAUI);
+   EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_GMII == EFX_LOOPBACK_GMII);
+   EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_SGMII == EFX_LOOPBACK_SGMII);
+   

[dpdk-dev] [PATCH 21/56] net/sfc: import libefx RSS support

2016-11-21 Thread Andrew Rybchenko
EFSYS_OPT_RX_SCALE should be enabled to use it.

>From Solarflare Communications Inc.

Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/efx/base/ef10_filter.c |  10 +
 drivers/net/sfc/efx/base/ef10_impl.h   |  29 +++
 drivers/net/sfc/efx/base/ef10_rx.c | 443 
 drivers/net/sfc/efx/base/efx.h |  67 +
 drivers/net/sfc/efx/base/efx_check.h   |   7 +
 drivers/net/sfc/efx/base/efx_ev.c  |  11 +
 drivers/net/sfc/efx/base/efx_filter.c  |   4 +
 drivers/net/sfc/efx/base/efx_impl.h|  14 +
 drivers/net/sfc/efx/base/efx_rx.c  | 456 +
 9 files changed, 1041 insertions(+)

diff --git a/drivers/net/sfc/efx/base/ef10_filter.c 
b/drivers/net/sfc/efx/base/ef10_filter.c
index 608a058..a881522 100644
--- a/drivers/net/sfc/efx/base/ef10_filter.c
+++ b/drivers/net/sfc/efx/base/ef10_filter.c
@@ -562,6 +562,10 @@ ef10_filter_add_internal(
EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
enp->en_family == EFX_FAMILY_MEDFORD);

+#if EFSYS_OPT_RX_SCALE
+   spec->efs_rss_context = enp->en_rss_context;
+#endif
+
hash = ef10_filter_hash(spec);

/*
@@ -1448,8 +1452,14 @@ ef10_filter_default_rxq_set(
 {
ef10_filter_table_t *table = enp->en_filter.ef_ef10_filter_table;

+#if EFSYS_OPT_RX_SCALE
+   EFSYS_ASSERT((using_rss == B_FALSE) ||
+   (enp->en_rss_context != EF10_RSS_CONTEXT_INVALID));
+   table->eft_using_rss = using_rss;
+#else
EFSYS_ASSERT(using_rss == B_FALSE);
table->eft_using_rss = B_FALSE;
+#endif
table->eft_default_rxq = erp;
 }

diff --git a/drivers/net/sfc/efx/base/ef10_impl.h 
b/drivers/net/sfc/efx/base/ef10_impl.h
index eedf121..f70773c 100644
--- a/drivers/net/sfc/efx/base/ef10_impl.h
+++ b/drivers/net/sfc/efx/base/ef10_impl.h
@@ -581,6 +581,35 @@ ef10_rx_scatter_enable(
 #endif /* EFSYS_OPT_RX_SCATTER */


+#if EFSYS_OPT_RX_SCALE
+
+extern __checkReturn   efx_rc_t
+ef10_rx_scale_mode_set(
+   __inefx_nic_t *enp,
+   __inefx_rx_hash_alg_t alg,
+   __inefx_rx_hash_type_t type,
+   __inboolean_t insert);
+
+extern __checkReturn   efx_rc_t
+ef10_rx_scale_key_set(
+   __inefx_nic_t *enp,
+   __in_ecount(n)  uint8_t *key,
+   __insize_t n);
+
+extern __checkReturn   efx_rc_t
+ef10_rx_scale_tbl_set(
+   __inefx_nic_t *enp,
+   __in_ecount(n)  unsigned int *table,
+   __insize_t n);
+
+extern __checkReturn   uint32_t
+ef10_rx_prefix_hash(
+   __inefx_nic_t *enp,
+   __inefx_rx_hash_alg_t func,
+   __inuint8_t *buffer);
+
+#endif /* EFSYS_OPT_RX_SCALE */
+
 extern __checkReturn   efx_rc_t
 ef10_rx_prefix_pktlen(
__inefx_nic_t *enp,
diff --git a/drivers/net/sfc/efx/base/ef10_rx.c 
b/drivers/net/sfc/efx/base/ef10_rx.c
index 95a182b..09a6314 100644
--- a/drivers/net/sfc/efx/base/ef10_rx.c
+++ b/drivers/net/sfc/efx/base/ef10_rx.c
@@ -150,11 +150,325 @@ efx_mcdi_fini_rxq(
return (rc);
 }

+#if EFSYS_OPT_RX_SCALE
+static __checkReturn   efx_rc_t
+efx_mcdi_rss_context_alloc(
+   __inefx_nic_t *enp,
+   __inefx_rx_scale_support_t scale_support,
+   __inuint32_t num_queues,
+   __out   uint32_t *rss_contextp)
+{
+   efx_mcdi_req_t req;
+   uint8_t payload[MAX(MC_CMD_RSS_CONTEXT_ALLOC_IN_LEN,
+   MC_CMD_RSS_CONTEXT_ALLOC_OUT_LEN)];
+   uint32_t rss_context;
+   uint32_t context_type;
+   efx_rc_t rc;
+
+   if (num_queues > EFX_MAXRSS) {
+   rc = EINVAL;
+   goto fail1;
+   }
+
+   switch (scale_support) {
+   case EFX_RX_SCALE_EXCLUSIVE:
+   context_type = MC_CMD_RSS_CONTEXT_ALLOC_IN_TYPE_EXCLUSIVE;
+   break;
+   case EFX_RX_SCALE_SHARED:
+   context_type = MC_CMD_RSS_CONTEXT_ALLOC_IN_TYPE_SHARED;
+   break;
+   default:
+   rc = EINVAL;
+   goto fail2;
+   }
+
+   (void) memset(payload, 0, sizeof (payload));
+   req.emr_cmd = MC_CMD_RSS_CONTEXT_ALLOC;
+   req.emr_in_buf = payload;
+   req.emr_in_length = MC_CMD_RSS_CONTEXT_ALLOC_IN_LEN;
+   req.emr_out_buf = payload;
+   req.emr_out_length = MC_CMD_RSS_CONTEXT_ALLOC_OUT_LEN;
+
+   MCDI_IN_SET_DWORD(req, RSS_CONTEXT_ALLOC_IN_UPSTREAM_PORT_ID,
+   EVB_PORT_ID_ASSIGNED);
+   MCDI_IN_SET_DWORD(req, RSS_CONTEXT_ALLOC_IN_TYPE, context_type);
+   /* NUM_QUEUES is only used to validate indirection table offsets */
+   MCDI_IN_SET_DWORD(req, RSS_CONTEXT_ALLOC_IN_NUM_QUEUES, num_queues);
+
+   efx_mcdi_execute(enp, );
+
+   if (req.emr_rc != 0) {
+   rc = req.emr_rc;
+   goto fail3;
+   }
+
+   if (req.emr_out_length_used < MC_CMD_RSS_CONTEXT_ALLOC_OUT_LEN) {
+   rc = 

[dpdk-dev] [PATCH 20/56] net/sfc: import libefx Rx scatter support

2016-11-21 Thread Andrew Rybchenko
EFSYS_OPT_RX_SCATTER should be enabled to use it.

>From Solarflare Communications Inc.

Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/efx/base/ef10_impl.h |  7 +++
 drivers/net/sfc/efx/base/ef10_rx.c   | 11 +
 drivers/net/sfc/efx/base/efx.h   |  7 +++
 drivers/net/sfc/efx/base/efx_check.h |  7 +++
 drivers/net/sfc/efx/base/efx_ev.c| 33 +
 drivers/net/sfc/efx/base/efx_impl.h  |  3 ++
 drivers/net/sfc/efx/base/efx_rx.c| 90 
 7 files changed, 158 insertions(+)

diff --git a/drivers/net/sfc/efx/base/ef10_impl.h 
b/drivers/net/sfc/efx/base/ef10_impl.h
index c778cce..eedf121 100644
--- a/drivers/net/sfc/efx/base/ef10_impl.h
+++ b/drivers/net/sfc/efx/base/ef10_impl.h
@@ -573,6 +573,13 @@ extern __checkReturn   efx_rc_t
 ef10_rx_init(
__inefx_nic_t *enp);

+#if EFSYS_OPT_RX_SCATTER
+extern __checkReturn   efx_rc_t
+ef10_rx_scatter_enable(
+   __inefx_nic_t *enp,
+   __inunsigned int buf_size);
+#endif /* EFSYS_OPT_RX_SCATTER */
+

 extern __checkReturn   efx_rc_t
 ef10_rx_prefix_pktlen(
diff --git a/drivers/net/sfc/efx/base/ef10_rx.c 
b/drivers/net/sfc/efx/base/ef10_rx.c
index 170125e..95a182b 100644
--- a/drivers/net/sfc/efx/base/ef10_rx.c
+++ b/drivers/net/sfc/efx/base/ef10_rx.c
@@ -159,6 +159,17 @@ ef10_rx_init(
return (0);
 }

+#if EFSYS_OPT_RX_SCATTER
+   __checkReturn   efx_rc_t
+ef10_rx_scatter_enable(
+   __inefx_nic_t *enp,
+   __inunsigned int buf_size)
+{
+   _NOTE(ARGUNUSED(enp, buf_size))
+   return (0);
+}
+#endif /* EFSYS_OPT_RX_SCATTER */
+

 /*
  * EF10 RX pseudo-header
diff --git a/drivers/net/sfc/efx/base/efx.h b/drivers/net/sfc/efx/base/efx.h
index 24b7c8d..bd85f0b 100644
--- a/drivers/net/sfc/efx/base/efx.h
+++ b/drivers/net/sfc/efx/base/efx.h
@@ -1381,6 +1381,13 @@ extern   void
 efx_rx_fini(
__inefx_nic_t *enp);

+#if EFSYS_OPT_RX_SCATTER
+   __checkReturn   efx_rc_t
+efx_rx_scatter_enable(
+   __inefx_nic_t *enp,
+   __inunsigned int buf_size);
+#endif /* EFSYS_OPT_RX_SCATTER */
+
 extern __checkReturn   efx_rc_t
 efx_psuedo_hdr_pkt_length_get(
__inefx_rxq_t *erp,
diff --git a/drivers/net/sfc/efx/base/efx_check.h 
b/drivers/net/sfc/efx/base/efx_check.h
index df46410..91a764f 100644
--- a/drivers/net/sfc/efx/base/efx_check.h
+++ b/drivers/net/sfc/efx/base/efx_check.h
@@ -244,6 +244,13 @@
 # error "RX_HDR_SPLIT is obsolete and is not supported"
 #endif

+#if EFSYS_OPT_RX_SCATTER
+/* Support receive scatter DMA */
+# if !(EFSYS_OPT_SIENA || EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD)
+#  error "RX_SCATTER requires SIENA or HUNTINGTON or MEDFORD"
+# endif
+#endif /* EFSYS_OPT_RX_SCATTER */
+
 #ifdef EFSYS_OPT_STAT_NAME
 # error "STAT_NAME is obsolete (replaced by NAMES)."
 #endif
diff --git a/drivers/net/sfc/efx/base/efx_ev.c 
b/drivers/net/sfc/efx/base/efx_ev.c
index c172a06..a667124 100644
--- a/drivers/net/sfc/efx/base/efx_ev.c
+++ b/drivers/net/sfc/efx/base/efx_ev.c
@@ -646,6 +646,22 @@ siena_ev_rx_not_ok(
EFX_EV_QSTAT_INCR(eep, EV_RX_FRM_TRUNC);
(*flagsp) |= EFX_DISCARD;

+#if EFSYS_OPT_RX_SCATTER
+   /*
+* Lookout for payload queue ran dry errors and ignore them.
+*
+* Sadly for the header/data split cases, the descriptor
+* pointer in this event refers to the header queue and
+* therefore cannot be easily detected as duplicate.
+* So we drop these and rely on the receive processing seeing
+* a subsequent packet with FSF_AZ_RX_EV_SOP set to discard
+* the partially received packet.
+*/
+   if ((EFX_QWORD_FIELD(*eqp, FSF_AZ_RX_EV_SOP) == 0) &&
+   (EFX_QWORD_FIELD(*eqp, FSF_AZ_RX_EV_JUMBO_CONT) == 0) &&
+   (EFX_QWORD_FIELD(*eqp, FSF_AZ_RX_EV_BYTE_CNT) == 0))
+   ignore = B_TRUE;
+#endif /* EFSYS_OPT_RX_SCATTER */
}

if (EFX_QWORD_FIELD(*eqp, FSF_AZ_RX_EV_ETH_CRC_ERR) != 0) {
@@ -705,6 +721,10 @@ siena_ev_rx(
uint32_t size;
uint32_t label;
boolean_t ok;
+#if EFSYS_OPT_RX_SCATTER
+   boolean_t sop;
+   boolean_t jumbo_cont;
+#endif /* EFSYS_OPT_RX_SCATTER */
uint32_t hdr_type;
boolean_t is_v6;
uint16_t flags;
@@ -719,6 +739,11 @@ siena_ev_rx(
label = EFX_QWORD_FIELD(*eqp, FSF_AZ_RX_EV_Q_LABEL);
ok = (EFX_QWORD_FIELD(*eqp, FSF_AZ_RX_EV_PKT_OK) != 0);

+#if EFSYS_OPT_RX_SCATTER
+   sop = (EFX_QWORD_FIELD(*eqp, FSF_AZ_RX_EV_SOP) != 0);
+   jumbo_cont = (EFX_QWORD_FIELD(*eqp, FSF_AZ_RX_EV_JUMBO_CONT) != 0);
+#endif /* EFSYS_OPT_RX_SCATTER */
+
hdr_type = EFX_QWORD_FIELD(*eqp, FSF_AZ_RX_EV_HDR_TYPE);

is_v6 = (EFX_QWORD_FIELD(*eqp, FSF_CZ_RX_EV_IPV6_PKT) != 0);
@@ -771,6 +796,14 

[dpdk-dev] [PATCH 19/56] net/sfc: import libefx event prefetch support

2016-11-21 Thread Andrew Rybchenko
EFSYS_OPT_EV_PREFECT allows to enable event prefetching
when event queue is polled.

>From Solarflare Communications Inc.

Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/efx/base/efx.h   |  9 +
 drivers/net/sfc/efx/base/efx_check.h |  7 +++
 drivers/net/sfc/efx/base/efx_ev.c| 38 
 3 files changed, 54 insertions(+)

diff --git a/drivers/net/sfc/efx/base/efx.h b/drivers/net/sfc/efx/base/efx.h
index c06c9b6..24b7c8d 100644
--- a/drivers/net/sfc/efx/base/efx.h
+++ b/drivers/net/sfc/efx/base/efx.h
@@ -1317,6 +1317,15 @@ efx_ev_qpending(
__inefx_evq_t *eep,
__inunsigned int count);

+#if EFSYS_OPT_EV_PREFETCH
+
+extern void
+efx_ev_qprefetch(
+   __inefx_evq_t *eep,
+   __inunsigned int count);
+
+#endif /* EFSYS_OPT_EV_PREFETCH */
+
 extern void
 efx_ev_qpoll(
__inefx_evq_t *eep,
diff --git a/drivers/net/sfc/efx/base/efx_check.h 
b/drivers/net/sfc/efx/base/efx_check.h
index 5956052..df46410 100644
--- a/drivers/net/sfc/efx/base/efx_check.h
+++ b/drivers/net/sfc/efx/base/efx_check.h
@@ -66,6 +66,13 @@
 # endif
 #endif /* EFSYS_OPT_DIAG */

+#if EFSYS_OPT_EV_PREFETCH
+/* Support optimized EVQ data access */
+# if !(EFSYS_OPT_SIENA || EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD)
+#  error "EV_PREFETCH requires SIENA or HUNTINGTON or MEDFORD"
+# endif
+#endif /* EFSYS_OPT_EV_PREFETCH */
+
 #ifdef EFSYS_OPT_FALCON_NIC_CFG_OVERRIDE
 # error "FALCON_NIC_CFG_OVERRIDE is obsolete and is not supported."
 #endif
diff --git a/drivers/net/sfc/efx/base/efx_ev.c 
b/drivers/net/sfc/efx/base/efx_ev.c
index 74d146e..c172a06 100644
--- a/drivers/net/sfc/efx/base/efx_ev.c
+++ b/drivers/net/sfc/efx/base/efx_ev.c
@@ -351,6 +351,23 @@ efx_ev_qpending(
return (EFX_EV_PRESENT(qword));
 }

+#if EFSYS_OPT_EV_PREFETCH
+
+   void
+efx_ev_qprefetch(
+   __inefx_evq_t *eep,
+   __inunsigned int count)
+{
+   unsigned int offset;
+
+   EFSYS_ASSERT3U(eep->ee_magic, ==, EFX_EVQ_MAGIC);
+
+   offset = (count & eep->ee_mask) * sizeof (efx_qword_t);
+   EFSYS_MEM_PREFETCH(eep->ee_esmp, offset);
+}
+
+#endif /* EFSYS_OPT_EV_PREFETCH */
+
 #defineEFX_EV_BATCH8

void
@@ -403,11 +420,32 @@ efx_ev_qpoll(
offset += sizeof (efx_qword_t);
}

+#if EFSYS_OPT_EV_PREFETCH && (EFSYS_OPT_EV_PREFETCH_PERIOD > 1)
+   /*
+* Prefetch the next batch when we get within PREFETCH_PERIOD
+* of a completed batch. If the batch is smaller, then prefetch
+* immediately.
+*/
+   if (total == batch && total < EFSYS_OPT_EV_PREFETCH_PERIOD)
+   EFSYS_MEM_PREFETCH(eep->ee_esmp, offset);
+#endif /* EFSYS_OPT_EV_PREFETCH */
+
/* Process the batch of events */
for (index = 0; index < total; ++index) {
boolean_t should_abort;
uint32_t code;

+#if EFSYS_OPT_EV_PREFETCH
+   /* Prefetch if we've now reached the batch period */
+   if (total == batch &&
+   index + EFSYS_OPT_EV_PREFETCH_PERIOD == total) {
+   offset = (count + batch) & eep->ee_mask;
+   offset *= sizeof (efx_qword_t);
+
+   EFSYS_MEM_PREFETCH(eep->ee_esmp, offset);
+   }
+#endif /* EFSYS_OPT_EV_PREFETCH */
+
EFX_EV_QSTAT_INCR(eep, EV_ALL);

code = EFX_QWORD_FIELD(ev[index], FSF_AZ_EV_CODE);
-- 
2.5.5



[dpdk-dev] [PATCH 18/56] net/sfc: import libefx MAC statistics support

2016-11-21 Thread Andrew Rybchenko
MAC statistics are either periodically (if supported/requested)
or on-demand written to provided DMA-mapped memory.
If periodic update is not supported (e.g. for EF10 virtual
functions), it is the driver responsiblity to handle it.

EFSYS_OPT_MAC_STATS should be enabled to use it.

>From Solarflare Communications Inc.

Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/efx/base/ef10_ev.c|   6 +
 drivers/net/sfc/efx/base/ef10_impl.h  |  17 ++
 drivers/net/sfc/efx/base/ef10_mac.c   | 415 ++
 drivers/net/sfc/efx/base/ef10_nic.c   |  10 +
 drivers/net/sfc/efx/base/efx.h| 175 ++
 drivers/net/sfc/efx/base/efx_check.h  |   7 +
 drivers/net/sfc/efx/base/efx_ev.c |   6 +
 drivers/net/sfc/efx/base/efx_impl.h   |  29 +++
 drivers/net/sfc/efx/base/efx_mac.c| 305 +
 drivers/net/sfc/efx/base/efx_mcdi.c   | 158 +
 drivers/net/sfc/efx/base/siena_impl.h |  17 ++
 drivers/net/sfc/efx/base/siena_mac.c  | 235 +++
 drivers/net/sfc/efx/base/siena_nic.c  |  10 +
 13 files changed, 1390 insertions(+)

diff --git a/drivers/net/sfc/efx/base/ef10_ev.c 
b/drivers/net/sfc/efx/base/ef10_ev.c
index b4fe9a7..f58ccc6 100644
--- a/drivers/net/sfc/efx/base/ef10_ev.c
+++ b/drivers/net/sfc/efx/base/ef10_ev.c
@@ -1103,6 +1103,12 @@ ef10_ev_mcdi(
break;

case MCDI_EVENT_CODE_MAC_STATS_DMA:
+#if EFSYS_OPT_MAC_STATS
+   if (eecp->eec_mac_stats != NULL) {
+   eecp->eec_mac_stats(arg,
+   MCDI_EV_FIELD(eqp, MAC_STATS_DMA_GENERATION));
+   }
+#endif
break;

case MCDI_EVENT_CODE_FWALERT: {
diff --git a/drivers/net/sfc/efx/base/ef10_impl.h 
b/drivers/net/sfc/efx/base/ef10_impl.h
index e847c22..c778cce 100644
--- a/drivers/net/sfc/efx/base/ef10_impl.h
+++ b/drivers/net/sfc/efx/base/ef10_impl.h
@@ -259,6 +259,23 @@ extern void
 ef10_mac_filter_default_rxq_clear(
__inefx_nic_t *enp);

+#if EFSYS_OPT_MAC_STATS
+
+extern __checkReturn   efx_rc_t
+ef10_mac_stats_get_mask(
+   __inefx_nic_t *enp,
+   __inout_bcount(mask_size)   uint32_t *maskp,
+   __insize_t mask_size);
+
+extern __checkReturn   efx_rc_t
+ef10_mac_stats_update(
+   __inefx_nic_t *enp,
+   __inefsys_mem_t *esmp,
+   __inout_ecount(EFX_MAC_NSTATS)  efsys_stat_t *stat,
+   __inout_opt uint32_t *generationp);
+
+#endif /* EFSYS_OPT_MAC_STATS */
+

 /* MCDI */

diff --git a/drivers/net/sfc/efx/base/ef10_mac.c 
b/drivers/net/sfc/efx/base/ef10_mac.c
index 7960067..477d0e7 100644
--- a/drivers/net/sfc/efx/base/ef10_mac.c
+++ b/drivers/net/sfc/efx/base/ef10_mac.c
@@ -443,4 +443,419 @@ ef10_mac_filter_default_rxq_clear(
 }


+#if EFSYS_OPT_MAC_STATS
+
+   __checkReturn   efx_rc_t
+ef10_mac_stats_get_mask(
+   __inefx_nic_t *enp,
+   __inout_bcount(mask_size)   uint32_t *maskp,
+   __insize_t mask_size)
+{
+   const struct efx_mac_stats_range ef10_common[] = {
+   { EFX_MAC_RX_OCTETS, EFX_MAC_RX_GE_15XX_PKTS },
+   { EFX_MAC_RX_FCS_ERRORS, EFX_MAC_RX_DROP_EVENTS },
+   { EFX_MAC_RX_JABBER_PKTS, EFX_MAC_RX_JABBER_PKTS },
+   { EFX_MAC_RX_NODESC_DROP_CNT, EFX_MAC_TX_PAUSE_PKTS },
+   };
+   const struct efx_mac_stats_range ef10_tx_size_bins[] = {
+   { EFX_MAC_TX_LE_64_PKTS, EFX_MAC_TX_GE_15XX_PKTS },
+   };
+   efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
+   efx_port_t *epp = &(enp->en_port);
+   efx_rc_t rc;
+
+   if ((rc = efx_mac_stats_mask_add_ranges(maskp, mask_size,
+   ef10_common, EFX_ARRAY_SIZE(ef10_common))) != 0)
+   goto fail1;
+
+   if (epp->ep_phy_cap_mask & (1 << MC_CMD_PHY_CAP_4FDX_LBN)) {
+   const struct efx_mac_stats_range ef10_40g_extra[] = {
+   { EFX_MAC_RX_ALIGN_ERRORS, EFX_MAC_RX_ALIGN_ERRORS },
+   };
+
+   if ((rc = efx_mac_stats_mask_add_ranges(maskp, mask_size,
+   ef10_40g_extra, EFX_ARRAY_SIZE(ef10_40g_extra))) != 0)
+   goto fail2;
+
+   if (encp->enc_mac_stats_40g_tx_size_bins) {
+   if ((rc = efx_mac_stats_mask_add_ranges(maskp,
+   mask_size, ef10_tx_size_bins,
+   EFX_ARRAY_SIZE(ef10_tx_size_bins))) != 0)
+   goto fail3;
+   }
+   } else {
+   if ((rc = efx_mac_stats_mask_add_ranges(maskp, mask_size,
+   ef10_tx_size_bins, EFX_ARRAY_SIZE(ef10_tx_size_bins))) != 0)
+   goto fail4;
+   }
+
+   if (encp->enc_pm_and_rxdp_counters) {
+   

[dpdk-dev] [PATCH 16/56] net/sfc: import libefx PHY statistics support

2016-11-21 Thread Andrew Rybchenko
EFSYS_OPT_PHY_STATS should be enabled to use it.

>From Solarflare Communications Inc.

Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/efx/base/ef10_impl.h  |  10 +++
 drivers/net/sfc/efx/base/ef10_phy.c   |  17 
 drivers/net/sfc/efx/base/efx.h|  80 ++
 drivers/net/sfc/efx/base/efx_check.h  |   7 ++
 drivers/net/sfc/efx/base/efx_impl.h   |   4 +
 drivers/net/sfc/efx/base/efx_mcdi.c   |   5 ++
 drivers/net/sfc/efx/base/efx_phy.c|  93 +
 drivers/net/sfc/efx/base/siena_impl.h |  18 
 drivers/net/sfc/efx/base/siena_nic.c  |   6 ++
 drivers/net/sfc/efx/base/siena_phy.c  | 152 ++
 10 files changed, 392 insertions(+)

diff --git a/drivers/net/sfc/efx/base/ef10_impl.h 
b/drivers/net/sfc/efx/base/ef10_impl.h
index e1d2903..e847c22 100644
--- a/drivers/net/sfc/efx/base/ef10_impl.h
+++ b/drivers/net/sfc/efx/base/ef10_impl.h
@@ -352,6 +352,16 @@ ef10_phy_oui_get(
__inefx_nic_t *enp,
__out   uint32_t *ouip);

+#if EFSYS_OPT_PHY_STATS
+
+extern __checkReturn   efx_rc_t
+ef10_phy_stats_update(
+   __inefx_nic_t *enp,
+   __inefsys_mem_t *esmp,
+   __inout_ecount(EFX_PHY_NSTATS)  uint32_t *stat);
+
+#endif /* EFSYS_OPT_PHY_STATS */
+
 #if EFSYS_OPT_BIST

 extern __checkReturn   efx_rc_t
diff --git a/drivers/net/sfc/efx/base/ef10_phy.c 
b/drivers/net/sfc/efx/base/ef10_phy.c
index c7e584b..b15b693 100644
--- a/drivers/net/sfc/efx/base/ef10_phy.c
+++ b/drivers/net/sfc/efx/base/ef10_phy.c
@@ -394,6 +394,23 @@ ef10_phy_oui_get(
return (ENOTSUP);
 }

+#if EFSYS_OPT_PHY_STATS
+
+   __checkReturn   efx_rc_t
+ef10_phy_stats_update(
+   __inefx_nic_t *enp,
+   __inefsys_mem_t *esmp,
+   __inout_ecount(EFX_PHY_NSTATS)  uint32_t *stat)
+{
+   /* TBD: no stats support in firmware yet */
+   _NOTE(ARGUNUSED(enp, esmp))
+   memset(stat, 0, EFX_PHY_NSTATS * sizeof (*stat));
+
+   return (0);
+}
+
+#endif /* EFSYS_OPT_PHY_STATS */
+
 #if EFSYS_OPT_BIST

__checkReturn   efx_rc_t
diff --git a/drivers/net/sfc/efx/base/efx.h b/drivers/net/sfc/efx/base/efx.h
index 6dd5a8e..02526cd 100644
--- a/drivers/net/sfc/efx/base/efx.h
+++ b/drivers/net/sfc/efx/base/efx.h
@@ -548,6 +548,80 @@ efx_phy_module_get_info(
__inuint8_t len,
__out_bcount(len)   uint8_t *data);

+#if EFSYS_OPT_PHY_STATS
+
+/* START MKCONFIG GENERATED PhyHeaderStatsBlock 30ed56ad501f8e36 */
+typedef enum efx_phy_stat_e {
+   EFX_PHY_STAT_OUI,
+   EFX_PHY_STAT_PMA_PMD_LINK_UP,
+   EFX_PHY_STAT_PMA_PMD_RX_FAULT,
+   EFX_PHY_STAT_PMA_PMD_TX_FAULT,
+   EFX_PHY_STAT_PMA_PMD_REV_A,
+   EFX_PHY_STAT_PMA_PMD_REV_B,
+   EFX_PHY_STAT_PMA_PMD_REV_C,
+   EFX_PHY_STAT_PMA_PMD_REV_D,
+   EFX_PHY_STAT_PCS_LINK_UP,
+   EFX_PHY_STAT_PCS_RX_FAULT,
+   EFX_PHY_STAT_PCS_TX_FAULT,
+   EFX_PHY_STAT_PCS_BER,
+   EFX_PHY_STAT_PCS_BLOCK_ERRORS,
+   EFX_PHY_STAT_PHY_XS_LINK_UP,
+   EFX_PHY_STAT_PHY_XS_RX_FAULT,
+   EFX_PHY_STAT_PHY_XS_TX_FAULT,
+   EFX_PHY_STAT_PHY_XS_ALIGN,
+   EFX_PHY_STAT_PHY_XS_SYNC_A,
+   EFX_PHY_STAT_PHY_XS_SYNC_B,
+   EFX_PHY_STAT_PHY_XS_SYNC_C,
+   EFX_PHY_STAT_PHY_XS_SYNC_D,
+   EFX_PHY_STAT_AN_LINK_UP,
+   EFX_PHY_STAT_AN_MASTER,
+   EFX_PHY_STAT_AN_LOCAL_RX_OK,
+   EFX_PHY_STAT_AN_REMOTE_RX_OK,
+   EFX_PHY_STAT_CL22EXT_LINK_UP,
+   EFX_PHY_STAT_SNR_A,
+   EFX_PHY_STAT_SNR_B,
+   EFX_PHY_STAT_SNR_C,
+   EFX_PHY_STAT_SNR_D,
+   EFX_PHY_STAT_PMA_PMD_SIGNAL_A,
+   EFX_PHY_STAT_PMA_PMD_SIGNAL_B,
+   EFX_PHY_STAT_PMA_PMD_SIGNAL_C,
+   EFX_PHY_STAT_PMA_PMD_SIGNAL_D,
+   EFX_PHY_STAT_AN_COMPLETE,
+   EFX_PHY_STAT_PMA_PMD_REV_MAJOR,
+   EFX_PHY_STAT_PMA_PMD_REV_MINOR,
+   EFX_PHY_STAT_PMA_PMD_REV_MICRO,
+   EFX_PHY_STAT_PCS_FW_VERSION_0,
+   EFX_PHY_STAT_PCS_FW_VERSION_1,
+   EFX_PHY_STAT_PCS_FW_VERSION_2,
+   EFX_PHY_STAT_PCS_FW_VERSION_3,
+   EFX_PHY_STAT_PCS_FW_BUILD_YY,
+   EFX_PHY_STAT_PCS_FW_BUILD_MM,
+   EFX_PHY_STAT_PCS_FW_BUILD_DD,
+   EFX_PHY_STAT_PCS_OP_MODE,
+   EFX_PHY_NSTATS
+} efx_phy_stat_t;
+
+/* END MKCONFIG GENERATED PhyHeaderStatsBlock */
+
+#if EFSYS_OPT_NAMES
+
+extern const char *
+efx_phy_stat_name(
+   __inefx_nic_t *enp,
+   __inefx_phy_stat_t stat);
+
+#endif /* EFSYS_OPT_NAMES */
+
+#defineEFX_PHY_STATS_SIZE 0x100
+
+extern __checkReturn   efx_rc_t
+efx_phy_stats_update(
+   __inefx_nic_t *enp,
+   __inefsys_mem_t *esmp,
+   __inout_ecount(EFX_PHY_NSTATS)  

[dpdk-dev] [PATCH 15/56] net/sfc: import libefx PHY flags control support

2016-11-21 Thread Andrew Rybchenko
EFSYS_OPT_PHY_FLAGS should be enabled to use it.

>From Solarflare Communications Inc.

Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/efx/base/ef10_phy.c  | 4 
 drivers/net/sfc/efx/base/efx.h   | 3 +++
 drivers/net/sfc/efx/base/efx_check.h | 7 +++
 drivers/net/sfc/efx/base/efx_impl.h  | 3 +++
 drivers/net/sfc/efx/base/efx_mcdi.c  | 3 +++
 drivers/net/sfc/efx/base/siena_phy.c | 4 
 6 files changed, 24 insertions(+)

diff --git a/drivers/net/sfc/efx/base/ef10_phy.c 
b/drivers/net/sfc/efx/base/ef10_phy.c
index 9e1b9c2..c7e584b 100644
--- a/drivers/net/sfc/efx/base/ef10_phy.c
+++ b/drivers/net/sfc/efx/base/ef10_phy.c
@@ -293,7 +293,11 @@ ef10_phy_reconfigure(
speed = 0;
MCDI_IN_SET_DWORD(req, SET_LINK_IN_LOOPBACK_SPEED, speed);

+#if EFSYS_OPT_PHY_FLAGS
+   MCDI_IN_SET_DWORD(req, SET_LINK_IN_FLAGS, epp->ep_phy_flags);
+#else
MCDI_IN_SET_DWORD(req, SET_LINK_IN_FLAGS, 0);
+#endif /* EFSYS_OPT_PHY_FLAGS */

efx_mcdi_execute(enp, );

diff --git a/drivers/net/sfc/efx/base/efx.h b/drivers/net/sfc/efx/base/efx.h
index c2587ca..6dd5a8e 100644
--- a/drivers/net/sfc/efx/base/efx.h
+++ b/drivers/net/sfc/efx/base/efx.h
@@ -668,6 +668,9 @@ typedef struct efx_nic_cfg_s {
uint32_tenc_rx_prefix_size;
uint32_tenc_rx_buf_align_start;
uint32_tenc_rx_buf_align_end;
+#if EFSYS_OPT_PHY_FLAGS
+   uint32_tenc_phy_flags_mask;
+#endif /* EFSYS_OPT_PHY_FLAGS */
 #if EFSYS_OPT_MCDI
uint8_t enc_mcdi_mdio_channel;
 #endif /* EFSYS_OPT_MCDI */
diff --git a/drivers/net/sfc/efx/base/efx_check.h 
b/drivers/net/sfc/efx/base/efx_check.h
index 6f0c216..68c01f3 100644
--- a/drivers/net/sfc/efx/base/efx_check.h
+++ b/drivers/net/sfc/efx/base/efx_check.h
@@ -166,6 +166,13 @@
 # error "PHY_BIST is obsolete (replaced by BIST)."
 #endif

+#if EFSYS_OPT_PHY_FLAGS
+/* Support PHY flags */
+# if !EFSYS_OPT_SIENA
+#  error "PHY_FLAGS requires SIENA"
+# endif
+#endif /* EFSYS_OPT_PHY_FLAGS */
+
 #ifdef EFSYS_OPT_PHY_NULL
 # error "PHY_NULL is obsolete and is not supported."
 #endif
diff --git a/drivers/net/sfc/efx/base/efx_impl.h 
b/drivers/net/sfc/efx/base/efx_impl.h
index f776656..489fcbc 100644
--- a/drivers/net/sfc/efx/base/efx_impl.h
+++ b/drivers/net/sfc/efx/base/efx_impl.h
@@ -237,6 +237,9 @@ typedef struct efx_port_s {
uint8_t ep_mulcst_addr_list[EFX_MAC_ADDR_LEN *
EFX_MAC_MULTICAST_LIST_MAX];
uint32_tep_mulcst_addr_count;
+#if EFSYS_OPT_PHY_FLAGS
+   uint32_tep_phy_flags;
+#endif /* EFSYS_OPT_PHY_FLAGS */
efx_phy_media_type_tep_fixed_port_type;
efx_phy_media_type_tep_module_type;
uint32_tep_adv_cap_mask;
diff --git a/drivers/net/sfc/efx/base/efx_mcdi.c 
b/drivers/net/sfc/efx/base/efx_mcdi.c
index 40cd456..b070887 100644
--- a/drivers/net/sfc/efx/base/efx_mcdi.c
+++ b/drivers/net/sfc/efx/base/efx_mcdi.c
@@ -1425,6 +1425,9 @@ efx_mcdi_get_phy_cfg(

epp->ep_phy_cap_mask =
MCDI_OUT_DWORD(req, GET_PHY_CFG_OUT_SUPPORTED_CAP);
+#if EFSYS_OPT_PHY_FLAGS
+   encp->enc_phy_flags_mask = MCDI_OUT_DWORD(req, GET_PHY_CFG_OUT_FLAGS);
+#endif /* EFSYS_OPT_PHY_FLAGS */

encp->enc_port = (uint8_t)MCDI_OUT_DWORD(req, GET_PHY_CFG_OUT_PRT);

diff --git a/drivers/net/sfc/efx/base/siena_phy.c 
b/drivers/net/sfc/efx/base/siena_phy.c
index d7e7d77..6451298 100644
--- a/drivers/net/sfc/efx/base/siena_phy.c
+++ b/drivers/net/sfc/efx/base/siena_phy.c
@@ -277,7 +277,11 @@ siena_phy_reconfigure(
speed = 0;
MCDI_IN_SET_DWORD(req, SET_LINK_IN_LOOPBACK_SPEED, speed);

+#if EFSYS_OPT_PHY_FLAGS
+   MCDI_IN_SET_DWORD(req, SET_LINK_IN_FLAGS, epp->ep_phy_flags);
+#else
MCDI_IN_SET_DWORD(req, SET_LINK_IN_FLAGS, 0);
+#endif /* EFSYS_OPT_PHY_FLAGS */

efx_mcdi_execute(enp, );

-- 
2.5.5



[dpdk-dev] [PATCH 14/56] net/sfc: import libefx software per-queue statistics support

2016-11-21 Thread Andrew Rybchenko
EFSYS_OPT_QSTATS should be enabled to use it.

>From Solarflare Communications Inc.

Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/efx/base/ef10_ev.c   |  25 
 drivers/net/sfc/efx/base/ef10_impl.h |  16 +
 drivers/net/sfc/efx/base/ef10_tx.c   |  26 
 drivers/net/sfc/efx/base/efx.h   |  97 ++
 drivers/net/sfc/efx/base/efx_check.h |   7 +++
 drivers/net/sfc/efx/base/efx_ev.c| 112 +++
 drivers/net/sfc/efx/base/efx_impl.h  |  13 
 drivers/net/sfc/efx/base/efx_tx.c|  80 +
 8 files changed, 376 insertions(+)

diff --git a/drivers/net/sfc/efx/base/ef10_ev.c 
b/drivers/net/sfc/efx/base/ef10_ev.c
index 46ecd42..b4fe9a7 100644
--- a/drivers/net/sfc/efx/base/ef10_ev.c
+++ b/drivers/net/sfc/efx/base/ef10_ev.c
@@ -33,7 +33,15 @@

 #if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD

+#if EFSYS_OPT_QSTATS
+#defineEFX_EV_QSTAT_INCR(_eep, _stat)  
\
+   do {\
+   (_eep)->ee_stat[_stat]++;   \
+   _NOTE(CONSTANTCONDITION)\
+   } while (B_FALSE)
+#else
 #defineEFX_EV_QSTAT_INCR(_eep, _stat)
+#endif

 /*
  * Non-interrupting event queue requires interrrupting event queue to
@@ -731,6 +739,23 @@ ef10_ev_qmoderate(
 }


+#if EFSYS_OPT_QSTATS
+   void
+ef10_ev_qstats_update(
+   __inefx_evq_t *eep,
+   __inout_ecount(EV_NQSTATS)  efsys_stat_t *stat)
+{
+   unsigned int id;
+
+   for (id = 0; id < EV_NQSTATS; id++) {
+   efsys_stat_t *essp = [id];
+
+   EFSYS_STAT_INCR(essp, eep->ee_stat[id]);
+   eep->ee_stat[id] = 0;
+   }
+}
+#endif /* EFSYS_OPT_QSTATS */
+
 static __checkReturn   boolean_t
 ef10_ev_rx(
__inefx_evq_t *eep,
diff --git a/drivers/net/sfc/efx/base/ef10_impl.h 
b/drivers/net/sfc/efx/base/ef10_impl.h
index 5cbe6b1..e1d2903 100644
--- a/drivers/net/sfc/efx/base/ef10_impl.h
+++ b/drivers/net/sfc/efx/base/ef10_impl.h
@@ -105,6 +105,13 @@ ef10_ev_qmoderate(
__inefx_evq_t *eep,
__inunsigned int us);

+#if EFSYS_OPT_QSTATS
+   void
+ef10_ev_qstats_update(
+   __inefx_evq_t *eep,
+   __inout_ecount(EV_NQSTATS)  efsys_stat_t *stat);
+#endif /* EFSYS_OPT_QSTATS */
+
void
 ef10_ev_rxlabel_init(
__inefx_evq_t *eep,
@@ -490,6 +497,15 @@ ef10_tx_qdesc_vlantci_create(
__out   efx_desc_t *edp);


+#if EFSYS_OPT_QSTATS
+
+extern void
+ef10_tx_qstats_update(
+   __inefx_txq_t *etp,
+   __inout_ecount(TX_NQSTATS)  efsys_stat_t *stat);
+
+#endif /* EFSYS_OPT_QSTATS */
+
 typedef uint32_t   efx_piobuf_handle_t;

 #defineEFX_PIOBUF_HANDLE_INVALID   ((efx_piobuf_handle_t) -1)
diff --git a/drivers/net/sfc/efx/base/ef10_tx.c 
b/drivers/net/sfc/efx/base/ef10_tx.c
index 59343a3..aa19cce 100644
--- a/drivers/net/sfc/efx/base/ef10_tx.c
+++ b/drivers/net/sfc/efx/base/ef10_tx.c
@@ -34,7 +34,15 @@

 #if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD

+#if EFSYS_OPT_QSTATS
+#defineEFX_TX_QSTAT_INCR(_etp, _stat)  
\
+   do {\
+   (_etp)->et_stat[_stat]++;   \
+   _NOTE(CONSTANTCONDITION)\
+   } while (B_FALSE)
+#else
 #defineEFX_TX_QSTAT_INCR(_etp, _stat)
+#endif

 static __checkReturn   efx_rc_t
 efx_mcdi_init_txq(
@@ -680,4 +688,22 @@ ef10_tx_qenable(
/* FIXME */
 }

+#if EFSYS_OPT_QSTATS
+   void
+ef10_tx_qstats_update(
+   __inefx_txq_t *etp,
+   __inout_ecount(TX_NQSTATS)  efsys_stat_t *stat)
+{
+   unsigned int id;
+
+   for (id = 0; id < TX_NQSTATS; id++) {
+   efsys_stat_t *essp = [id];
+
+   EFSYS_STAT_INCR(essp, etp->et_stat[id]);
+   etp->et_stat[id] = 0;
+   }
+}
+
+#endif /* EFSYS_OPT_QSTATS */
+
 #endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */
diff --git a/drivers/net/sfc/efx/base/efx.h b/drivers/net/sfc/efx/base/efx.h
index 15faf9d..c2587ca 100644
--- a/drivers/net/sfc/efx/base/efx.h
+++ b/drivers/net/sfc/efx/base/efx.h
@@ -823,6 +823,54 @@ efx_sram_buf_tbl_clear(

 typedef struct efx_evq_s   efx_evq_t;

+#if EFSYS_OPT_QSTATS
+
+/* START MKCONFIG GENERATED EfxHeaderEventQueueBlock 6f3843f5fe7cc843 */
+typedef enum efx_ev_qstat_e {
+   EV_ALL,
+   EV_RX,
+   EV_RX_OK,
+   EV_RX_FRM_TRUNC,
+   EV_RX_TOBE_DISC,
+   EV_RX_PAUSE_FRM_ERR,
+   EV_RX_BUF_OWNER_ID_ERR,
+   EV_RX_IPV4_HDR_CHKSUM_ERR,
+   EV_RX_TCP_UDP_CHKSUM_ERR,
+   

[dpdk-dev] [PATCH 13/56] net/sfc: import libefx built-in selftest support

2016-11-21 Thread Andrew Rybchenko
EFSYS_OPT_BIST should be enabled to use it.

>From Solarflare Communications Inc.

Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/efx/base/ef10_impl.h  |  29 +
 drivers/net/sfc/efx/base/ef10_phy.c   | 153 +
 drivers/net/sfc/efx/base/efx.h|  80 +
 drivers/net/sfc/efx/base/efx_check.h  |   7 ++
 drivers/net/sfc/efx/base/efx_impl.h   |  11 ++
 drivers/net/sfc/efx/base/efx_mcdi.c   | 115 +++
 drivers/net/sfc/efx/base/efx_mcdi.h   |  12 ++
 drivers/net/sfc/efx/base/efx_phy.c| 140 +++
 drivers/net/sfc/efx/base/siena_impl.h |  25 +
 drivers/net/sfc/efx/base/siena_phy.c  | 205 ++
 10 files changed, 777 insertions(+)

diff --git a/drivers/net/sfc/efx/base/ef10_impl.h 
b/drivers/net/sfc/efx/base/ef10_impl.h
index 5bebbe9..5cbe6b1 100644
--- a/drivers/net/sfc/efx/base/ef10_impl.h
+++ b/drivers/net/sfc/efx/base/ef10_impl.h
@@ -345,6 +345,35 @@ ef10_phy_oui_get(
__inefx_nic_t *enp,
__out   uint32_t *ouip);

+#if EFSYS_OPT_BIST
+
+extern __checkReturn   efx_rc_t
+ef10_bist_enable_offline(
+   __inefx_nic_t *enp);
+
+extern __checkReturn   efx_rc_t
+ef10_bist_start(
+   __inefx_nic_t *enp,
+   __inefx_bist_type_t type);
+
+extern __checkReturn   efx_rc_t
+ef10_bist_poll(
+   __inefx_nic_t *enp,
+   __inefx_bist_type_t type,
+   __out   efx_bist_result_t *resultp,
+   __out_opt __drv_when(count > 0, __notnull)
+   uint32_t*value_maskp,
+   __out_ecount_opt(count) __drv_when(count > 0, __notnull)
+   unsigned long   *valuesp,
+   __insize_t count);
+
+extern void
+ef10_bist_stop(
+   __inefx_nic_t *enp,
+   __inefx_bist_type_t type);
+
+#endif /* EFSYS_OPT_BIST */
+
 /* TX */

 extern __checkReturn   efx_rc_t
diff --git a/drivers/net/sfc/efx/base/ef10_phy.c 
b/drivers/net/sfc/efx/base/ef10_phy.c
index 36e2603..9e1b9c2 100644
--- a/drivers/net/sfc/efx/base/ef10_phy.c
+++ b/drivers/net/sfc/efx/base/ef10_phy.c
@@ -390,4 +390,157 @@ ef10_phy_oui_get(
return (ENOTSUP);
 }

+#if EFSYS_OPT_BIST
+
+   __checkReturn   efx_rc_t
+ef10_bist_enable_offline(
+   __inefx_nic_t *enp)
+{
+   efx_rc_t rc;
+
+   if ((rc = efx_mcdi_bist_enable_offline(enp)) != 0)
+   goto fail1;
+
+   return (0);
+
+fail1:
+   EFSYS_PROBE1(fail1, efx_rc_t, rc);
+
+   return (rc);
+}
+
+   __checkReturn   efx_rc_t
+ef10_bist_start(
+   __inefx_nic_t *enp,
+   __inefx_bist_type_t type)
+{
+   efx_rc_t rc;
+
+   if ((rc = efx_mcdi_bist_start(enp, type)) != 0)
+   goto fail1;
+
+   return (0);
+
+fail1:
+   EFSYS_PROBE1(fail1, efx_rc_t, rc);
+
+   return (rc);
+}
+
+   __checkReturn   efx_rc_t
+ef10_bist_poll(
+   __inefx_nic_t *enp,
+   __inefx_bist_type_t type,
+   __out   efx_bist_result_t *resultp,
+   __out_opt __drv_when(count > 0, __notnull)
+   uint32_t *value_maskp,
+   __out_ecount_opt(count) __drv_when(count > 0, __notnull)
+   unsigned long *valuesp,
+   __insize_t count)
+{
+   efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
+   efx_mcdi_req_t req;
+   uint8_t payload[MAX(MC_CMD_POLL_BIST_IN_LEN,
+   MCDI_CTL_SDU_LEN_MAX)];
+   uint32_t value_mask = 0;
+   uint32_t result;
+   efx_rc_t rc;
+
+   _NOTE(ARGUNUSED(type))
+
+   (void) memset(payload, 0, sizeof (payload));
+   req.emr_cmd = MC_CMD_POLL_BIST;
+   req.emr_in_buf = payload;
+   req.emr_in_length = MC_CMD_POLL_BIST_IN_LEN;
+   req.emr_out_buf = payload;
+   req.emr_out_length = MCDI_CTL_SDU_LEN_MAX;
+
+   efx_mcdi_execute(enp, );
+
+   if (req.emr_rc != 0) {
+   rc = req.emr_rc;
+   goto fail1;
+   }
+
+   if (req.emr_out_length_used < MC_CMD_POLL_BIST_OUT_RESULT_OFST + 4) {
+   rc = EMSGSIZE;
+   goto fail2;
+   }
+
+   if (count > 0)
+   (void) memset(valuesp, '\0', count * sizeof (unsigned long));
+
+   result = MCDI_OUT_DWORD(req, POLL_BIST_OUT_RESULT);
+
+   if (result == MC_CMD_POLL_BIST_FAILED &&
+   req.emr_out_length >= MC_CMD_POLL_BIST_OUT_MEM_LEN &&
+   count > EFX_BIST_MEM_ECC_FATAL) {
+   if (valuesp != NULL) {
+   valuesp[EFX_BIST_MEM_TEST] =
+   MCDI_OUT_DWORD(req, POLL_BIST_OUT_MEM_TEST);
+   valuesp[EFX_BIST_MEM_ADDR] =
+   MCDI_OUT_DWORD(req, POLL_BIST_OUT_MEM_ADDR);
+ 

[dpdk-dev] [PATCH 12/56] net/sfc: import libefx diagnostics support

2016-11-21 Thread Andrew Rybchenko
EFSYS_OPT_DIAG should be enabled to use it.

>From Solarflare Communications Inc.

Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/efx/base/ef10_impl.h  |   8 ++
 drivers/net/sfc/efx/base/ef10_nic.c   |  27 ++
 drivers/net/sfc/efx/base/efx.h|  33 +++
 drivers/net/sfc/efx/base/efx_check.h  |   7 ++
 drivers/net/sfc/efx/base/efx_impl.h   |  29 ++
 drivers/net/sfc/efx/base/efx_nic.c| 168 ++
 drivers/net/sfc/efx/base/efx_sram.c   | 131 ++
 drivers/net/sfc/efx/base/siena_impl.h |  17 
 drivers/net/sfc/efx/base/siena_nic.c  | 132 ++
 drivers/net/sfc/efx/base/siena_sram.c | 104 +
 10 files changed, 656 insertions(+)

diff --git a/drivers/net/sfc/efx/base/ef10_impl.h 
b/drivers/net/sfc/efx/base/ef10_impl.h
index 15d12d2..5bebbe9 100644
--- a/drivers/net/sfc/efx/base/ef10_impl.h
+++ b/drivers/net/sfc/efx/base/ef10_impl.h
@@ -192,6 +192,14 @@ extern __checkReturn   efx_rc_t
 ef10_nic_init(
__inefx_nic_t *enp);

+#if EFSYS_OPT_DIAG
+
+extern __checkReturn   efx_rc_t
+ef10_nic_register_test(
+   __inefx_nic_t *enp);
+
+#endif /* EFSYS_OPT_DIAG */
+
 extern void
 ef10_nic_fini(
__inefx_nic_t *enp);
diff --git a/drivers/net/sfc/efx/base/ef10_nic.c 
b/drivers/net/sfc/efx/base/ef10_nic.c
index 538e18c..0eb72a7 100644
--- a/drivers/net/sfc/efx/base/ef10_nic.c
+++ b/drivers/net/sfc/efx/base/ef10_nic.c
@@ -1765,5 +1765,32 @@ ef10_nic_unprobe(
(void) efx_mcdi_drv_attach(enp, B_FALSE);
 }

+#if EFSYS_OPT_DIAG
+
+   __checkReturn   efx_rc_t
+ef10_nic_register_test(
+   __inefx_nic_t *enp)
+{
+   efx_rc_t rc;
+
+   /* FIXME */
+   _NOTE(ARGUNUSED(enp))
+   _NOTE(CONSTANTCONDITION)
+   if (B_FALSE) {
+   rc = ENOTSUP;
+   goto fail1;
+   }
+   /* FIXME */
+
+   return (0);
+
+fail1:
+   EFSYS_PROBE1(fail1, efx_rc_t, rc);
+
+   return (rc);
+}
+
+#endif /* EFSYS_OPT_DIAG */
+

 #endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */
diff --git a/drivers/net/sfc/efx/base/efx.h b/drivers/net/sfc/efx/base/efx.h
index e61c865..4cabc79 100644
--- a/drivers/net/sfc/efx/base/efx.h
+++ b/drivers/net/sfc/efx/base/efx.h
@@ -146,6 +146,14 @@ extern __checkReturn   efx_rc_t
 efx_nic_reset(
__inefx_nic_t *enp);

+#if EFSYS_OPT_DIAG
+
+extern __checkReturn   efx_rc_t
+efx_nic_register_test(
+   __inefx_nic_t *enp);
+
+#endif /* EFSYS_OPT_DIAG */
+
 extern void
 efx_nic_fini(
__inefx_nic_t *enp);
@@ -689,6 +697,31 @@ efx_nic_get_vi_pool(

 /* NVRAM */

+#if EFSYS_OPT_DIAG
+
+typedef enum efx_pattern_type_t {
+   EFX_PATTERN_BYTE_INCREMENT = 0,
+   EFX_PATTERN_ALL_THE_SAME,
+   EFX_PATTERN_BIT_ALTERNATE,
+   EFX_PATTERN_BYTE_ALTERNATE,
+   EFX_PATTERN_BYTE_CHANGING,
+   EFX_PATTERN_BIT_SWEEP,
+   EFX_PATTERN_NTYPES
+} efx_pattern_type_t;
+
+typedefvoid
+(*efx_sram_pattern_fn_t)(
+   __insize_t row,
+   __inboolean_t negate,
+   __out   efx_qword_t *eqp);
+
+extern __checkReturn   efx_rc_t
+efx_sram_test(
+   __inefx_nic_t *enp,
+   __inefx_pattern_type_t type);
+
+#endif /* EFSYS_OPT_DIAG */
+
 extern __checkReturn   efx_rc_t
 efx_sram_buf_tbl_set(
__inefx_nic_t *enp,
diff --git a/drivers/net/sfc/efx/base/efx_check.h 
b/drivers/net/sfc/efx/base/efx_check.h
index ef88645..feaccd0 100644
--- a/drivers/net/sfc/efx/base/efx_check.h
+++ b/drivers/net/sfc/efx/base/efx_check.h
@@ -59,6 +59,13 @@
 # endif
 #endif /* EFSYS_OPT_DECODE_INTR_FATAL */

+#if EFSYS_OPT_DIAG
+/* Support diagnostic hardware tests */
+# if !(EFSYS_OPT_SIENA || EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD)
+#  error "DIAG requires SIENA or HUNTINGTON or MEDFORD"
+# endif
+#endif /* EFSYS_OPT_DIAG */
+
 #ifdef EFSYS_OPT_FALCON_NIC_CFG_OVERRIDE
 # error "FALCON_NIC_CFG_OVERRIDE is obsolete and is not supported."
 #endif
diff --git a/drivers/net/sfc/efx/base/efx_impl.h 
b/drivers/net/sfc/efx/base/efx_impl.h
index 97057e4..a7c6b29 100644
--- a/drivers/net/sfc/efx/base/efx_impl.h
+++ b/drivers/net/sfc/efx/base/efx_impl.h
@@ -271,6 +271,9 @@ typedef struct efx_nic_ops_s {
efx_rc_t(*eno_get_vi_pool)(efx_nic_t *, uint32_t *);
efx_rc_t(*eno_get_bar_region)(efx_nic_t *, efx_nic_region_t,
uint32_t *, size_t *);
+#if EFSYS_OPT_DIAG
+   efx_rc_t(*eno_register_test)(efx_nic_t *);
+#endif /* EFSYS_OPT_DIAG */
void(*eno_fini)(efx_nic_t *);
void(*eno_unprobe)(efx_nic_t *);
 } efx_nic_ops_t;
@@ -829,6 +832,32 @@ extern void
 efx_phy_unprobe(
__inefx_nic_t *enp);

+#if EFSYS_OPT_DIAG
+
+extern efx_sram_pattern_fn_t   

[dpdk-dev] [PATCH 10/56] net/sfc: import libefx SFN7xxx family support

2016-11-21 Thread Andrew Rybchenko
SFN7xxx is the first family based on EF10 architecture.

EFSYS_OPT_HUNTINGTON should be enabled to use it.

>From Solarflare Communications Inc.

Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/efx/base/ef10_ev.c | 1226 +++
 drivers/net/sfc/efx/base/ef10_filter.c | 1469 +++
 drivers/net/sfc/efx/base/ef10_impl.h   |  718 +++
 drivers/net/sfc/efx/base/ef10_intr.c   |  197 
 drivers/net/sfc/efx/base/ef10_mac.c|  446 +++
 drivers/net/sfc/efx/base/ef10_mcdi.c   |  342 ++
 drivers/net/sfc/efx/base/ef10_nic.c| 1769 
 drivers/net/sfc/efx/base/ef10_phy.c|  393 ++
 drivers/net/sfc/efx/base/ef10_rx.c |  397 +++
 drivers/net/sfc/efx/base/ef10_tlv_layout.h |  941 +++
 drivers/net/sfc/efx/base/ef10_tx.c |  683 +++
 drivers/net/sfc/efx/base/efx.h |   10 +
 drivers/net/sfc/efx/base/efx_check.h   |6 +
 drivers/net/sfc/efx/base/efx_ev.c  |   18 +
 drivers/net/sfc/efx/base/efx_filter.c  |   18 +
 drivers/net/sfc/efx/base/efx_impl.h|   36 +
 drivers/net/sfc/efx/base/efx_intr.c|   20 +
 drivers/net/sfc/efx/base/efx_mac.c |   22 +
 drivers/net/sfc/efx/base/efx_mcdi.c|  122 ++
 drivers/net/sfc/efx/base/efx_nic.c |   53 +
 drivers/net/sfc/efx/base/efx_phy.c |   15 +
 drivers/net/sfc/efx/base/efx_regs_ef10.h   |  571 +
 drivers/net/sfc/efx/base/efx_rx.c  |   20 +
 drivers/net/sfc/efx/base/efx_sram.c|   32 +
 drivers/net/sfc/efx/base/efx_tx.c  |   29 +
 drivers/net/sfc/efx/base/hunt_impl.h   |   74 ++
 drivers/net/sfc/efx/base/hunt_nic.c|  395 +++
 27 files changed, 10022 insertions(+)
 create mode 100644 drivers/net/sfc/efx/base/ef10_ev.c
 create mode 100644 drivers/net/sfc/efx/base/ef10_filter.c
 create mode 100644 drivers/net/sfc/efx/base/ef10_impl.h
 create mode 100644 drivers/net/sfc/efx/base/ef10_intr.c
 create mode 100644 drivers/net/sfc/efx/base/ef10_mac.c
 create mode 100644 drivers/net/sfc/efx/base/ef10_mcdi.c
 create mode 100644 drivers/net/sfc/efx/base/ef10_nic.c
 create mode 100644 drivers/net/sfc/efx/base/ef10_phy.c
 create mode 100644 drivers/net/sfc/efx/base/ef10_rx.c
 create mode 100644 drivers/net/sfc/efx/base/ef10_tlv_layout.h
 create mode 100644 drivers/net/sfc/efx/base/ef10_tx.c
 create mode 100644 drivers/net/sfc/efx/base/efx_regs_ef10.h
 create mode 100644 drivers/net/sfc/efx/base/hunt_impl.h
 create mode 100644 drivers/net/sfc/efx/base/hunt_nic.c

diff --git a/drivers/net/sfc/efx/base/ef10_ev.c 
b/drivers/net/sfc/efx/base/ef10_ev.c
new file mode 100644
index 000..46ecd42
--- /dev/null
+++ b/drivers/net/sfc/efx/base/ef10_ev.c
@@ -0,0 +1,1226 @@
+/*
+ * Copyright (c) 2012-2016 Solarflare Communications Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *this list of conditions and the following disclaimer in the documentation
+ *and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are
+ * those of the authors and should not be interpreted as representing official
+ * policies, either expressed or implied, of the FreeBSD Project.
+ */
+
+#include "efx.h"
+#include "efx_impl.h"
+
+#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD
+
+#defineEFX_EV_QSTAT_INCR(_eep, _stat)
+
+/*
+ * Non-interrupting event queue requires interrrupting event queue to
+ * refer to for wake-up events even if wake ups are never used.
+ * It could be even non-allocated event queue.
+ */
+#defineEFX_EF10_ALWAYS_INTERRUPTING_EVQ_INDEX  (0)
+
+static __checkReturn   boolean_t
+ef10_ev_rx(
+   __inefx_evq_t *eep,
+   __inefx_qword_t *eqp,
+   __in

[dpdk-dev] [PATCH 09/56] net/sfc: import libefx 5xxx/6xxx family support

2016-11-21 Thread Andrew Rybchenko
EFSYS_OPT_SIENA should be enabled to use it.

>From Solarflare Communications Inc.

Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/efx/base/efx_check.h   |   14 +
 drivers/net/sfc/efx/base/efx_ev.c  |  783 
 drivers/net/sfc/efx/base/efx_filter.c  | 1042 
 drivers/net/sfc/efx/base/efx_impl.h|   70 +++
 drivers/net/sfc/efx/base/efx_intr.c|  345 +++
 drivers/net/sfc/efx/base/efx_mac.c |   97 +++
 drivers/net/sfc/efx/base/efx_mcdi.c|   22 +
 drivers/net/sfc/efx/base/efx_nic.c |   44 ++
 drivers/net/sfc/efx/base/efx_phy.c |   15 +
 drivers/net/sfc/efx/base/efx_rx.c  |  417 +
 drivers/net/sfc/efx/base/efx_tx.c  |  488 +++
 drivers/net/sfc/efx/base/siena_flash.h |  215 +++
 drivers/net/sfc/efx/base/siena_impl.h  |  179 ++
 drivers/net/sfc/efx/base/siena_mac.c   |  205 +++
 drivers/net/sfc/efx/base/siena_mcdi.c  |  263 
 drivers/net/sfc/efx/base/siena_nic.c   |  357 +++
 drivers/net/sfc/efx/base/siena_phy.c   |  375 
 drivers/net/sfc/efx/base/siena_sram.c  |   74 +++
 18 files changed, 5005 insertions(+)
 create mode 100644 drivers/net/sfc/efx/base/siena_flash.h
 create mode 100644 drivers/net/sfc/efx/base/siena_impl.h
 create mode 100644 drivers/net/sfc/efx/base/siena_mac.c
 create mode 100644 drivers/net/sfc/efx/base/siena_mcdi.c
 create mode 100644 drivers/net/sfc/efx/base/siena_nic.c
 create mode 100644 drivers/net/sfc/efx/base/siena_phy.c
 create mode 100644 drivers/net/sfc/efx/base/siena_sram.c

diff --git a/drivers/net/sfc/efx/base/efx_check.h 
b/drivers/net/sfc/efx/base/efx_check.h
index 470f73c..190ac46 100644
--- a/drivers/net/sfc/efx/base/efx_check.h
+++ b/drivers/net/sfc/efx/base/efx_check.h
@@ -47,12 +47,16 @@

 #if EFSYS_OPT_CHECK_REG
 /* Verify chip implements accessed registers */
+# if !(EFSYS_OPT_SIENA || EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD)
 #  error "CHECK_REG requires SIENA or HUNTINGTON or MEDFORD"
+# endif
 #endif /* EFSYS_OPT_CHECK_REG */

 #if EFSYS_OPT_DECODE_INTR_FATAL
 /* Decode fatal errors */
+# if !EFSYS_OPT_SIENA
 #  error "INTR_FATAL requires SIENA"
+# endif
 #endif /* EFSYS_OPT_DECODE_INTR_FATAL */

 #ifdef EFSYS_OPT_FALCON_NIC_CFG_OVERRIDE
@@ -61,7 +65,9 @@

 #if EFSYS_OPT_FILTER
 /* Support hardware packet filters */
+# if !(EFSYS_OPT_SIENA || EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD)
 #  error "FILTER requires SIENA or HUNTINGTON or MEDFORD"
+# endif
 #endif /* EFSYS_OPT_FILTER */

 #ifdef EFSYS_OPT_MAC_FALCON_GMAC
@@ -74,9 +80,17 @@

 #if EFSYS_OPT_MCDI
 /* Support management controller messages */
+# if !(EFSYS_OPT_SIENA || EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD)
 #  error "MCDI requires SIENA or HUNTINGTON or MEDFORD"
+# endif
 #endif /* EFSYS_OPT_MCDI */

+#if (EFSYS_OPT_SIENA || EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD)
+# if !EFSYS_OPT_MCDI
+#  error "SIENA or HUNTINGTON or MEDFORD requires MCDI"
+# endif
+#endif
+
 #if EFSYS_OPT_MCDI_LOGGING
 /* Support MCDI logging */
 # if !EFSYS_OPT_MCDI
diff --git a/drivers/net/sfc/efx/base/efx_ev.c 
b/drivers/net/sfc/efx/base/efx_ev.c
index 942dac6..59f4d02 100644
--- a/drivers/net/sfc/efx/base/efx_ev.c
+++ b/drivers/net/sfc/efx/base/efx_ev.c
@@ -39,6 +39,61 @@



+#if EFSYS_OPT_SIENA
+
+static __checkReturn   efx_rc_t
+siena_ev_init(
+   __inefx_nic_t *enp);
+
+static void
+siena_ev_fini(
+   __inefx_nic_t *enp);
+
+static __checkReturn   efx_rc_t
+siena_ev_qcreate(
+   __inefx_nic_t *enp,
+   __inunsigned int index,
+   __inefsys_mem_t *esmp,
+   __insize_t n,
+   __inuint32_t id,
+   __inuint32_t us,
+   __inuint32_t flags,
+   __inefx_evq_t *eep);
+
+static void
+siena_ev_qdestroy(
+   __inefx_evq_t *eep);
+
+static __checkReturn   efx_rc_t
+siena_ev_qprime(
+   __inefx_evq_t *eep,
+   __inunsigned int count);
+
+static void
+siena_ev_qpost(
+   __inefx_evq_t *eep,
+   __inuint16_t data);
+
+static __checkReturn   efx_rc_t
+siena_ev_qmoderate(
+   __inefx_evq_t *eep,
+   __inunsigned int us);
+
+#endif /* EFSYS_OPT_SIENA */
+
+#if EFSYS_OPT_SIENA
+static const efx_ev_ops_t  __efx_ev_siena_ops = {
+   siena_ev_init,  /* eevo_init */
+   siena_ev_fini,  /* eevo_fini */
+   siena_ev_qcreate,   /* eevo_qcreate */
+   siena_ev_qdestroy,  /* eevo_qdestroy */
+   siena_ev_qprime,/* eevo_qprime */
+   siena_ev_qpost, /* eevo_qpost */
+   siena_ev_qmoderate, /* eevo_qmoderate */
+};
+#endif /* EFSYS_OPT_SIENA */
+
+
__checkReturn   efx_rc_t
 efx_ev_init(
__in  

[dpdk-dev] [PATCH 08/56] net/sfc: import libefx MCDI proxy authorization support

2016-11-21 Thread Andrew Rybchenko
MCDI proxy authorization may be used if priviledged PCI
function (physical function) would like to intercept and
authorize MCDI requests done by unprivileged (e.g. virtual)
PCI function. It may be used to control unpriviledged
function Rx mode (e.g. promicsuous, all-multicast), MTU
and default MAC address change requests etc.

Current libefx support is limited to client-side which
is required to work when function requests need to be
authorized.

Server side support required to request and do the
authorization is not implemented yet.

EFSYS_OPT_MCDI_PROXY_AUTH should be enabled to use it.

>From Solarflare Communications Inc.

Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/efx/base/efx.h   |  3 ++
 drivers/net/sfc/efx/base/efx_check.h |  7 
 drivers/net/sfc/efx/base/efx_mcdi.c  | 74 
 drivers/net/sfc/efx/base/efx_mcdi.h  | 17 +
 4 files changed, 101 insertions(+)

diff --git a/drivers/net/sfc/efx/base/efx.h b/drivers/net/sfc/efx/base/efx.h
index 0ca0156..3899580 100644
--- a/drivers/net/sfc/efx/base/efx.h
+++ b/drivers/net/sfc/efx/base/efx.h
@@ -209,6 +209,9 @@ typedef struct efx_mcdi_transport_s {
void(*emt_logger)(void *, efx_log_msg_t,
void *, size_t, void *, size_t);
 #endif /* EFSYS_OPT_MCDI_LOGGING */
+#if EFSYS_OPT_MCDI_PROXY_AUTH
+   void(*emt_ev_proxy_response)(void *, uint32_t, efx_rc_t);
+#endif /* EFSYS_OPT_MCDI_PROXY_AUTH */
 } efx_mcdi_transport_t;

 extern __checkReturn   efx_rc_t
diff --git a/drivers/net/sfc/efx/base/efx_check.h 
b/drivers/net/sfc/efx/base/efx_check.h
index 228b42c..470f73c 100644
--- a/drivers/net/sfc/efx/base/efx_check.h
+++ b/drivers/net/sfc/efx/base/efx_check.h
@@ -84,6 +84,13 @@
 # endif
 #endif /* EFSYS_OPT_MCDI_LOGGING */

+#if EFSYS_OPT_MCDI_PROXY_AUTH
+/* Support MCDI proxy authorization */
+# if !EFSYS_OPT_MCDI
+#  error "MCDI_PROXY_AUTH requires MCDI"
+# endif
+#endif /* EFSYS_OPT_MCDI_PROXY_AUTH */
+
 #ifdef EFSYS_OPT_MON_LM87
 # error "MON_LM87 is obsolete and is not supported."
 #endif
diff --git a/drivers/net/sfc/efx/base/efx_mcdi.c 
b/drivers/net/sfc/efx/base/efx_mcdi.c
index 59a16fc..7b82096 100644
--- a/drivers/net/sfc/efx/base/efx_mcdi.c
+++ b/drivers/net/sfc/efx/base/efx_mcdi.c
@@ -352,6 +352,21 @@ efx_mcdi_read_response_header(
emrp->emr_err_code = err_code;
emrp->emr_err_arg = err_arg;

+#if EFSYS_OPT_MCDI_PROXY_AUTH
+   if ((err_code == MC_CMD_ERR_PROXY_PENDING) &&
+   (err_len == sizeof (err))) {
+   /*
+* The MCDI request would normally fail with EPERM, but
+* firmware has forwarded it to an authorization agent
+* attached to a privileged PF.
+*
+* Save the authorization request handle. The client
+* must wait for a PROXY_RESPONSE event, or timeout.
+*/
+   emrp->emr_proxy_handle = err_arg;
+   }
+#endif /* EFSYS_OPT_MCDI_PROXY_AUTH */
+
 #if EFSYS_OPT_MCDI_LOGGING
if (emtp->emt_logger != NULL) {
emtp->emt_logger(emtp->emt_context,
@@ -372,6 +387,9 @@ efx_mcdi_read_response_header(

emrp->emr_rc = 0;
emrp->emr_out_length_used = data_len;
+#if EFSYS_OPT_MCDI_PROXY_AUTH
+   emrp->emr_proxy_handle = 0;
+#endif /* EFSYS_OPT_MCDI_PROXY_AUTH */
return;

 fail3:
@@ -732,6 +750,62 @@ efx_mcdi_ev_cpl(
emtp->emt_ev_cpl(emtp->emt_context);
 }

+#if EFSYS_OPT_MCDI_PROXY_AUTH
+
+   __checkReturn   efx_rc_t
+efx_mcdi_get_proxy_handle(
+   __inefx_nic_t *enp,
+   __inefx_mcdi_req_t *emrp,
+   __out   uint32_t *handlep)
+{
+   efx_rc_t rc;
+
+   /*
+* Return proxy handle from MCDI request that returned with error
+* MC_MCD_ERR_PROXY_PENDING. This handle is used to wait for a matching
+* PROXY_RESPONSE event.
+*/
+   if ((emrp == NULL) || (handlep == NULL)) {
+   rc = EINVAL;
+   goto fail1;
+   }
+   if ((emrp->emr_rc != 0) &&
+   (emrp->emr_err_code == MC_CMD_ERR_PROXY_PENDING)) {
+   *handlep = emrp->emr_proxy_handle;
+   rc = 0;
+   } else {
+   *handlep = 0;
+   rc = ENOENT;
+   }
+   return (rc);
+
+fail1:
+   EFSYS_PROBE1(fail1, efx_rc_t, rc);
+   return (rc);
+}
+
+   void
+efx_mcdi_ev_proxy_response(
+   __inefx_nic_t *enp,
+   __inunsigned int handle,
+   __inunsigned int status)
+{
+   const efx_mcdi_transport_t *emtp = enp->en_mcdi.em_emtp;
+   efx_rc_t rc;
+
+   /*
+* Handle results of an authorization request for a privileged MCDI
+* command. If authorization was granted then we 

[dpdk-dev] [PATCH 07/56] net/sfc: import libefx MCDI logging support

2016-11-21 Thread Andrew Rybchenko
Driver can provide a function to be called to log MCDI
requests and responses to help with debugging.

Solarflare netlogdecode cross-platform tool may be used
to decode these logs.

EFSYS_OPT_MCDI_LOGGING should be enabled to use it.

>From Solarflare Communications Inc.

Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/efx/base/efx.h   | 12 
 drivers/net/sfc/efx/base/efx_check.h |  7 +++
 drivers/net/sfc/efx/base/efx_mcdi.c  | 34 ++
 3 files changed, 53 insertions(+)

diff --git a/drivers/net/sfc/efx/base/efx.h b/drivers/net/sfc/efx/base/efx.h
index 8b9d4d1..0ca0156 100644
--- a/drivers/net/sfc/efx/base/efx.h
+++ b/drivers/net/sfc/efx/base/efx.h
@@ -191,12 +191,24 @@ typedef enum efx_mcdi_exception_e {
EFX_MCDI_EXCEPTION_MC_BADASSERT,
 } efx_mcdi_exception_t;

+#if EFSYS_OPT_MCDI_LOGGING
+typedef enum efx_log_msg_e {
+   EFX_LOG_INVALID,
+   EFX_LOG_MCDI_REQUEST,
+   EFX_LOG_MCDI_RESPONSE,
+} efx_log_msg_t;
+#endif /* EFSYS_OPT_MCDI_LOGGING */
+
 typedef struct efx_mcdi_transport_s {
void*emt_context;
efsys_mem_t *emt_dma_mem;
void(*emt_execute)(void *, efx_mcdi_req_t *);
void(*emt_ev_cpl)(void *);
void(*emt_exception)(void *, efx_mcdi_exception_t);
+#if EFSYS_OPT_MCDI_LOGGING
+   void(*emt_logger)(void *, efx_log_msg_t,
+   void *, size_t, void *, size_t);
+#endif /* EFSYS_OPT_MCDI_LOGGING */
 } efx_mcdi_transport_t;

 extern __checkReturn   efx_rc_t
diff --git a/drivers/net/sfc/efx/base/efx_check.h 
b/drivers/net/sfc/efx/base/efx_check.h
index 9d0e988..228b42c 100644
--- a/drivers/net/sfc/efx/base/efx_check.h
+++ b/drivers/net/sfc/efx/base/efx_check.h
@@ -77,6 +77,13 @@
 #  error "MCDI requires SIENA or HUNTINGTON or MEDFORD"
 #endif /* EFSYS_OPT_MCDI */

+#if EFSYS_OPT_MCDI_LOGGING
+/* Support MCDI logging */
+# if !EFSYS_OPT_MCDI
+#  error "MCDI_LOGGING requires MCDI"
+# endif
+#endif /* EFSYS_OPT_MCDI_LOGGING */
+
 #ifdef EFSYS_OPT_MON_LM87
 # error "MON_LM87 is obsolete and is not supported."
 #endif
diff --git a/drivers/net/sfc/efx/base/efx_mcdi.c 
b/drivers/net/sfc/efx/base/efx_mcdi.c
index 643ba6a..59a16fc 100644
--- a/drivers/net/sfc/efx/base/efx_mcdi.c
+++ b/drivers/net/sfc/efx/base/efx_mcdi.c
@@ -192,6 +192,9 @@ efx_mcdi_request_start(
__inefx_mcdi_req_t *emrp,
__inboolean_t ev_cpl)
 {
+#if EFSYS_OPT_MCDI_LOGGING
+   const efx_mcdi_transport_t *emtp = enp->en_mcdi.em_emtp;
+#endif
efx_mcdi_iface_t *emip = &(enp->en_mcdi.em_emip);
efx_dword_t hdr[2];
size_t hdr_len;
@@ -268,6 +271,14 @@ efx_mcdi_request_start(
MCDI_HEADER_XFLAGS, xflags);
}

+#if EFSYS_OPT_MCDI_LOGGING
+   if (emtp->emt_logger != NULL) {
+   emtp->emt_logger(emtp->emt_context, EFX_LOG_MCDI_REQUEST,
+   [0], hdr_len,
+   emrp->emr_in_buf, emrp->emr_in_length);
+   }
+#endif /* EFSYS_OPT_MCDI_LOGGING */
+
efx_mcdi_send_request(enp, [0], hdr_len,
emrp->emr_in_buf, emrp->emr_in_length);
 }
@@ -278,6 +289,9 @@ efx_mcdi_read_response_header(
__inefx_nic_t *enp,
__inout efx_mcdi_req_t *emrp)
 {
+#if EFSYS_OPT_MCDI_LOGGING
+   const efx_mcdi_transport_t *emtp = enp->en_mcdi.em_emtp;
+#endif /* EFSYS_OPT_MCDI_LOGGING */
efx_mcdi_iface_t *emip = &(enp->en_mcdi.em_emip);
efx_dword_t hdr[2];
unsigned int hdr_len;
@@ -338,6 +352,15 @@ efx_mcdi_read_response_header(
emrp->emr_err_code = err_code;
emrp->emr_err_arg = err_arg;

+#if EFSYS_OPT_MCDI_LOGGING
+   if (emtp->emt_logger != NULL) {
+   emtp->emt_logger(emtp->emt_context,
+   EFX_LOG_MCDI_RESPONSE,
+   [0], hdr_len,
+   [0], err_len);
+   }
+#endif /* EFSYS_OPT_MCDI_LOGGING */
+
if (!emrp->emr_quiet) {
EFSYS_PROBE3(mcdi_err_arg, int, emrp->emr_cmd,
int, err_code, int, err_arg);
@@ -363,6 +386,9 @@ efx_mcdi_finish_response(
__inefx_nic_t *enp,
__inefx_mcdi_req_t *emrp)
 {
+#if EFSYS_OPT_MCDI_LOGGING
+   const efx_mcdi_transport_t *emtp = enp->en_mcdi.em_emtp;
+#endif /* EFSYS_OPT_MCDI_LOGGING */
efx_dword_t hdr[2];
unsigned int hdr_len;
size_t bytes;
@@ -389,6 +415,14 @@ efx_mcdi_finish_response(
bytes = MIN(emrp->emr_out_length_used, emrp->emr_out_length);
efx_mcdi_read_response(enp, emrp->emr_out_buf, hdr_len, bytes);

+#if EFSYS_OPT_MCDI_LOGGING
+   if (emtp->emt_logger != NULL) {
+   emtp->emt_logger(emtp->emt_context,
+   EFX_LOG_MCDI_RESPONSE,
+   [0], hdr_len,
+   

[dpdk-dev] [PATCH 06/56] net/sfc: import libefx MCDI implementation

2016-11-21 Thread Andrew Rybchenko
Implement interface to talk to NIC managment CPU. Provide
helpers to fill in MCDI requests, execute it and process
recevied response.

MCDI request is prepared in either PCI BAR mapped memory
(SFN5xxx/SFN6xxx) or DMA-mapped memory (SFN7xxx/SFN8xxx) and,
doorbell is pressed (memory-mapped register) to execute it.

Events about MCDI completion are delivered to house-keeping
event queue, but usage of these events is optional and MCDI
buffer may be simply polled waiting for completion
indication set.

>From Solarflare Communications Inc.

Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/efx/base/efx.h   |   59 ++
 drivers/net/sfc/efx/base/efx_check.h |5 +
 drivers/net/sfc/efx/base/efx_ev.c|   10 +
 drivers/net/sfc/efx/base/efx_impl.h  |   47 +
 drivers/net/sfc/efx/base/efx_mcdi.c  | 1725 ++
 drivers/net/sfc/efx/base/efx_mcdi.h  |  371 
 drivers/net/sfc/efx/base/efx_nic.c   |6 +
 7 files changed, 2223 insertions(+)
 create mode 100644 drivers/net/sfc/efx/base/efx_mcdi.c
 create mode 100644 drivers/net/sfc/efx/base/efx_mcdi.h

diff --git a/drivers/net/sfc/efx/base/efx.h b/drivers/net/sfc/efx/base/efx.h
index 485ce51..8b9d4d1 100644
--- a/drivers/net/sfc/efx/base/efx.h
+++ b/drivers/net/sfc/efx/base/efx.h
@@ -182,6 +182,62 @@ efx_nic_check_pcie_link_speed(
__inuint32_t pcie_link_gen,
__out   efx_pcie_link_performance_t *resultp);

+#if EFSYS_OPT_MCDI
+
+typedef struct efx_mcdi_req_s efx_mcdi_req_t;
+
+typedef enum efx_mcdi_exception_e {
+   EFX_MCDI_EXCEPTION_MC_REBOOT,
+   EFX_MCDI_EXCEPTION_MC_BADASSERT,
+} efx_mcdi_exception_t;
+
+typedef struct efx_mcdi_transport_s {
+   void*emt_context;
+   efsys_mem_t *emt_dma_mem;
+   void(*emt_execute)(void *, efx_mcdi_req_t *);
+   void(*emt_ev_cpl)(void *);
+   void(*emt_exception)(void *, efx_mcdi_exception_t);
+} efx_mcdi_transport_t;
+
+extern __checkReturn   efx_rc_t
+efx_mcdi_init(
+   __inefx_nic_t *enp,
+   __inconst efx_mcdi_transport_t *mtp);
+
+extern __checkReturn   efx_rc_t
+efx_mcdi_reboot(
+   __inefx_nic_t *enp);
+
+   void
+efx_mcdi_new_epoch(
+   __inefx_nic_t *enp);
+
+extern void
+efx_mcdi_get_timeout(
+   __inefx_nic_t *enp,
+   __inefx_mcdi_req_t *emrp,
+   __out   uint32_t *usec_timeoutp);
+
+extern void
+efx_mcdi_request_start(
+   __inefx_nic_t *enp,
+   __inefx_mcdi_req_t *emrp,
+   __inboolean_t ev_cpl);
+
+extern __checkReturn   boolean_t
+efx_mcdi_request_poll(
+   __inefx_nic_t *enp);
+
+extern __checkReturn   boolean_t
+efx_mcdi_request_abort(
+   __inefx_nic_t *enp);
+
+extern void
+efx_mcdi_fini(
+   __inefx_nic_t *enp);
+
+#endif /* EFSYS_OPT_MCDI */
+
 /* INTR */

 #defineEFX_NINTR_SIENA 1024
@@ -507,6 +563,9 @@ typedef struct efx_nic_cfg_s {
uint32_tenc_rx_prefix_size;
uint32_tenc_rx_buf_align_start;
uint32_tenc_rx_buf_align_end;
+#if EFSYS_OPT_MCDI
+   uint8_t enc_mcdi_mdio_channel;
+#endif /* EFSYS_OPT_MCDI */
boolean_t   enc_bug26807_workaround;
boolean_t   enc_bug35388_workaround;
boolean_t   enc_bug41750_workaround;
diff --git a/drivers/net/sfc/efx/base/efx_check.h 
b/drivers/net/sfc/efx/base/efx_check.h
index 555c184..9d0e988 100644
--- a/drivers/net/sfc/efx/base/efx_check.h
+++ b/drivers/net/sfc/efx/base/efx_check.h
@@ -72,6 +72,11 @@
 # error "MAC_FALCON_XMAC is obsolete and is not supported."
 #endif

+#if EFSYS_OPT_MCDI
+/* Support management controller messages */
+#  error "MCDI requires SIENA or HUNTINGTON or MEDFORD"
+#endif /* EFSYS_OPT_MCDI */
+
 #ifdef EFSYS_OPT_MON_LM87
 # error "MON_LM87 is obsolete and is not supported."
 #endif
diff --git a/drivers/net/sfc/efx/base/efx_ev.c 
b/drivers/net/sfc/efx/base/efx_ev.c
index 2bd365f..942dac6 100644
--- a/drivers/net/sfc/efx/base/efx_ev.c
+++ b/drivers/net/sfc/efx/base/efx_ev.c
@@ -270,6 +270,10 @@ efx_ev_qpoll(
EFX_STATIC_ASSERT(ESE_DZ_EV_CODE_DRIVER_EV == FSE_AZ_EV_CODE_DRIVER_EV);
EFX_STATIC_ASSERT(ESE_DZ_EV_CODE_DRV_GEN_EV ==
FSE_AZ_EV_CODE_DRV_GEN_EV);
+#if EFSYS_OPT_MCDI
+   EFX_STATIC_ASSERT(ESE_DZ_EV_CODE_MCDI_EV ==
+   FSE_AZ_EV_CODE_MCDI_EVRESPONSE);
+#endif

EFSYS_ASSERT3U(eep->ee_magic, ==, EFX_EVQ_MAGIC);
EFSYS_ASSERT(countp != NULL);
@@ -318,6 +322,12 @@ efx_ev_qpoll(
should_abort = eep->ee_drv_gen(eep,
&(ev[index]), eecp, arg);
break;
+#if EFSYS_OPT_MCDI
+   case 

[dpdk-dev] [PATCH 04/56] net/sfc: import libefx filters support

2016-11-21 Thread Andrew Rybchenko
Filtering capabilities depend on NIC family and used firmware
variant. Provided API allows to get supported filter types
(in a priority order), add/delete individual filters and
restore entire filter table after, for example, NIC management
CPU reboot.

Rx filters allow to redirect matching flow to specified Rx queue.

Tx filters allow to control generated traffic (e.g. to implement
virtual function anti-spoofing control).

EFSYS_OPT_FILTER should be enabled to use it. It is required
for SFN7xxx and SFN8xxx adapter families support.

>From Solarflare Communications Inc.

Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/efx/base/efx.h| 157 
 drivers/net/sfc/efx/base/efx_check.h  |   5 +
 drivers/net/sfc/efx/base/efx_filter.c | 332 ++
 drivers/net/sfc/efx/base/efx_impl.h   |  38 
 4 files changed, 532 insertions(+)
 create mode 100644 drivers/net/sfc/efx/base/efx_filter.c

diff --git a/drivers/net/sfc/efx/base/efx.h b/drivers/net/sfc/efx/base/efx.h
index 79c6fdc..485ce51 100644
--- a/drivers/net/sfc/efx/base/efx.h
+++ b/drivers/net/sfc/efx/base/efx.h
@@ -1044,6 +1044,163 @@ efx_tx_qdestroy(

 /* FILTER */

+#if EFSYS_OPT_FILTER
+
+#defineEFX_ETHER_TYPE_IPV4 0x0800
+#defineEFX_ETHER_TYPE_IPV6 0x86DD
+
+#defineEFX_IPPROTO_TCP 6
+#defineEFX_IPPROTO_UDP 17
+
+typedef enum efx_filter_flag_e {
+   EFX_FILTER_FLAG_RX_RSS = 0x01,  /* use RSS to spread across
+* multiple queues */
+   EFX_FILTER_FLAG_RX_SCATTER = 0x02,  /* enable RX scatter */
+   EFX_FILTER_FLAG_RX_OVER_AUTO = 0x04,/* Override an automatic filter
+* (priority 
EFX_FILTER_PRI_AUTO).
+* May only be set by the filter
+* implementation for each type.
+* A removal request will
+* restore the automatic filter
+* in its place. */
+   EFX_FILTER_FLAG_RX = 0x08,  /* Filter is for RX */
+   EFX_FILTER_FLAG_TX = 0x10,  /* Filter is for TX */
+} efx_filter_flag_t;
+
+typedef enum efx_filter_match_flags_e {
+   EFX_FILTER_MATCH_REM_HOST = 0x0001, /* Match by remote IP host
+* address */
+   EFX_FILTER_MATCH_LOC_HOST = 0x0002, /* Match by local IP host
+* address */
+   EFX_FILTER_MATCH_REM_MAC = 0x0004,  /* Match by remote MAC address 
*/
+   EFX_FILTER_MATCH_REM_PORT = 0x0008, /* Match by remote TCP/UDP port 
*/
+   EFX_FILTER_MATCH_LOC_MAC = 0x0010,  /* Match by remote TCP/UDP port 
*/
+   EFX_FILTER_MATCH_LOC_PORT = 0x0020, /* Match by local TCP/UDP port 
*/
+   EFX_FILTER_MATCH_ETHER_TYPE = 0x0040,   /* Match by Ether-type */
+   EFX_FILTER_MATCH_INNER_VID = 0x0080,/* Match by inner VLAN ID */
+   EFX_FILTER_MATCH_OUTER_VID = 0x0100,/* Match by outer VLAN ID */
+   EFX_FILTER_MATCH_IP_PROTO = 0x0200, /* Match by IP transport
+* protocol */
+   EFX_FILTER_MATCH_LOC_MAC_IG = 0x0400,   /* Match by local MAC address
+* I/G bit. Used for RX default
+* unicast and multicast/
+* broadcast filters. */
+} efx_filter_match_flags_t;
+
+typedef enum efx_filter_priority_s {
+   EFX_FILTER_PRI_HINT = 0,/* Performance hint */
+   EFX_FILTER_PRI_AUTO,/* Automatic filter based on device
+* address list or hardware
+* requirements. This may only be used
+* by the filter implementation for
+* each NIC type. */
+   EFX_FILTER_PRI_MANUAL,  /* Manually configured filter */
+   EFX_FILTER_PRI_REQUIRED,/* Required for correct behaviour of the
+* client (e.g. SR-IOV, HyperV VMQ etc.)
+*/
+} efx_filter_priority_t;
+
+/*
+ * FIXME: All these fields are assumed to be in little-endian byte order.
+ * It may be better for some to be big-endian. See bug42804.
+ */
+
+typedef struct efx_filter_spec_s {
+   uint32_tefs_match_flags:12;
+   uint32_tefs_priority:2;
+   uint32_tefs_flags:6;
+   uint32_tefs_dmaq_id:12;
+   uint32_tefs_rss_context;
+   uint16_tefs_outer_vid;
+   uint16_tefs_inner_vid;
+   uint8_t efs_loc_mac[EFX_MAC_ADDR_LEN];
+   uint8_t 

[dpdk-dev] [PATCH 03/56] net/sfc: import libefx register definitions

2016-11-21 Thread Andrew Rybchenko
>From Solarflare Communications Inc.

Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/efx/base/efx_regs.h | 3870 +++
 drivers/net/sfc/efx/base/efx_regs_pci.h | 2356 +++
 2 files changed, 6226 insertions(+)
 create mode 100644 drivers/net/sfc/efx/base/efx_regs.h
 create mode 100644 drivers/net/sfc/efx/base/efx_regs_pci.h

diff --git a/drivers/net/sfc/efx/base/efx_regs.h 
b/drivers/net/sfc/efx/base/efx_regs.h
new file mode 100644
index 000..a1a7f9d
--- /dev/null
+++ b/drivers/net/sfc/efx/base/efx_regs.h
@@ -0,0 +1,3870 @@
+/*
+ * Copyright (c) 2007-2016 Solarflare Communications Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *this list of conditions and the following disclaimer in the documentation
+ *and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are
+ * those of the authors and should not be interpreted as representing official
+ * policies, either expressed or implied, of the FreeBSD Project.
+ */
+
+#ifndef_SYS_EFX_REGS_H
+#define_SYS_EFX_REGS_H
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/**
+ *
+ * Falcon/Siena registers and descriptors
+ *
+ **
+ */
+
+/*
+ * FR_AB_EE_VPD_CFG0_REG_SF(128bit):
+ * SPI/VPD configuration register 0
+ */
+#defineFR_AB_EE_VPD_CFG0_REG_SF_OFST 0x0300
+/* falcona0,falconb0=eeprom_flash */
+/*
+ * FR_AB_EE_VPD_CFG0_REG(128bit):
+ * SPI/VPD configuration register 0
+ */
+#defineFR_AB_EE_VPD_CFG0_REG_OFST 0x0140
+/* falcona0,falconb0=net_func_bar2,falcona0=char_func_bar0 */
+
+#defineFRF_AB_EE_SF_FASTRD_EN_LBN 127
+#defineFRF_AB_EE_SF_FASTRD_EN_WIDTH 1
+#defineFRF_AB_EE_SF_CLOCK_DIV_LBN 120
+#defineFRF_AB_EE_SF_CLOCK_DIV_WIDTH 7
+#defineFRF_AB_EE_VPD_WIP_POLL_LBN 119
+#defineFRF_AB_EE_VPD_WIP_POLL_WIDTH 1
+#defineFRF_AB_EE_EE_CLOCK_DIV_LBN 112
+#defineFRF_AB_EE_EE_CLOCK_DIV_WIDTH 7
+#defineFRF_AB_EE_EE_WR_TMR_VALUE_LBN 96
+#defineFRF_AB_EE_EE_WR_TMR_VALUE_WIDTH 16
+#defineFRF_AB_EE_VPDW_LENGTH_LBN 80
+#defineFRF_AB_EE_VPDW_LENGTH_WIDTH 15
+#defineFRF_AB_EE_VPDW_BASE_LBN 64
+#defineFRF_AB_EE_VPDW_BASE_WIDTH 15
+#defineFRF_AB_EE_VPD_WR_CMD_EN_LBN 56
+#defineFRF_AB_EE_VPD_WR_CMD_EN_WIDTH 8
+#defineFRF_AB_EE_VPD_BASE_LBN 32
+#defineFRF_AB_EE_VPD_BASE_WIDTH 24
+#defineFRF_AB_EE_VPD_LENGTH_LBN 16
+#defineFRF_AB_EE_VPD_LENGTH_WIDTH 15
+#defineFRF_AB_EE_VPD_AD_SIZE_LBN 8
+#defineFRF_AB_EE_VPD_AD_SIZE_WIDTH 5
+#defineFRF_AB_EE_VPD_ACCESS_ON_LBN 5
+#defineFRF_AB_EE_VPD_ACCESS_ON_WIDTH 1
+#defineFRF_AB_EE_VPD_ACCESS_BLOCK_LBN 4
+#defineFRF_AB_EE_VPD_ACCESS_BLOCK_WIDTH 1
+#defineFRF_AB_EE_VPD_DEV_SF_SEL_LBN 2
+#defineFRF_AB_EE_VPD_DEV_SF_SEL_WIDTH 1
+#defineFRF_AB_EE_VPD_EN_AD9_MODE_LBN 1
+#defineFRF_AB_EE_VPD_EN_AD9_MODE_WIDTH 1
+#defineFRF_AB_EE_VPD_EN_LBN 0
+#defineFRF_AB_EE_VPD_EN_WIDTH 1
+
+
+/*
+ * FR_AB_PCIE_SD_CTL0123_REG_SF(128bit):
+ * PCIE SerDes control register 0 to 3
+ */
+#defineFR_AB_PCIE_SD_CTL0123_REG_SF_OFST 0x0320
+/* falcona0,falconb0=eeprom_flash */
+/*
+ * FR_AB_PCIE_SD_CTL0123_REG(128bit):
+ * PCIE SerDes control register 0 to 3
+ */
+#defineFR_AB_PCIE_SD_CTL0123_REG_OFST 0x0320
+/* falcona0,falconb0=net_func_bar2,falcona0=char_func_bar0 */
+
+#defineFRF_AB_PCIE_TESTSIG_H_LBN 96
+#defineFRF_AB_PCIE_TESTSIG_H_WIDTH 19
+#defineFRF_AB_PCIE_TESTSIG_L_LBN 64
+#define

[dpdk-dev] [PATCH 02/56] net/sfc: import libefx base

2016-11-21 Thread Andrew Rybchenko
libefx is a platform-independent library to implement drivers
for Solarflare network adapters. It provides unified adapter
family independent interface (if possible).

Driver must provide efsys.h header which defines options
(EFSYS_OPT_*) to be used and macros/functions to allocate
memory, read/write DMA-mapped memory, read/write PCI BAR
space, locks, barriers etc.

efx.h and efx_types.h provide external interfaces intended
to be used by drivers. Other header files are internal.

>From Solarflare Communications Inc.

Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/efx/base/README|   36 +
 drivers/net/sfc/efx/base/efx.h | 1067 +
 drivers/net/sfc/efx/base/efx_check.h   |  171 
 drivers/net/sfc/efx/base/efx_crc32.c   |  122 +++
 drivers/net/sfc/efx/base/efx_ev.c  |  432 +
 drivers/net/sfc/efx/base/efx_hash.c|  328 +++
 drivers/net/sfc/efx/base/efx_impl.h|  658 +
 drivers/net/sfc/efx/base/efx_intr.c|  201 
 drivers/net/sfc/efx/base/efx_mac.c |  489 ++
 drivers/net/sfc/efx/base/efx_mon.c |  118 +++
 drivers/net/sfc/efx/base/efx_nic.c |  549 +++
 drivers/net/sfc/efx/base/efx_phy.c |  248 +
 drivers/net/sfc/efx/base/efx_phy_ids.h |   51 +
 drivers/net/sfc/efx/base/efx_port.c|  151 +++
 drivers/net/sfc/efx/base/efx_rx.c  |  242 +
 drivers/net/sfc/efx/base/efx_sram.c|  168 
 drivers/net/sfc/efx/base/efx_tx.c  |  463 +
 drivers/net/sfc/efx/base/efx_types.h   | 1647 
 18 files changed, 7141 insertions(+)
 create mode 100644 drivers/net/sfc/efx/base/README
 create mode 100644 drivers/net/sfc/efx/base/efx.h
 create mode 100644 drivers/net/sfc/efx/base/efx_check.h
 create mode 100644 drivers/net/sfc/efx/base/efx_crc32.c
 create mode 100644 drivers/net/sfc/efx/base/efx_ev.c
 create mode 100644 drivers/net/sfc/efx/base/efx_hash.c
 create mode 100644 drivers/net/sfc/efx/base/efx_impl.h
 create mode 100644 drivers/net/sfc/efx/base/efx_intr.c
 create mode 100644 drivers/net/sfc/efx/base/efx_mac.c
 create mode 100644 drivers/net/sfc/efx/base/efx_mon.c
 create mode 100644 drivers/net/sfc/efx/base/efx_nic.c
 create mode 100644 drivers/net/sfc/efx/base/efx_phy.c
 create mode 100644 drivers/net/sfc/efx/base/efx_phy_ids.h
 create mode 100644 drivers/net/sfc/efx/base/efx_port.c
 create mode 100644 drivers/net/sfc/efx/base/efx_rx.c
 create mode 100644 drivers/net/sfc/efx/base/efx_sram.c
 create mode 100644 drivers/net/sfc/efx/base/efx_tx.c
 create mode 100644 drivers/net/sfc/efx/base/efx_types.h

diff --git a/drivers/net/sfc/efx/base/README b/drivers/net/sfc/efx/base/README
new file mode 100644
index 000..9019e8b
--- /dev/null
+++ b/drivers/net/sfc/efx/base/README
@@ -0,0 +1,36 @@
+
+   Copyright (c) 2006-2016 Solarflare Communications Inc.
+   All rights reserved.
+
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions are met:
+
+   1. Redistributions of source code must retain the above copyright notice,
+  this list of conditions and the following disclaimer.
+   2. Redistributions in binary form must reproduce the above copyright notice,
+  this list of conditions and the following disclaimer in the documentation
+  and/or other materials provided with the distribution.
+
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+   THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+   PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+   OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+   OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+   EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Solarflare libefx driver library
+
+
+This directory contains source code of Solarflare Communications libefx
+driver library of version v4.10.0.1012.
+
+Updating
+
+
+The source code in this directory should not be modified.
+Please contact the driver maintainers to request changes.
diff --git a/drivers/net/sfc/efx/base/efx.h b/drivers/net/sfc/efx/base/efx.h
new file mode 100644
index 000..79c6fdc
--- /dev/null
+++ b/drivers/net/sfc/efx/base/efx.h
@@ -0,0 +1,1067 @@
+/*
+ * Copyright (c) 2006-2016 Solarflare Communications Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source 

[dpdk-dev] [PATCH 01/56] net/sfc: libefx-based PMD stub sufficient to build and init

2016-11-21 Thread Andrew Rybchenko
The PMD is put into the sfc/efx subdirectory to have a place for
the second PMD and library shared by both.

Enable the PMD by default on supported configuratons.

Reviewed-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 MAINTAINERS |   6 ++
 config/common_base  |   6 ++
 config/defconfig_arm-armv7a-linuxapp-gcc|   1 +
 config/defconfig_arm64-armv8a-linuxapp-gcc  |   1 +
 config/defconfig_i686-native-linuxapp-gcc   |   5 +
 config/defconfig_i686-native-linuxapp-icc   |   5 +
 config/defconfig_ppc_64-power8-linuxapp-gcc |   1 +
 config/defconfig_tile-tilegx-linuxapp-gcc   |   1 +
 config/defconfig_x86_64-native-linuxapp-icc |   5 +
 config/defconfig_x86_x32-native-linuxapp-gcc|   5 +
 doc/guides/nics/features/sfc_efx.ini|  10 ++
 doc/guides/nics/index.rst   |   1 +
 doc/guides/nics/sfc_efx.rst | 109 +
 drivers/net/Makefile|   1 +
 drivers/net/sfc/Makefile|  33 +++
 drivers/net/sfc/efx/Makefile|  81 
 drivers/net/sfc/efx/rte_pmd_sfc_efx_version.map |   4 +
 drivers/net/sfc/efx/sfc.h   |  53 +++
 drivers/net/sfc/efx/sfc_debug.h |  45 +
 drivers/net/sfc/efx/sfc_ethdev.c| 120 
 drivers/net/sfc/efx/sfc_kvargs.c| 108 +
 drivers/net/sfc/efx/sfc_kvargs.h|  58 
 drivers/net/sfc/efx/sfc_log.h   |  72 ++
 mk/rte.app.mk   |   1 +
 24 files changed, 732 insertions(+)
 create mode 100644 doc/guides/nics/features/sfc_efx.ini
 create mode 100644 doc/guides/nics/sfc_efx.rst
 create mode 100644 drivers/net/sfc/Makefile
 create mode 100644 drivers/net/sfc/efx/Makefile
 create mode 100644 drivers/net/sfc/efx/rte_pmd_sfc_efx_version.map
 create mode 100644 drivers/net/sfc/efx/sfc.h
 create mode 100644 drivers/net/sfc/efx/sfc_debug.h
 create mode 100644 drivers/net/sfc/efx/sfc_ethdev.c
 create mode 100644 drivers/net/sfc/efx/sfc_kvargs.c
 create mode 100644 drivers/net/sfc/efx/sfc_kvargs.h
 create mode 100644 drivers/net/sfc/efx/sfc_log.h

diff --git a/MAINTAINERS b/MAINTAINERS
index d6bb8f8..63fab48 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -364,6 +364,12 @@ M: Sony Chacko 
 F: drivers/net/qede/
 F: doc/guides/nics/qede.rst

+Solarflare sfc_efx
+M: Andrew Rybchenko 
+F: drivers/net/sfc/
+F: doc/guides/nics/sfc_efx.rst
+F: doc/guides/nics/features/sfc_efx.ini
+
 RedHat virtio
 M: Huawei Xie 
 M: Yuanhan Liu 
diff --git a/config/common_base b/config/common_base
index 4bff83a..1eb8eea 100644
--- a/config/common_base
+++ b/config/common_base
@@ -338,6 +338,12 @@ CONFIG_RTE_LIBRTE_PMD_AF_PACKET=n
 CONFIG_RTE_LIBRTE_PMD_XENVIRT=n

 #
+# Compile burst-oriented Solarflare libefx-based PMD
+#
+CONFIG_RTE_LIBRTE_SFC_EFX_PMD=y
+CONFIG_RTE_LIBRTE_SFC_EFX_DEBUG=n
+
+#
 # Compile null PMD
 #
 CONFIG_RTE_LIBRTE_PMD_NULL=y
diff --git a/config/defconfig_arm-armv7a-linuxapp-gcc 
b/config/defconfig_arm-armv7a-linuxapp-gcc
index bde6acd..d99bd0f 100644
--- a/config/defconfig_arm-armv7a-linuxapp-gcc
+++ b/config/defconfig_arm-armv7a-linuxapp-gcc
@@ -75,3 +75,4 @@ CONFIG_RTE_LIBRTE_VMXNET3_PMD=n
 CONFIG_RTE_LIBRTE_PMD_XENVIRT=n
 CONFIG_RTE_LIBRTE_PMD_BNX2X=n
 CONFIG_RTE_LIBRTE_QEDE_PMD=n
+CONFIG_RTE_LIBRTE_SFC_EFX_PMD=n
diff --git a/config/defconfig_arm64-armv8a-linuxapp-gcc 
b/config/defconfig_arm64-armv8a-linuxapp-gcc
index 6321884..aef5431 100644
--- a/config/defconfig_arm64-armv8a-linuxapp-gcc
+++ b/config/defconfig_arm64-armv8a-linuxapp-gcc
@@ -45,5 +45,6 @@ CONFIG_RTE_TOOLCHAIN_GCC=y
 CONFIG_RTE_EAL_IGB_UIO=n

 CONFIG_RTE_LIBRTE_FM10K_PMD=n
+CONFIG_RTE_LIBRTE_SFC_EFX_PMD=n

 CONFIG_RTE_SCHED_VECTOR=n
diff --git a/config/defconfig_i686-native-linuxapp-gcc 
b/config/defconfig_i686-native-linuxapp-gcc
index 576d543..5875ecd 100644
--- a/config/defconfig_i686-native-linuxapp-gcc
+++ b/config/defconfig_i686-native-linuxapp-gcc
@@ -67,6 +67,11 @@ CONFIG_RTE_LIBRTE_PMD_AESNI_GCM=n
 CONFIG_RTE_LIBRTE_PMD_KASUMI=n

 #
+# Solarflare PMD is not supported on 32-bit
+#
+CONFIG_RTE_LIBRTE_SFC_EFX_PMD=n
+
+#
 # ZUC PMD is not supported on 32-bit
 #
 CONFIG_RTE_LIBRTE_PMD_ZUC=n
diff --git a/config/defconfig_i686-native-linuxapp-icc 
b/config/defconfig_i686-native-linuxapp-icc
index 6c902a3..7be476b 100644
--- a/config/defconfig_i686-native-linuxapp-icc
+++ b/config/defconfig_i686-native-linuxapp-icc
@@ -67,6 +67,11 @@ CONFIG_RTE_LIBRTE_PMD_AESNI_GCM=n
 CONFIG_RTE_LIBRTE_PMD_KASUMI=n

 #
+# Solarflare PMD is not supported on 32-bit
+#
+CONFIG_RTE_LIBRTE_SFC_EFX_PMD=n
+
+#
 # ZUC PMD is not supported on 32-bit
 #
 CONFIG_RTE_LIBRTE_PMD_ZUC=n
diff --git a/config/defconfig_ppc_64-power8-linuxapp-gcc 
b/config/defconfig_ppc_64-power8-linuxapp-gcc
index f953e61..35f7fb6 100644
--- 

[dpdk-dev] [PATCH 00/56] Solarflare libefx-based PMD

2016-11-21 Thread Andrew Rybchenko
The patch series adds Solarflare libefx-based network PMD.

This version of the driver supports Solarflare SFN7xxx and SFN8xxx
families of 10/40 Gbps adapters.

libefx is a platform-independent library to implement drivers for
Solarflare network adapters. It provides unified adapter family
independent interface (if possible). FreeBSD [1] and illumos [2]
drivers are built on top of the library.

The patch series could be logically structured into 5 sub-series:
 1. (1) add the driver skeleton including documentation
 2. (2-30) import libefx and include it in build with the latest patch
 3. (31-43) implement minimal device level operations in steps
 4. (44-51) implement Rx subsystem
 5. (52-56) implement Tx subsystem

Functional driver with multi-queue support capable to send and receive
traffic appears with the last patch in the series.

The following design decisions are made during development:

 1. Since libefx uses positive errno return codes, positive errno
return codes are used inside the driver and coversion to negative
is done on return from eth_dev_ops callbacks. We think that it
is the less error-prone way.

 2. Another Solarflare PMD with in-kernel part (for control operations)
is considered and could be added in the future. Code for data path
should be shared by these two drivers. libefx-based PMD is put into
'efx' subdirectory to have a space for another PMD and shared code.

 3. Own event queue (a way to deliver events from HW to host CPU) is
used for house-keeping (e.g. link status notifications), each Tx
and each Rx queue. No locks on datapath are requires in this case.

 4. Alarm is used to periodically poll house-keeping event queue.
The event queue is used to deliver link status change notifications,
Rx/Tx queue flush events, SRAM events. It is not used on datapath.
The event queue polling is protected using spin-lock since
concurrent access from different contexts is possible (e.g. device
stop when polling alarm is running).

[1] https://svnweb.freebsd.org/base/head/sys/dev/sfxge/common/
[2] 
https://github.com/illumos/illumos-gate/tree/master/usr/src/uts/common/io/sfxge/common/

---

Andrew Rybchenko (49):
  net/sfc: libefx-based PMD stub sufficient to build and init
  net/sfc: import libefx base
  net/sfc: import libefx register definitions
  net/sfc: import libefx filters support
  net/sfc: import libefx MCDI definition
  net/sfc: import libefx MCDI implementation
  net/sfc: import libefx MCDI logging support
  net/sfc: import libefx MCDI proxy authorization support
  net/sfc: import libefx 5xxx/6xxx family support
  net/sfc: import libefx SFN7xxx family support
  net/sfc: import libefx SFN8xxx family support
  net/sfc: import libefx diagnostics support
  net/sfc: import libefx built-in selftest support
  net/sfc: import libefx software per-queue statistics support
  net/sfc: import libefx PHY flags control support
  net/sfc: import libefx PHY statistics support
  net/sfc: import libefx PHY LEDs control support
  net/sfc: import libefx MAC statistics support
  net/sfc: import libefx event prefetch support
  net/sfc: import libefx Rx scatter support
  net/sfc: import libefx RSS support
  net/sfc: import libefx loopback control support
  net/sfc: import libefx monitors statistics support
  net/sfc: import libefx support to access monitors via MCDI
  net/sfc: import libefx support for Rx packed stream mode
  net/sfc: import libefx NVRAM support
  net/sfc: import libefx VPD support
  net/sfc: import libefx bootrom configuration support
  net/sfc: import libefx licensing support
  net/sfc: implement dummy callback to get device information
  net/sfc: implement driver operation to init device on attach
  net/sfc: add device configure and close stubs
  net/sfc: add device configuration checks
  net/sfc: implement device start and stop operations
  net/sfc: make available resources estimation and allocation
  net/sfc: interrupts support sufficient for event queue init
  net/sfc: implement event queue support
  net/sfc: implement EVQ dummy exception handling
  net/sfc: maintain management event queue
  net/sfc: periodic management EVQ polling using alarm
  net/sfc: minimum port control sufficient to receive traffic
  net/sfc: implement Rx subsystem stubs
  net/sfc: check configured rxmode
  net/sfc: implement Rx queue setup release operations
  net/sfc: calculate Rx buffer size which may be used
  net/sfc: validate Rx queue buffers setup
  net/sfc: implement Rx queue start and stop operations
  net/sfc: implement device callback to Rx burst of packets
  net/sfc: discard scattered packet on Rx correctly

Artem Andreev (2):
  net/sfc: include libefx in build
  net/sfc: implement device operation to retrieve link info

Ivan Malov (5):
  net/sfc: provide basic stubs for Tx subsystem
  net/sfc: add function to check configured Tx mode
  net/sfc: add callbacks to set up and release Tx queues
  net/sfc: implement transmit path start / stop
  

[dpdk-dev] [PATCH v2] nfp: report link speed using hardware info

2016-11-21 Thread Alejandro Lucero
On Mon, Nov 21, 2016 at 11:18 AM, Ferruh Yigit 
wrote:

> On 11/18/2016 4:06 PM, Alejandro Lucero wrote:
> > Previous reported speed was hardcoded.
> >
> > Signed-off-by: Alejandro Lucero 
> > ---
> >  drivers/net/nfp/nfp_net.c  | 28 ++--
> >  drivers/net/nfp/nfp_net_ctrl.h | 13 +
> >  2 files changed, 39 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/net/nfp/nfp_net.c b/drivers/net/nfp/nfp_net.c
> > index c6b1587..24f3164 100644
> > --- a/drivers/net/nfp/nfp_net.c
> > +++ b/drivers/net/nfp/nfp_net.c
> > @@ -816,6 +816,17 @@ static void nfp_net_read_mac(struct nfp_net_hw *hw)
> >   struct rte_eth_link link, old;
> >   uint32_t nn_link_status;
> >
> > + static const uint32_t ls_to_ethtool[] = {
> > + [NFP_NET_CFG_STS_LINK_RATE_UNSUPPORTED] =
> ETH_SPEED_NUM_NONE,
> > + [NFP_NET_CFG_STS_LINK_RATE_UNKNOWN] =
> ETH_SPEED_NUM_NONE,
> > + [NFP_NET_CFG_STS_LINK_RATE_1G]  = ETH_SPEED_NUM_1G,
> > + [NFP_NET_CFG_STS_LINK_RATE_10G] =
> ETH_SPEED_NUM_10G,
> > + [NFP_NET_CFG_STS_LINK_RATE_25G] =
> ETH_SPEED_NUM_25G,
> > + [NFP_NET_CFG_STS_LINK_RATE_40G] =
> ETH_SPEED_NUM_40G,
> > + [NFP_NET_CFG_STS_LINK_RATE_50G] =
> ETH_SPEED_NUM_50G,
> > + [NFP_NET_CFG_STS_LINK_RATE_100G]=
> ETH_SPEED_NUM_100G,
> > + };
> > +
> >   PMD_DRV_LOG(DEBUG, "Link update\n");
> >
> >   hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
> > @@ -831,8 +842,21 @@ static void nfp_net_read_mac(struct nfp_net_hw *hw)
> >   link.link_status = ETH_LINK_UP;
> >
> >   link.link_duplex = ETH_LINK_FULL_DUPLEX;
> > - /* Other cards can limit the tx and rx rate per VF */
> > - link.link_speed = ETH_SPEED_NUM_40G;
> > +
> > + nn_link_status = (nn_link_status >> NFP_NET_CFG_STS_LINK_RATE_SHIFT)
> &
> > +  NFP_NET_CFG_STS_LINK_RATE_MASK;
> > +
> > + if ((NFD_CFG_MAJOR_VERSION_of(hw->ver) < 4) ||
> > + ((NFD_CFG_MINOR_VERSION_of(hw->ver) == 4) &&
> > + (NFD_CFG_MINOR_VERSION_of(hw->ver) == 0)))
> > + link.link_speed = ETH_SPEED_NUM_40G;
>
> For specific firmware version, speed is still hardcoded to 40G, can you
> please mention from this and if possible its reason in commit log?
>
> > + else {
> > + if (nn_link_status == NFP_NET_CFG_STS_LINK_RATE_UNKNOWN ||
>
> This check can be redundant, since
> ls_to_ethtool[NFP_NET_CFG_STS_LINK_RATE_UNKNOWN] => ETH_SPEED_NUM_NONE
>
>
This is for checking any wrong value from firmware/hardware.


> > + nn_link_status >= RTE_DIM(ls_to_ethtool))
> > + link.link_speed = ETH_SPEED_NUM_NONE;
> > + else
> > + link.link_speed = ls_to_ethtool[nn_link_status];
> > + }
> >
> >   if (old.link_status != link.link_status) {
> >   nfp_net_dev_atomic_write_link_status(dev, );
> > diff --git a/drivers/net/nfp/nfp_net_ctrl.h b/drivers/net/nfp/nfp_net_
> ctrl.h
> > index fce8251..f9aaba3 100644
> > --- a/drivers/net/nfp/nfp_net_ctrl.h
> > +++ b/drivers/net/nfp/nfp_net_ctrl.h
> > @@ -157,6 +157,19 @@
> >  #define   NFP_NET_CFG_VERSION_MINOR(x)(((x) & 0xff) <<  0)
> >  #define NFP_NET_CFG_STS 0x0034
> >  #define   NFP_NET_CFG_STS_LINK(0x1 << 0) /* Link up or down
> */
> > +/* Link rate */
> > +#define   NFP_NET_CFG_STS_LINK_RATE_SHIFT 1
> > +#define   NFP_NET_CFG_STS_LINK_RATE_MASK  0xF
> > +#define   NFP_NET_CFG_STS_LINK_RATE   \
> > +   (NFP_NET_CFG_STS_LINK_RATE_MASK << NFP_NET_CFG_STS_LINK_RATE_
> SHIFT)
>
> This macro is not used at all, just fyi.
>
>
Thanks. I think I can remove it.


> > +#define   NFP_NET_CFG_STS_LINK_RATE_UNSUPPORTED   0
> > +#define   NFP_NET_CFG_STS_LINK_RATE_UNKNOWN   1
> > +#define   NFP_NET_CFG_STS_LINK_RATE_1G2
> > +#define   NFP_NET_CFG_STS_LINK_RATE_10G   3
> > +#define   NFP_NET_CFG_STS_LINK_RATE_25G   4
> > +#define   NFP_NET_CFG_STS_LINK_RATE_40G   5
> > +#define   NFP_NET_CFG_STS_LINK_RATE_50G   6
> > +#define   NFP_NET_CFG_STS_LINK_RATE_100G  7
> >  #define NFP_NET_CFG_CAP 0x0038
> >  #define NFP_NET_CFG_MAX_TXRINGS 0x003c
> >  #define NFP_NET_CFG_MAX_RXRINGS 0x0040
> >
>
>


[dpdk-dev] [PATCH RFC 0/2] Allow vectorized Rx with 4096 desc ring size on Intel NICs.

2016-11-21 Thread Ferruh Yigit
On 10/19/2016 3:30 PM, Ferruh Yigit wrote:
> On 10/19/2016 3:07 PM, Ilya Maximets wrote:
>> Ilya Maximets (2):
>>   net/i40e: allow bulk alloc for the max size desc ring
>>   net/ixgbe: allow bulk alloc for the max size desc ring
>>
>>  drivers/net/i40e/i40e_rxtx.c   | 24 +---
>>  drivers/net/ixgbe/ixgbe_rxtx.c | 17 +
>>  drivers/net/ixgbe/ixgbe_rxtx.h |  2 +-
>>  3 files changed, 15 insertions(+), 28 deletions(-)
>>
> 
> Hi Ilya,
> 
> Thank you for the patch, we are in post rc1 phase and this is a new
> feature, so this patchset will be considered for next release (v17.02).
> 

Reminder for this patch (RFC) which has been sent in 16.11 time frame
and we postponed to 17.02 release.

Thanks,
ferruh


[dpdk-dev] [PATCH v3] ntnic: add PMD driver

2016-11-21 Thread Ferruh Yigit
On 9/12/2016 8:34 AM, fc at napatech.com (Finn Christensen) wrote:
>> -Original Message-
>> From: Thomas Monjalon [mailto:thomas.monjalon at 6wind.com]
>> Sent: 10. september 2016 10:20
>> To: Finn Christensen 
>> Cc: Neil Horman ; dev at dpdk.org;
>> stephen at networkplumber.org
>> Subject: Re: [PATCH v3] ntnic: add PMD driver
>>
>> 2016-09-10 07:58, Finn Christensen:
>>> From: Neil Horman [mailto:nhorman at tuxdriver.com]
 On Fri, Sep 09, 2016 at 12:48:38PM +, Finn Christensen wrote:
> This is the Napatech NTNIC Poll Mode Driver (PMD) for DPDK.
>
> This patch adds support for Napatech NICs to DPDK. This is the
> initial implementation.
>
> Signed-off-by: Finn Christensen 
> ---
> v3:
>   * Removed the need for binary libraries on build
> v2:
>   * Added information how to build the PMD without NIC
> Board Support Package
>   * Fixed some formatting issues

 So, this is a step in the right direction, but I think its solving
 the wrong problem.  If you have a dependency on an external library,
 thats ok, and accessing it via dlopen makes it possible to build the
 library without having that library present, but it not really in
 keeping with the spirit of what I meant.  This driver is still
 effectively dependent on a binary blob that we have no visibility
 into.  The better solution is releasing the source for the ntnic and
 ntos libraries.  The license file in the referenced git tree
 indicates its BSD licensed, so I don't think there should be a problem in
>> doing that.

 Neil

>>> No, unfortunately the ntapi is not BSD licensed, only the header files
>>> that you can freely download are.
>>> We are building this NT NIC by using parts or our technology from our
>>> capture adapters and that is using closed source software.
>>>
>>> We are new to opensource and we want to go that way, but we haven't
>>> yet a complete stand-alone driver ready that we can put into the DPDK
>>> PMD to have a complete self contained and open sourced DPDK PMD, that
>>> only needs the actual HW NIC plugged in to run.
>>> Therefore this version is implemented as a virtual device, exactly
>>> like the PCAP PMD driver is, and it runs on top of a driver that follows the
>> NIC itself.
>>>
>>> In regards to the DPDK functionality we do not see that anything is missing.
>>> I cannot either see where we should add source code, because it is not
>>> part of the DPDK package and it should not be either.
>>>
>>> One of the things I really liked about the DPDK open source project is
>>> that it uses BSD licensing not GPL. Therefore, I must admit, we
>>> completely failed to see that the "spirit" of the DPDK community is
>>> not really BSD. Our view of this community was that the main driving
>>> force of it was to be able to make DPDK run on everything anywhere
>>> effectively, in a global contributing community, without  any legally
>> constrains prohibiting us to do so.
>>
>> It is difficult to define what is the spirit of a community, especially only 
>> after
>> few mail exchanges.
>> I agree that running on everything anywhere is a nice goal.
>> Here Neil, as a RedHat developer, is probably concerned about enabling your
>> driver in a distribution. It seems your model is not compatible with the
>> "anywhere goal" and will be disabled in that case, until it is fully open.
> 
> The ntnic PMD is not enabled by default and I think it should not be either. 
> To
> enable it in a distribution for general purposes seems wrong. In that respect
> we see no difference between the PCAP PMD and this ntnic PMD.
> 
>>> However, this is our standing, and I don't know what else to do.
>>> Please advise or NAK this PMD.
>>
>> I do not remember having already seen such model in DPDK.
>> So we need to think about the implications a bit more.
>> (Comments/discussions are welcome)
>> Thanks for your patience.
> 
> Thanks. I will be happy to discuss this further, so that we can get to a 
> conclusion.
> If the outcome is that the majority of the community does not like the idea 
> that
> upstream supported PMDs has external linking dependencies to closed source
> libraries, then it is ok with us(a pity though). But then it might be a good 
> idea to
> make that decision clear to everybody else by putting in a clause into the
> contribution section of the DPDK guide, or somewhere else in the guide.
> 
> In our opinion, the inclusion of the ntnic PMD into upstream DPDK, does not
> seem to be any different than that of the PCAP PMD, since that is also
> dependent on external header files and externally built libraries.
> Of course we see the difference in open source vs close source library. But we
> cannot see that is has any influence in the usage or functionality of the 
> DPDK.
> 
> Thanks for this discussion!
> 

The patch is still waiting in the patchwork.

This requires a high level discussion. Any suggestion on how to 

[dpdk-dev] [PATCH] examples/ip_pipeline: fix load balancing function in pass-through pipeline

2016-11-21 Thread Jasvinder Singh
This patch fixes the configuration file parsing error when load balancing
function is enabled in pass-through pipeline.

error log:
pipeline> [APP] Initializing PIPELINE1 ...
[PIPELINE1] Pass-through
Parse error in section "PIPELINE1": entry "lb" has invalid value ("hash")

Fixes: cbe82f6cfb0a ("examples/ip_pipeline: add swap action in pass-through")

Signed-off-by: Jasvinder Singh 
---
 examples/ip_pipeline/pipeline/pipeline_passthrough_be.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/examples/ip_pipeline/pipeline/pipeline_passthrough_be.c 
b/examples/ip_pipeline/pipeline/pipeline_passthrough_be.c
index 8b71a7d..7ab0afe 100644
--- a/examples/ip_pipeline/pipeline/pipeline_passthrough_be.c
+++ b/examples/ip_pipeline/pipeline/pipeline_passthrough_be.c
@@ -589,7 +589,7 @@ pipeline_passthrough_parse_args(struct 
pipeline_passthrough_params *p,
params->name, arg_name);
dma_hash_lb_present = 1;

-   if (strcmp(arg_value, "hash") ||
+   if (strcmp(arg_value, "hash") &&
strcmp(arg_value, "HASH"))

PIPELINE_PARSE_ERR_INV_VAL(0,
-- 
2.5.5



[dpdk-dev] [PATCH v9] drivers/net:new PMD using tun/tap host interface

2016-11-21 Thread Ferruh Yigit
On 10/13/2016 11:03 PM, Keith Wiles wrote:
> The rte_eth_tap.c PMD creates a device using TUN/TAP interfaces
> on the local host. The PMD allows for DPDK and the host to
> communicate using a raw device interface on the host and in
> the DPDK application. The device created is a Tap device with
> a L2 packet header.
> 
> v9 - Fix up the docs to use correct syntax
> v8 - Fix issue with tap_tx_queue_setup() not return zero on success.
> v7 - Reword the comment in common_base and fix the data->name issue
> v6 - fixed the checkpatch issues
> v5 - merge in changes from list review see related emails
>  fixed many minor edits
> v4 - merge with latest driver changes
> v3 - fix includes by removing ifdef for other type besides Linux
>  Fix the copyright notice in the Makefile
> v2 - merge all of the patches into one patch
>  Fix a typo on naming the tap device
>  Update the maintainers list
> 
> Signed-off-by: Keith Wiles 
> ---

Just a reminder, this is a new PMD and waiting for community review.


[dpdk-dev] [RFC PATCH 0/6] Restructure EAL device model for bus support

2016-11-21 Thread Jan Blunck
On Mon, Nov 21, 2016 at 10:08 AM, Thomas Monjalon
 wrote:
> 2016-11-20 16:30, David Marchand:
>> For a first patchset, I would see:
>> - introduce the rte_bus object. In rte_eal_init, for each bus, we call
>> the scan method. Then, for each bus, we find the appropriate
>> rte_driver using the bus match method then call the probe method. If
>> the probe succeeds, the rte_device points to the associated
>> rte_driver,
>> - migrate the pci scan code to a pci bus (scan looks at sysfs for
>> linux / ioctl for bsd + devargs for blacklist / whitelist ?), match is
>> the same at what is done in rte_eal_pci_probe_one_driver() at the
>> moment,
>> - migrate the vdev init code to a vdev bus (scan looks at devargs):
>> this is new, we must create rte_device objects for vdev drivers to use
>> later
>
> I think it can be 3 patchsets.
> Who can work on the vdev part please?

I'll take a look.


[dpdk-dev] Solarflare PMD submission question

2016-11-21 Thread Andrew Rybchenko
On 11/21/2016 11:19 AM, Thomas Monjalon wrote:
>> Before submitting 56 patches I'd like to double-check that checkpatch.pl
>> errors (for example, because of assignments in the 'if' condition,
>> parenthesis around return value) is not a show-stopper for base driver
>> import.
> You can run checkpatches.sh or send the patches to checkpatch at dpdk.org.
> The script check-git-log.sh can also guide you for the expected formatting.

Yes, I did it and it helped me to find and fix some coding standard 
violations.

The problem with libefx (base driver) is that it is existing code which 
follows FreeBSD and illumos coding conventions which contradict to 
checkpatches.sh sometimes (e.g. require parenthesis around return 
value). Other example of error produced by checkpatches.sh is assign in 
if. It is widely used in the code to assign return code value and 
compare it vs 0 in one line. It is not a coding standard conflict, but 
it is very wide-spread in the code (so changing it will produce too many 
changes not strictly required/useful).

So, may I repeat my question if it is a show-stopper for base driver or 
acceptable.

Thanks,
Andrew.


[dpdk-dev] [dpdk-stable] [PATCH] Revert "bonding: use existing enslaved device queues"

2016-11-21 Thread Ferruh Yigit
On 10/25/2016 3:00 PM, Bruce Richardson wrote:
> On Tue, Oct 25, 2016 at 02:48:04PM +0100, Declan Doherty wrote:
>> On 25/10/16 13:57, Bruce Richardson wrote:
>>> On Mon, Oct 24, 2016 at 04:07:17PM +0100, Declan Doherty wrote:
 On 24/10/16 15:51, Jan Blunck wrote:
> On Mon, Oct 24, 2016 at 7:02 AM, Declan Doherty
>  wrote:
>> On 14/10/16 00:37, Eric Kinzie wrote:
>>>
>>> On Wed Oct 12 16:24:21 +0100 2016, Bruce Richardson wrote:

 On Wed, Oct 12, 2016 at 04:24:54PM +0300, Ilya Maximets wrote:
>
> On 07.10.2016 05:02, Eric Kinzie wrote:
>>
>> On Wed Sep 07 15:28:10 +0300 2016, Ilya Maximets wrote:
>>>
>>> This reverts commit 5b7bb2bda5519b7800f814df64d4e015282140e5.
>>>
>>> It is necessary to reconfigure all queues every time because
>>> configuration
>>> can be changed.
>>>
>>> For example, if we're reconfiguring bonding device with new memory
>>> pool,
>>> already configured queues will still use the old one. And if the old
>>> mempool be freed, application likely will panic in attempt to use
>>> freed mempool.
>>>
>>> This happens when we use the bonding device with OVS 2.6 while MTU
>>> reconfiguration:
>>>
>>> PANIC in rte_mempool_get_ops():
>>> assert "(ops_index >= 0) && (ops_index < RTE_MEMPOOL_MAX_OPS_IDX)"
>>> failed
>>>
>>> Cc: 
>>> Signed-off-by: Ilya Maximets 
>>> ---
>>>  drivers/net/bonding/rte_eth_bond_pmd.c | 10 ++
>>>  1 file changed, 2 insertions(+), 8 deletions(-)
>>>
>>> diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c
>>> b/drivers/net/bonding/rte_eth_bond_pmd.c
>>> index b20a272..eb5b6d1 100644
>>> --- a/drivers/net/bonding/rte_eth_bond_pmd.c
>>> +++ b/drivers/net/bonding/rte_eth_bond_pmd.c
>>> @@ -1305,8 +1305,6 @@ slave_configure(struct rte_eth_dev
>>> *bonded_eth_dev,
>>> struct bond_rx_queue *bd_rx_q;
>>> struct bond_tx_queue *bd_tx_q;
>>>
>>> -   uint16_t old_nb_tx_queues = 
>>> slave_eth_dev->data->nb_tx_queues;
>>> -   uint16_t old_nb_rx_queues = 
>>> slave_eth_dev->data->nb_rx_queues;
>>> int errval;
>>> uint16_t q_id;
>>>
>>> @@ -1347,9 +1345,7 @@ slave_configure(struct rte_eth_dev
>>> *bonded_eth_dev,
>>> }
>>>
>>> /* Setup Rx Queues */
>>> -   /* Use existing queues, if any */
>>> -   for (q_id = old_nb_rx_queues;
>>> -q_id < bonded_eth_dev->data->nb_rx_queues; q_id++) {
>>> +   for (q_id = 0; q_id < bonded_eth_dev->data->nb_rx_queues;
>>> q_id++) {
>>> bd_rx_q = (struct bond_rx_queue
>>> *)bonded_eth_dev->data->rx_queues[q_id];
>>>
>>> errval =
>>> rte_eth_rx_queue_setup(slave_eth_dev->data->port_id, q_id,
>>> @@ -1365,9 +1361,7 @@ slave_configure(struct rte_eth_dev
>>> *bonded_eth_dev,
>>> }
>>>
>>> /* Setup Tx Queues */
>>> -   /* Use existing queues, if any */
>>> -   for (q_id = old_nb_tx_queues;
>>> -q_id < bonded_eth_dev->data->nb_tx_queues; q_id++) {
>>> +   for (q_id = 0; q_id < bonded_eth_dev->data->nb_tx_queues;
>>> q_id++) {
>>> bd_tx_q = (struct bond_tx_queue
>>> *)bonded_eth_dev->data->tx_queues[q_id];
>>>
>>> errval =
>>> rte_eth_tx_queue_setup(slave_eth_dev->data->port_id, q_id,
>>> --
>>> 2.7.4
>>>
>>
>> NAK
>>
>> There are still some users of this code.  Let's give them a chance to
>> comment before removing it.
>
>
> Hi Eric,
>
> Are these users in CC-list? If not, could you, please, add them?
> This patch awaits in mail-list already more than a month. I think, 
> it's
> enough
> time period for all who wants to say something. Patch fixes a real bug
> that
> prevent using of DPDK bonding in all applications that reconfigures
> devices
> in runtime including OVS.
>
 Agreed.

 Eric, does reverting this patch cause you problems directly, or is your
 concern
 just with regards to potential impact to others?

 Thanks,
 /Bruce
>>>
>>>
>>> This won't impact me directly.  The users are CCed (different thread)
>>> and I haven't seen any comment, so I no longer have any objection to
>>> reverting this change.
>>>
>>> Eric
>>>
>>
>> As there has been no 

[dpdk-dev] [PATCH v2] nfp: report link speed using hardware info

2016-11-21 Thread Ferruh Yigit
On 11/18/2016 4:06 PM, Alejandro Lucero wrote:
> Previous reported speed was hardcoded.
> 
> Signed-off-by: Alejandro Lucero 
> ---
>  drivers/net/nfp/nfp_net.c  | 28 ++--
>  drivers/net/nfp/nfp_net_ctrl.h | 13 +
>  2 files changed, 39 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/nfp/nfp_net.c b/drivers/net/nfp/nfp_net.c
> index c6b1587..24f3164 100644
> --- a/drivers/net/nfp/nfp_net.c
> +++ b/drivers/net/nfp/nfp_net.c
> @@ -816,6 +816,17 @@ static void nfp_net_read_mac(struct nfp_net_hw *hw)
>   struct rte_eth_link link, old;
>   uint32_t nn_link_status;
>  
> + static const uint32_t ls_to_ethtool[] = {
> + [NFP_NET_CFG_STS_LINK_RATE_UNSUPPORTED] = ETH_SPEED_NUM_NONE,
> + [NFP_NET_CFG_STS_LINK_RATE_UNKNOWN] = ETH_SPEED_NUM_NONE,
> + [NFP_NET_CFG_STS_LINK_RATE_1G]  = ETH_SPEED_NUM_1G,
> + [NFP_NET_CFG_STS_LINK_RATE_10G] = ETH_SPEED_NUM_10G,
> + [NFP_NET_CFG_STS_LINK_RATE_25G] = ETH_SPEED_NUM_25G,
> + [NFP_NET_CFG_STS_LINK_RATE_40G] = ETH_SPEED_NUM_40G,
> + [NFP_NET_CFG_STS_LINK_RATE_50G] = ETH_SPEED_NUM_50G,
> + [NFP_NET_CFG_STS_LINK_RATE_100G]= ETH_SPEED_NUM_100G,
> + };
> +
>   PMD_DRV_LOG(DEBUG, "Link update\n");
>  
>   hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
> @@ -831,8 +842,21 @@ static void nfp_net_read_mac(struct nfp_net_hw *hw)
>   link.link_status = ETH_LINK_UP;
>  
>   link.link_duplex = ETH_LINK_FULL_DUPLEX;
> - /* Other cards can limit the tx and rx rate per VF */
> - link.link_speed = ETH_SPEED_NUM_40G;
> +
> + nn_link_status = (nn_link_status >> NFP_NET_CFG_STS_LINK_RATE_SHIFT) &
> +  NFP_NET_CFG_STS_LINK_RATE_MASK;
> +
> + if ((NFD_CFG_MAJOR_VERSION_of(hw->ver) < 4) ||
> + ((NFD_CFG_MINOR_VERSION_of(hw->ver) == 4) &&
> + (NFD_CFG_MINOR_VERSION_of(hw->ver) == 0)))
> + link.link_speed = ETH_SPEED_NUM_40G;

For specific firmware version, speed is still hardcoded to 40G, can you
please mention from this and if possible its reason in commit log?

> + else {
> + if (nn_link_status == NFP_NET_CFG_STS_LINK_RATE_UNKNOWN ||

This check can be redundant, since
ls_to_ethtool[NFP_NET_CFG_STS_LINK_RATE_UNKNOWN] => ETH_SPEED_NUM_NONE

> + nn_link_status >= RTE_DIM(ls_to_ethtool))
> + link.link_speed = ETH_SPEED_NUM_NONE;
> + else
> + link.link_speed = ls_to_ethtool[nn_link_status];
> + }
>  
>   if (old.link_status != link.link_status) {
>   nfp_net_dev_atomic_write_link_status(dev, );
> diff --git a/drivers/net/nfp/nfp_net_ctrl.h b/drivers/net/nfp/nfp_net_ctrl.h
> index fce8251..f9aaba3 100644
> --- a/drivers/net/nfp/nfp_net_ctrl.h
> +++ b/drivers/net/nfp/nfp_net_ctrl.h
> @@ -157,6 +157,19 @@
>  #define   NFP_NET_CFG_VERSION_MINOR(x)(((x) & 0xff) <<  0)
>  #define NFP_NET_CFG_STS 0x0034
>  #define   NFP_NET_CFG_STS_LINK(0x1 << 0) /* Link up or down */
> +/* Link rate */
> +#define   NFP_NET_CFG_STS_LINK_RATE_SHIFT 1
> +#define   NFP_NET_CFG_STS_LINK_RATE_MASK  0xF
> +#define   NFP_NET_CFG_STS_LINK_RATE   \
> +   (NFP_NET_CFG_STS_LINK_RATE_MASK << NFP_NET_CFG_STS_LINK_RATE_SHIFT)

This macro is not used at all, just fyi.

> +#define   NFP_NET_CFG_STS_LINK_RATE_UNSUPPORTED   0
> +#define   NFP_NET_CFG_STS_LINK_RATE_UNKNOWN   1
> +#define   NFP_NET_CFG_STS_LINK_RATE_1G2
> +#define   NFP_NET_CFG_STS_LINK_RATE_10G   3
> +#define   NFP_NET_CFG_STS_LINK_RATE_25G   4
> +#define   NFP_NET_CFG_STS_LINK_RATE_40G   5
> +#define   NFP_NET_CFG_STS_LINK_RATE_50G   6
> +#define   NFP_NET_CFG_STS_LINK_RATE_100G  7
>  #define NFP_NET_CFG_CAP 0x0038
>  #define NFP_NET_CFG_MAX_TXRINGS 0x003c
>  #define NFP_NET_CFG_MAX_RXRINGS 0x0040
> 



[dpdk-dev] [PATCH v2] nfp: report link speed using hardware info

2016-11-21 Thread Ferruh Yigit
On 11/18/2016 4:50 PM, Alejandro Lucero wrote:
> On Fri, Nov 18, 2016 at 4:29 PM, Thomas Monjalon  6wind.com>
> wrote:
> 
>> 2016-11-18 16:06, Alejandro Lucero:
>>> Previous reported speed was hardcoded.
>>>
>>> Signed-off-by: Alejandro Lucero 
>>> ---
>>>  drivers/net/nfp/nfp_net.c  | 28 ++--
>>>  drivers/net/nfp/nfp_net_ctrl.h | 13 +
>>>  2 files changed, 39 insertions(+), 2 deletions(-)
>>
>> You should update the doc in the same patch:
>> doc/guides/nics/features/nfp.ini
>> It will be the first feature as the file appears to be empty.
>> So you will need another patch to fill other existing features.
>>
> 
> Yes. I'm just working on updating that file properly.
> May I delay this doc change for including it with that other one?
> It will be a bit weird to just have one feature there.

I think yes, but can you please send the documentation patch before
integration deadline of this release?

> 
> 
>>
>> I have an unrelated question: why nfp is disabled in the default build?
>>
>>
> Because NFP PMD can just work if Netronome BSP is installed in the system.

Is this BSP open source and freely available? If so, can you update the
document with details (how/where to get it) please?

> We do not support PF with the PMD, so it requires a Linux PF driver which
> comes with the BSP.
> 
> The compilation has no dependencies, but we had our own UIO driver before
> (now using igb_uio). So basically, we wanted the people aware of this
> dependency and to specifically configure this option.
> 
> I know what you are surely going to ask about DPDK in Linux distributions,
> and that this being a bad idea. The fact is, we have people using NFP PMD
> as part of a product, so installing that product implies to (automatically)
> install the BSP and a specific DPDK version with the NFP PMD enabled. But
> yes, maybe we should modify this and to add some sort of BSP check inside
> the PMD.

Is there a DPDK version <-> BSP version dependency?

> 
> So, thanks for the heads up. I will think about this.
> 



[dpdk-dev] Adding API to force freeing consumed buffers in TX ring

2016-11-21 Thread Damjan Marion (damarion)

Hi,

Currently in VPP we do memcpy of whole packet when we need to do 
replication as we cannot know if specific buffer is transmitted
from tx ring before we update it again (i.e. l2 header rewrite).

Unless there is already a way to address this issue in DPDK which I?m not aware
of my proposal is that we provide mechanism for polling TX ring 
for consumed buffers. This can be either completely new API or 
extension of rte_etx_tx_burst (i.e. special case when nb_pkts=0).

This will allows us to start polling tx ring when we expect some 
mbuf back, instead of waiting for next tx burst (which we don?t know
when it will happen) and hoping that we will reach free_threshold soon.

Any thoughts?

Thanks,

Damjan





[dpdk-dev] [PATCH] eal: postpone vdev initialization

2016-11-21 Thread Shreyansh Jain
On Sunday 20 November 2016 01:30 PM, Jerin Jacob wrote:
> Some platform like octeontx may use pci and
> vdev based combined device to represent a logical
> dpdk functional device.In such case, postponing the
> vdev initialization after pci device
> initialization will provide the better view of
> the pci device resources in the system in
> vdev's probe function, and it allows better
> functional subsystem registration in vdev probe
> function.
>
> As a bonus, This patch fixes a bond device
> initialization use case.
>
> example command to reproduce the issue:
> ../testpmd -c 0x2  --vdev 'eth_bond0,mode=0,
> slave=:02:00.0,slave=:03:00.0' --
> --port-topology=chained
>
> root cause:
> In existing case(vdev initialization and then pci
> initialization), creates three Ethernet ports with
> following port ids
> 0 - Bond device
> 1 - PCI device 0
> 2 - PCI devive 1
>
> Since testpmd, calls the configure/start on all the ports on
> start up,it will translate to following illegal setup sequence
>
> 1)bond device configure/start
> 1.1) pci device0 stop/configure/start
> 1.2) pci device1 stop/configure/start
> 2)pci device 0 configure(illegal setup case,
> as device in start state)
>
> The fix changes the initialization sequence and
> allow initialization in following valid setup order
> 1) pcie device 0 configure/start
> 2) pcie device 1 configure/start
> 3) bond device 2 configure/start
> 3.1) pcie device 0/stop/configure/start
> 3.2) pcie device 1/stop/configure/start
>
> Signed-off-by: Jerin Jacob 
> ---
>  lib/librte_eal/bsdapp/eal/eal.c   | 6 +++---
>  lib/librte_eal/linuxapp/eal/eal.c | 6 +++---
>  2 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c
> index 35e3117..2206277 100644
> --- a/lib/librte_eal/bsdapp/eal/eal.c
> +++ b/lib/librte_eal/bsdapp/eal/eal.c
> @@ -577,9 +577,6 @@ rte_eal_init(int argc, char **argv)
>   rte_config.master_lcore, thread_id, cpuset,
>   ret == 0 ? "" : "...");
>
> - if (rte_eal_dev_init() < 0)
> - rte_panic("Cannot init pmd devices\n");
> -
>   RTE_LCORE_FOREACH_SLAVE(i) {
>
>   /*
> @@ -616,6 +613,9 @@ rte_eal_init(int argc, char **argv)
>   if (rte_eal_pci_probe())
>   rte_panic("Cannot probe PCI\n");
>
> + if (rte_eal_dev_init() < 0)
> + rte_panic("Cannot init pmd devices\n");
> +
>   rte_eal_mcfg_complete();
>
>   return fctret;
> diff --git a/lib/librte_eal/linuxapp/eal/eal.c 
> b/lib/librte_eal/linuxapp/eal/eal.c
> index 2075282..16dd5b9 100644
> --- a/lib/librte_eal/linuxapp/eal/eal.c
> +++ b/lib/librte_eal/linuxapp/eal/eal.c
> @@ -841,9 +841,6 @@ rte_eal_init(int argc, char **argv)
>   rte_config.master_lcore, (int)thread_id, cpuset,
>   ret == 0 ? "" : "...");
>
> - if (rte_eal_dev_init() < 0)
> - rte_panic("Cannot init pmd devices\n");
> -
>   if (rte_eal_intr_init() < 0)
>   rte_panic("Cannot init interrupt-handling thread\n");
>
> @@ -887,6 +884,9 @@ rte_eal_init(int argc, char **argv)
>   if (rte_eal_pci_probe())
>   rte_panic("Cannot probe PCI\n");
>
> + if (rte_eal_dev_init() < 0)
> + rte_panic("Cannot init pmd devices\n");
> +
>   rte_eal_mcfg_complete();
>
>   return fctret;
>

Movement looks fine to me.

IMO, rte_eal_dev_init() is a misleading name. It actually performs a 
driver->probe for vdev - which is parallel to rte_eal_pci_probe.

-
Shreyansh


[dpdk-dev] Solarflare PMD submission question

2016-11-21 Thread Ferruh Yigit
On 11/21/2016 8:59 AM, Thomas Monjalon wrote:
> 2016-11-21 11:46, Andrew Rybchenko:
>> On 11/21/2016 11:19 AM, Thomas Monjalon wrote:
 Before submitting 56 patches I'd like to double-check that checkpatch.pl
 errors (for example, because of assignments in the 'if' condition,
 parenthesis around return value) is not a show-stopper for base driver
 import.
>>> You can run checkpatches.sh or send the patches to checkpatch at dpdk.org.
>>> The script check-git-log.sh can also guide you for the expected formatting.
>>
>> Yes, I did it and it helped me to find and fix some coding standard 
>> violations.
>>
>> The problem with libefx (base driver) is that it is existing code which 
>> follows FreeBSD and illumos coding conventions which contradict to 
>> checkpatches.sh sometimes (e.g. require parenthesis around return 
>> value). Other example of error produced by checkpatches.sh is assign in 
>> if. It is widely used in the code to assign return code value and 
>> compare it vs 0 in one line. It is not a coding standard conflict, but 
>> it is very wide-spread in the code (so changing it will produce too many 
>> changes not strictly required/useful).
>>
>> So, may I repeat my question if it is a show-stopper for base driver or 
>> acceptable.
> 
> I would vote to accept these minor style warnings for the base driver.
> Ferruh, any comment?
> 

For _base driver_, I am also OK for having checkpatch warnings.


[dpdk-dev] [PATCH 00/22] Generic flow API (rte_flow)

2016-11-21 Thread NĂ©lio Laranjeiro
Hi,

I found some small issues:

 - In rte_flow_error_set(), *cause argument should be const to avoid a
   compilation error when we implement it.

 - In port_flow_create(), the flow is not stored in the pf structure
   which ends by providing a null pointer to port_flow_destroy()
   function.

Regards,

-- 
N?lio Laranjeiro
6WIND


[dpdk-dev] [PATCH] pmdinfogen: Fix pmdinfogen to select proper endianess on cross-compile

2016-11-21 Thread Bruce Richardson
On Fri, Nov 18, 2016 at 01:47:52PM -0500, Neil Horman wrote:
> pmdinfogen has a bug in which, during build, it pulls in rte_byteorder.h to
> obtain the rte macros for byteswapping between the cpu byte order and big or
> little endian.  Unfortunately, pmdinfogen is a tool that is only meant to be 
> run
> during the build of dpdk components, and so, it runs on the host.  In cross
> compile environments however, the rte_byteorder.h is configured using a target
> cpu, who's endianess may differ from that of the host, leading to improper
> swapping.
> 
> The fix is to use host system defined byte swapping routines rather than the
> dpdk provided routines.  Note that we are using non posix compliant routines, 
> as
> the posix compliant api only addresses 16 and 32 bit swaps, and we also need 
> 64
> bit swaps.  Those macros exist (via endian.h), but BSD and Linux put that 
> header
> in different locations so some ifdeffery is required.
> 
> Tested successfully by myself on Linux and BSD systems.
> 
> Signed-off-by: Neil Horman 
> CC: Hemant Agrawal 
> CC: Jerin Jacob 
> CC: Bruce Richardson 
> CC: Thomas Monjalon 
> ---
>  buildtools/pmdinfogen/pmdinfogen.h | 10 +++---
>  1 file changed, 7 insertions(+), 3 deletions(-)

Compiles fine on FreeBSD with clang.

Tested-by: Bruce Richardson 



[dpdk-dev] [RFC PATCH 0/6] Restructure EAL device model for bus support

2016-11-21 Thread Thomas Monjalon
2016-11-20 16:30, David Marchand:
> For a first patchset, I would see:
> - introduce the rte_bus object. In rte_eal_init, for each bus, we call
> the scan method. Then, for each bus, we find the appropriate
> rte_driver using the bus match method then call the probe method. If
> the probe succeeds, the rte_device points to the associated
> rte_driver,
> - migrate the pci scan code to a pci bus (scan looks at sysfs for
> linux / ioctl for bsd + devargs for blacklist / whitelist ?), match is
> the same at what is done in rte_eal_pci_probe_one_driver() at the
> moment,
> - migrate the vdev init code to a vdev bus (scan looks at devargs):
> this is new, we must create rte_device objects for vdev drivers to use
> later

I think it can be 3 patchsets.
Who can work on the vdev part please?

> Then we can talk about the next steps once the bus is in place.

Yes


[dpdk-dev] [PATCH v2] ethdev: check number of queues less than RTE_ETHDEV_QUEUE_STAT_CNTRS

2016-11-21 Thread Alejandro Lucero
From: Bert van Leeuwen 

Arrays inside rte_eth_stats have size=RTE_ETHDEV_QUEUE_STAT_CNTRS.
Some devices report more queues than that and this code blindly uses
the reported number of queues by the device to fill those arrays up.
This patch fixes the problem using MIN between the reported number of
queues and RTE_ETHDEV_QUEUE_STAT_CNTRS.

Signed-off-by: Alejandro Lucero 
---
 lib/librte_ether/rte_ethdev.c | 25 +
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index fde8112..4209ad0 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -1343,8 +1343,10 @@ get_xstats_count(uint8_t port_id)
} else
count = 0;
count += RTE_NB_STATS;
-   count += dev->data->nb_rx_queues * RTE_NB_RXQ_STATS;
-   count += dev->data->nb_tx_queues * RTE_NB_TXQ_STATS;
+   count += RTE_MIN(dev->data->nb_rx_queues, RTE_ETHDEV_QUEUE_STAT_CNTRS) *
+RTE_NB_RXQ_STATS;
+   count += RTE_MIN(dev->data->nb_tx_queues, RTE_ETHDEV_QUEUE_STAT_CNTRS) *
+RTE_NB_TXQ_STATS;
return count;
 }

@@ -1358,6 +1360,7 @@ rte_eth_xstats_get_names(uint8_t port_id,
int cnt_expected_entries;
int cnt_driver_entries;
uint32_t idx, id_queue;
+   uint16_t num_q;

cnt_expected_entries = get_xstats_count(port_id);
if (xstats_names == NULL || cnt_expected_entries < 0 ||
@@ -1374,7 +1377,8 @@ rte_eth_xstats_get_names(uint8_t port_id,
"%s", rte_stats_strings[idx].name);
cnt_used_entries++;
}
-   for (id_queue = 0; id_queue < dev->data->nb_rx_queues; id_queue++) {
+   num_q = RTE_MIN(dev->data->nb_rx_queues, RTE_ETHDEV_QUEUE_STAT_CNTRS);
+   for (id_queue = 0; id_queue < num_q; id_queue++) {
for (idx = 0; idx < RTE_NB_RXQ_STATS; idx++) {
snprintf(xstats_names[cnt_used_entries].name,
sizeof(xstats_names[0].name),
@@ -1384,7 +1388,8 @@ rte_eth_xstats_get_names(uint8_t port_id,
}

}
-   for (id_queue = 0; id_queue < dev->data->nb_tx_queues; id_queue++) {
+   num_q = RTE_MIN(dev->data->nb_tx_queues, RTE_ETHDEV_QUEUE_STAT_CNTRS);
+   for (id_queue = 0; id_queue < num_q; id_queue++) {
for (idx = 0; idx < RTE_NB_TXQ_STATS; idx++) {
snprintf(xstats_names[cnt_used_entries].name,
sizeof(xstats_names[0].name),
@@ -1420,14 +1425,18 @@ rte_eth_xstats_get(uint8_t port_id, struct 
rte_eth_xstat *xstats,
unsigned count = 0, i, q;
signed xcount = 0;
uint64_t val, *stats_ptr;
+   uint16_t nb_rxqs, nb_txqs;

RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);

dev = _eth_devices[port_id];

+   nb_rxqs = RTE_MIN(dev->data->nb_rx_queues, RTE_ETHDEV_QUEUE_STAT_CNTRS);
+   nb_txqs = RTE_MIN(dev->data->nb_tx_queues, RTE_ETHDEV_QUEUE_STAT_CNTRS);
+
/* Return generic statistics */
-   count = RTE_NB_STATS + (dev->data->nb_rx_queues * RTE_NB_RXQ_STATS) +
-   (dev->data->nb_tx_queues * RTE_NB_TXQ_STATS);
+   count = RTE_NB_STATS + (nb_rxqs * RTE_NB_RXQ_STATS) +
+   (nb_txqs * RTE_NB_TXQ_STATS);

/* implemented by the driver */
if (dev->dev_ops->xstats_get != NULL) {
@@ -1458,7 +1467,7 @@ rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstat 
*xstats,
}

/* per-rxq stats */
-   for (q = 0; q < dev->data->nb_rx_queues; q++) {
+   for (q = 0; q < nb_rxqs; q++) {
for (i = 0; i < RTE_NB_RXQ_STATS; i++) {
stats_ptr = RTE_PTR_ADD(_stats,
rte_rxq_stats_strings[i].offset +
@@ -1469,7 +1478,7 @@ rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstat 
*xstats,
}

/* per-txq stats */
-   for (q = 0; q < dev->data->nb_tx_queues; q++) {
+   for (q = 0; q < nb_txqs; q++) {
for (i = 0; i < RTE_NB_TXQ_STATS; i++) {
stats_ptr = RTE_PTR_ADD(_stats,
rte_txq_stats_strings[i].offset +
-- 
1.9.1



[dpdk-dev] [PATCH 0/4] libeventdev API and northbound implementation

2016-11-21 Thread Bruce Richardson
On Mon, Nov 21, 2016 at 10:40:50AM +0100, Thomas Monjalon wrote:
> 2016-11-19 00:57, Jerin Jacob:
> > On Fri, Nov 18, 2016 at 04:04:29PM +, Bruce Richardson wrote:
> > > On Fri, Nov 18, 2016 at 03:25:18PM +, Bruce Richardson wrote:
> > > > On Fri, Nov 18, 2016 at 11:14:58AM +0530, Jerin Jacob wrote:
> > > > > Possible next steps:
> > > > > 1) Review this patch set
> > > > > 2) Integrate Intel's SW 
> > > > > driver[http://dpdk.org/dev/patchwork/patch/17049/]
> > > > > 3) Review proposed examples/eventdev_pipeline 
> > > > > application[http://dpdk.org/dev/patchwork/patch/17053/]
> > > > > 4) Review proposed functional 
> > > > > tests[http://dpdk.org/dev/patchwork/patch/17051/]
> > > > > 5) Cavium's HW based eventdev driver
> > > > > 
> > > > > I am planning to work on (3),(4) and (5)
> > > > > 
> > > > Thanks Jerin,
> > > > 
> > > > we'll review and get back to you with any comments or feedback (1), and
> > > > obviously start working on item (2) also! :-)
> > > > 
> > > > I'm also wonder whether we should have a staging tree for this work to
> > > > make interaction between us easier. Although this may not be
> > > > finalised enough for 17.02 release, do you think having an
> > > > dpdk-eventdev-next tree would be a help? My thinking is that once we get
> > > > the eventdev library itself in reasonable shape following our review, we
> > > > could commit that and make any changes thereafter as new patches, rather
> > > > than constantly respinning the same set. It also gives us a clean git
> > > > tree to base the respective driver implementations on from our two 
> > > > sides.
> > > > 
> > > > Thomas, any thoughts here on your end - or from anyone else?
> > 
> > I was thinking more or less along the same lines. To avoid re-spinning the
> > same set, it is better to have libeventdev library mark as EXPERIMENTAL
> > and commit it somewhere on dpdk-eventdev-next or main tree
> > 
> > I think, EXPERIMENTAL status can be changed only when
> > - At least two event drivers available
> > - Functional test applications fine with at least two drivers
> > - Portable example application to showcase the features of the library
> > - eventdev integration with another dpdk subsystem such as ethdev
> 
> Are you asking for a temporary tree?
> If yes, please tell its name and its committers, it will be done.

Yes, we are asking for a new tree, but I would not assume it is
temporary - it might be, but it also might not be, given how other
threads are discussing having an increasing number of subtrees giving
pull requests. :-)

Name: dpdk-eventdev-next
Committers: Bruce Richardson & Jerin Jacob

Thanks,
/Bruce.


[dpdk-dev] [PATCH] eal: postpone vdev initialization

2016-11-21 Thread Ferruh Yigit
On 11/20/2016 8:00 AM, Jerin Jacob wrote:
> Some platform like octeontx may use pci and
> vdev based combined device to represent a logical
> dpdk functional device.In such case, postponing the
> vdev initialization after pci device
> initialization will provide the better view of
> the pci device resources in the system in
> vdev's probe function, and it allows better
> functional subsystem registration in vdev probe
> function.
> 
> As a bonus, This patch fixes a bond device
> initialization use case.
> 
> example command to reproduce the issue:
> ./testpmd -c 0x2  --vdev 'eth_bond0,mode=0,
> slave=:02:00.0,slave=:03:00.0' --
> --port-topology=chained
> 
> root cause:
> In existing case(vdev initialization and then pci
> initialization), creates three Ethernet ports with
> following port ids
> 0 - Bond device
> 1 - PCI device 0
> 2 - PCI devive 1
> 
> Since testpmd, calls the configure/start on all the ports on
> start up,it will translate to following illegal setup sequence
> 
> 1)bond device configure/start
> 1.1) pci device0 stop/configure/start
> 1.2) pci device1 stop/configure/start
> 2)pci device 0 configure(illegal setup case,
> as device in start state)
> 
> The fix changes the initialization sequence and
> allow initialization in following valid setup order
> 1) pcie device 0 configure/start
> 2) pcie device 1 configure/start
> 3) bond device 2 configure/start
> 3.1) pcie device 0/stop/configure/start
> 3.2) pcie device 1/stop/configure/start
> 
> Signed-off-by: Jerin Jacob 
> ---

This changes the port id assignments to the devices, right?

Previously virtual devices get first available port ids (0..N1), later
physical devices (N1..N2). Now this becomes reverse.

Can this change break some existing user applications?

Thanks,
ferruh



[dpdk-dev] Proposal for a new Committer model

2016-11-21 Thread Thomas Monjalon
2016-11-18 13:09, Neil Horman:
> A) Further promote subtree maintainership.  This was a conversation that I
> proposed some time ago, but my proposed granularity was discarded in favor
> of something that hasn't worked as well (in my opinion).  That is to say a
> few driver pmds (i40e and fm10k come to mind) have their own tree that
> send pull requests to Thomas.

Yes we tried this fine granularity and stated that it was not working well.
We are now using the bigger granularity that you describe below.

> We should be sharding that at a much higher
> granularity and using it much more consistently.  That is to say, that we
> should have a maintainer for all the ethernet pmds, and another for the
> crypto pmds, another for the core eal layer, another for misc libraries
> that have low patch volumes, etc.

Yes we could open a tree for EAL and another one for the core libraries.

> Each of those subdivisions should have
> their own list to communicate on, and each should have a tree that
> integrates patches for their own subsystem, and they should on a regular
> cycle send pull requests to Thomas.

Yes I think it is now a good idea to split the mailing list traffic,
at least for netdev and cryptodev.

> Thomas in turn should by and large,
> only be integrating pull requests.  This should address our high-
> throughput issue, in that it will allow multiple maintainers to share the
> workload, and integration should be relatively easy.

Yes in an ideal organization, the last committer does only a last check
that technical plan and fairness are respected.
So it gives more time to coordinate the plans :)

> B) Designate alternates to serve as backups for the maintainer when they
> are unavailable.  This provides high-availablility, and sounds very much
> like your proposal, but in the interests of clarity, there is still a
> single maintainer at any one time, it just may change to ensure the
> continued merging of patches, if the primary maintainer isn't available.
> Ideally however, those backup alternates arent needed, because most of the
> primary maintainers work in merging pull requests, which are done based on
> the trust of the submaintainer, and done during a very limited window of
> time.  This also partially addreses multi-vendor fairness if your subtree
> maintainers come from multiple participating companies.

About the merge window, I do not have a strong opinion about how it can be
improved. However, I know that closing the window too early makes developer
unhappy because it makes wait - between development start and its release -
longer.


[dpdk-dev] [RFC PATCH 0/7] RFC: EventDev Software PMD

2016-11-21 Thread Bruce Richardson
On Sat, Nov 19, 2016 at 03:53:25AM +0530, Jerin Jacob wrote:
> On Thu, Nov 17, 2016 at 10:05:07AM +, Bruce Richardson wrote:
> > > 2) device stats API can be based on capability, HW implementations may not
> > > support all the stats
> > 
> > Yes, this is something we were thinking about. It would be nice if we
> > could at least come up with a common set of stats - maybe even ones
> > tracked at an eventdev API level, e.g. nb enqueues/dequeues. As well as
> > that, we think the idea of an xstats API, like in ethdev, might work
> > well. For our software implementation, having visibility into the
> > scheduler behaviour can be important, so we'd like a way to report out
> > things like internal queue depths etc.
> >
> 
> Since these are not very generic hardware, I am not sure how much sense
> to have generic stats API. But, Something similar to ethdev's xstat(any 
> capability based)
> the scheme works well. Look forward to seeing API proposal with common code.
> 
> Jerin
> 
Well, to start off with, some stats that could be tracked at the API
level could be common. What about counts of number of enqueues and
dequeues?

I suppose the other way we can look at this is: once we get a few
implementations of the interface, we can look at the provided xstats
values from each one, and see if there is anything common between them.

/Bruce


[dpdk-dev] Solarflare PMD submission question

2016-11-21 Thread Thomas Monjalon
2016-11-18 19:50, Andrew Rybchenko:
> Now we have a split of the base driver import in big feature steps. The 
> base driver is split into 28 patches. Just only 1 patch exceeds 300K 
> boundary (which add MCDI definitions header).

Good

> Before submitting 56 patches I'd like to double-check that checkpatch.pl 
> errors (for example, because of assignments in the 'if' condition, 
> parenthesis around return value) is not a show-stopper for base driver 
> import.

You can run checkpatches.sh or send the patches to checkpatch at dpdk.org.
The script check-git-log.sh can also guide you for the expected formatting.


[dpdk-dev] Solarflare PMD submission question

2016-11-21 Thread Thomas Monjalon
2016-11-21 11:46, Andrew Rybchenko:
> On 11/21/2016 11:19 AM, Thomas Monjalon wrote:
> >> Before submitting 56 patches I'd like to double-check that checkpatch.pl
> >> errors (for example, because of assignments in the 'if' condition,
> >> parenthesis around return value) is not a show-stopper for base driver
> >> import.
> > You can run checkpatches.sh or send the patches to checkpatch at dpdk.org.
> > The script check-git-log.sh can also guide you for the expected formatting.
> 
> Yes, I did it and it helped me to find and fix some coding standard 
> violations.
> 
> The problem with libefx (base driver) is that it is existing code which 
> follows FreeBSD and illumos coding conventions which contradict to 
> checkpatches.sh sometimes (e.g. require parenthesis around return 
> value). Other example of error produced by checkpatches.sh is assign in 
> if. It is widely used in the code to assign return code value and 
> compare it vs 0 in one line. It is not a coding standard conflict, but 
> it is very wide-spread in the code (so changing it will produce too many 
> changes not strictly required/useful).
> 
> So, may I repeat my question if it is a show-stopper for base driver or 
> acceptable.

I would vote to accept these minor style warnings for the base driver.
Ferruh, any comment?