Re: [dpdk-dev] [PATCH 00/31] Support VFD and DPDK PF + kernel VF on i40e

2016-12-02 Thread Andrew Rybchenko

Hi Bernard,

On 12/02/2016 01:58 PM, Iremonger, Bernard wrote:

-Original Message-
From: dev [mailto:dev-boun...@dpdk.org] On Behalf Of Andrew Rybchenko
Sent: Friday, December 2, 2016 9:00 AM
To: Lu, Wenzhuo <wenzhuo...@intel.com>; dev@dpdk.org
Subject: Re: [dpdk-dev] [PATCH 00/31] Support VFD and DPDK PF + kernel VF
on i40e

On 12/02/2016 03:11 AM, Wenzhuo Lu wrote:

1, VF Daemon (VFD)
VFD is an idea to control all the VFs from PF.
As we need to support the scenario kernel PF + DPDK VF, DPDK follows
the interface between kernel PF + kernel VF. We don't want to
introduce too many new messages between PF and VF. So this patch set
adds some new APIs to control VFs directly from PF.
The new APIs include,
1) set VF MAC anti-spoofing
2) set VF VLAN anti-spoofing
3) set TX loopback
4) set VF unicast promiscuous mode
5) set VF multicast promiscuous mode
6) set VF MTU
7) get/reset VF stats
8) set VF MAC address
9) set VF VLAN stripping
10) VF VLAN insertion
12) set VF broadcast mode
12) set VF VLAN tag
13) set VF VLAN filter
VFD also includes VF to PF mailbox message management by APP. When PF
receives mailbox messages from VF, PF should call the callback
provided by APP to know if they're permitted to be processed.

The patch series adds i40e-specific API functions for VF control (advertise link
status change, MAC anti-spoofing, VLAN anti-spoofing, promiscuous mode,
MAC change, VLAN controls), but RTE API is added to get VF stats. I'm
wondering why.
Corresponding patches do not explain why i40e-specific API is added instead
of generic RTE API. IMHO, it is hardly convenient for applications.
(I guess it was a discussion and decision, but I've failed to find in the 
archive).

Andrew.

There was a discussion previously in DPDK 16.11 about this approach being used 
for the ixgbe PMD.
I have attached the email thread.


Many thanks. I see that it is a staging area waiting for a later 
generalization.


Andrew.


[dpdk-dev] Solarflare PMD submission question

2016-11-18 Thread Andrew Rybchenko
On 10/28/2016 05:43 PM, Andrew Rybchenko wrote:
> On 10/28/2016 03:33 PM, Thomas Monjalon wrote:
>> 2016-10-28 13:50, Andrew Rybchenko:
>>> The only thing which comes to my mind is to split libefx import on 
>>> subsystem
>>> basis (few files per subsystem). It is artificial and added files will
>>> be abandoned
>>> until the patch which adds them into build. It could be something like:
>>>1. External interfaces definition
>>>2. Internal interfaces definition
>>>3. Registers definition (hardware interface)
>>>4. Management CPU interface definition (it is one file, but still 
>>> big
>>> 650K)
>>>5. Management CPU interface implementation
>>> and so on for NIC global controls, interrupts, event queue, transmit,
>>> receive,
>>>filtering etc.
>> Yes it is artificial.
>> The most valuable would be a transversal logical split, kind of feature
>> per feature, in order to explain how the device works.
>
> I'm not the main author of the libefx and personally would consider it 
> very useful.
> From the other hand I understand that it is a huge amount of work to 
> make it.
>
>> Such commit is also the opportunity to explain acronyms and so on.
>
> Good. We'll go this way and 'll do my best to make it useful to 
> understand
> overall structure of the code and how the device works.

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).

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.

Andrew.




[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] [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
  net/sfc

[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-&g

[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];
+   uint

[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 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 re

[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,
+

[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 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] =
+   

[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
+
+exter

[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 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

[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 de

[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_NST

[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;
+   

[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

[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(r

[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 

[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

[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,
+   _

[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 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_TE

[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 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;
+   }
+
+  

[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_ADA

[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. Redistributi

[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_debu

[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_ASSE

[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
 <http://solarflare.com>`_.


+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, &quo

[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
 <http://solarflare.com>`_.


+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 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 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 */
+
+
  

[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 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,
+   _

[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 MERC

[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");
+ 

[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;
   

[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.
+

[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 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 CONT

[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 Fr

[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

[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

[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;

[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,
+   __in 

[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 56/56] net/sfc: add callback to send bursts of packets

2016-11-21 Thread Andrew Rybchenko
From: Ivan Malov <ivan.ma...@oktetlabs.ru>

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;
+ 

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

2016-11-21 Thread Andrew Rybchenko
From: Ivan Malov <ivan.ma...@oktetlabs.ru>

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 <ivan.ma...@oktetlabs.ru>

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-&g

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

2016-11-21 Thread Andrew Rybchenko
From: Artem Andreev <artem.andr...@oktetlabs.ru>

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 DA

[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 <ivan.ma...@oktetlabs.ru>

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_NOXSUMSC

[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 00/56] Solarflare libefx-based PMD

2016-11-23 Thread Andrew Rybchenko
On 11/23/2016 03:02 AM, Ferruh Yigit wrote:
> On 11/21/2016 3:00 PM, Andrew Rybchenko wrote:
>> 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: 

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

2016-11-24 Thread Andrew Rybchenko
On 11/23/2016 10:21 PM, Stephen Hemminger wrote:
> On Wed, 23 Nov 2016 10:49:33 +0300
> Andrew Rybchenko  wrote:
>
>> I've tried to explain it above in item (2):
>>
>>   >>>
>>
>>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.
>>
>> <<<
>>
>> So, main reason is to have location for the code shared by two Solarflare
>> network PMDs. May be it better to relocate when we really have it.
>> I'm open for other ideas/suggestions.
> So is this driver dependent on another non-upstream kernel driver to work?

No, this driver does not have any external dependencies.

> Is this documented in docs directory.  If it does depend on other non-upstream
> components, then the default config should disable the driver.


Andrew.



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

2016-11-24 Thread Andrew Rybchenko
On 11/23/2016 06:26 PM, Ferruh Yigit wrote:
> On 11/21/2016 3:00 PM, Andrew Rybchenko wrote:
>> Reviewed-by: Andy Moreton 
>> Signed-off-by: Andrew Rybchenko 
>> ---
> <...>
>
>> 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
> <...>
>> @@ -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)
> Why not do proper naming in 32/56 at first place?

Thanks, will be fixed in v2.

> <...>




[dpdk-dev] [PATCH 32/56] net/sfc: implement driver operation to init device on attach

2016-11-24 Thread Andrew Rybchenko
On 11/23/2016 06:26 PM, Ferruh Yigit wrote:
> On 11/21/2016 3:00 PM, Andrew Rybchenko wrote:
>> The setup and configuration of the PMD is not performance sensitive,
>> but is not thread safe either. It is possible that the multiple
>> read/writes during PMD setup and configuration could be corrupted
>> in a multi-thread environment.
> Right, this is not thread-safe, but this is valid for all PMDs, it is
> not expected to have initialization in multi-threaded environment, that
> said so, synchronization also won't hurt, as you said this is not fast
> path, just may not be necessary.

In fact further patches really need the lock and it should be introduced and
maintained from the very beginning. I'll add comments in v2 to explain it.

>> Since this is not performance
>> sensitive, the developer can choose to add their own layer to provide
>> thread-safe setup and configuration. It is expected that, in most
>> applications, the initial configuration of the network ports would be
>> done by a single thread at startup.
>>
>> Reviewed-by: Andy Moreton 
>> Signed-off-by: Andrew Rybchenko 
> <...>

Thanks,
Andrew.


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

2016-11-24 Thread Andrew Rybchenko
On 11/23/2016 06:26 PM, Ferruh Yigit wrote:
> On 11/21/2016 3:00 PM, Andrew Rybchenko wrote:
>> Just a stub to be filled in when corresponding functionality is
>> implemented.
> What about merging this stub with real implementation?
> Or perhaps replace with code that adds dummy .dev_configure?

Thanks, I like the second idea. Will do in v2.

>> 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
>>



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

2016-11-24 Thread Andrew Rybchenko
See one question below.

On 11/23/2016 06:26 PM, Ferruh Yigit wrote:
> On 11/21/2016 3:00 PM, Andrew Rybchenko wrote:
>> 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
> clang complain about this one:
> warning: unknown warning option '-Wno-unused-but-set-variable'; did you
> mean '-Wno-unused-const-variable'? [-Wunknown-warning-option]

Will fix in v2

>> +
>> +#
>> +# 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)))
> This cause multiple "-Wno-unused-variable -Wno-unused-but-set-variable"
> params in final command, I guess the intention is:
>
> $(foreach obj, $(BASE_DRIVER_OBJS), $(eval
> CFLAGS_$(obj)+=$(CFLAGS_BASE_DRIVER)))
>
> Fixing this may generate a few compiler warnings.

Many thanks, will fix in v2.

> <...>
>
>> 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 @@
> <...>
>
> I guess below is hardcoded compile time configuration for libefx, do you
> think does it make sense to document this default configuration?

Yes, it is libefx configuration and more options will be enabled when 
corresponding
functionality is supported in the PMD.
I'm sorry, but I don't understand what would you like to see in the 
documentation.
Could you clarify, please?

>> +
>> +#define EFSYS_OPT_NAMES 0
>> +
>> +#define EFSYS_OPT_SIENA 0
>> +#define EFSYS_OPT_HUNTINGTON 1
>> +#define EFSYS_OPT_MEDFORD 1
>> +#ifdef RTE_LIBRTE_SFC_EFX_DEBUG
>> +#define EFSYS_OPT_CHECK_REG 1
>> +#else
>> +#define EFSYS_OPT_CHECK_REG 0
>> +#endif
>> +
>> +#define EFSYS_OPT_MCDI 1
>> +#define EFSYS_OPT_MCDI_LOGGING 0
>> +#define EFSYS_OPT_MCDI_PROXY_AUTH 0
>> +
>> +#define EFSYS_OPT_MAC_STATS 0
>> +
>> +#define EFSYS_OPT_LOOPBACK 0
>> +
>> +#define EFSYS_OPT_MON_MCDI 0
>> +#define EFSYS_OPT_MON_STATS 0
>> +
>> +#define EFSYS_OPT_PHY_STATS 0
>> +#define EFSYS_OPT_BIST 0
>> +#define EFSYS_OPT_PHY_LED_CONTROL 0
>> +#define EFSYS_OPT_PHY_FLAGS 0
>> +
>> +#define EFSYS_OPT_VPD 0
>> +#define EFSYS_OPT_NVRAM 0
>> +#define EFSYS_OPT_BOOTCFG 0
>> +
>> +#define EFSYS_OPT_DIAG 0
>> +#define EFSYS_OPT_RX_SCALE 0
>> +#define EFSYS_OPT_QSTATS 0
>> +#define EFSYS_OPT_FILTER 1
>> +#define EFSYS_OPT_RX_SCATTER 0
>> +
>> +#define EFSYS_OPT_EV_PREFETCH 0
>> +
>> +#define EFSYS_OPT_DECODE_INTR_FATAL 0
>> +
>> +#define EFSYS_OPT_LICENSING 0
>> +
>> +#define EFSYS_OPT_ALLOW_UNCONFIGURED_NIC 0
>> +
>> +#define EFSYS_OPT_RX_PACKED_STREAM 0
> <...>




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

2016-11-24 Thread Andrew Rybchenko
On 11/23/2016 06:26 PM, Ferruh Yigit wrote:
> On 11/21/2016 3:00 PM, Andrew Rybchenko wrote:
>> 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 +
> Can you also update release notes please, to announce new driver.

Thanks, will do in v2.

> <...>
>
>> diff --git a/drivers/net/sfc/efx/Makefile b/drivers/net/sfc/efx/Makefile
>> new file mode 100644
>> index 000..71f07ca
>> --- /dev/null
>> +++ b/drivers/net/sfc/efx/Makefile
>> @@ -0,0 +1,81 @@
> <...>
>> +
>> +include $(RTE_SDK)/mk/rte.vars.mk
>> +
>> +#
>> +# library name
>> +#
>> +LIB = librte_pmd_sfc_efx.a
>> +
>> +CFLAGS += -O3
>> +
>> +# Enable basic warnings but disable some which are accepted
>> +CFLAGS += -Wall
> It is possible to use $(WERROR_FLAGS), which set automatically based on
> selected compiler. See mk/toolchain/* .

Thanks, will do in v2.

> And you can add extra options here, please keep in mind that there are
> three compiler supported right now: gcc, clang and icc. You may require
> to add compiler and version checks..

I've tried to disable the driver build on ICC since we've never tested it.
I've failed to find list of compiler versions which must/should be checked.
I've tested versions which come with RHEL 7.2, Debian Jessie and Sid.
(In v1 I've lost my fixes for clang which produce warnings because of
unsupported -W option)

>> +CFLAGS += -Wno-strict-aliasing
>> +
>> +# Enable extra warnings but disable some which are accepted
>> +CFLAGS += -Wextra
>> +CFLAGS += -Wno-empty-body
>> +CFLAGS += -Wno-sign-compare
>> +CFLAGS += -Wno-type-limits
>> +CFLAGS += -Wno-unused-parameter
> Is there a way to not disable these warnings but fix in the source code?
> Or move to CFLAGS_BASE_DRIVER, if the reason is the base driver?

Will do in v2.

>> +
>> +# More warnings not enabled by above aggregators
>> +CFLAGS += -Waggregate-return
>> +CFLAGS += -Wbad-function-cast
>> +CFLAGS += -Wcast-qual
>> +CFLAGS += -Wdisabled-optimization
>> +CFLAGS += -Wmissing-declarations
>> +CFLAGS += -Wmissing-prototypes
>> +CFLAGS += -Wnested-externs
>> +CFLAGS += -Wold-style-definition
>> +CFLAGS += -Wpointer-arith
>> +CFLAGS += -Wstrict-prototypes
>> +CFLAGS += -Wundef
>> +CFLAGS += -Wwrite-strings
> If you believe some can be useful for everybody, please feel free to add
> to mk/toolchain/* .

I'll definitely remove duplicates which are already included in 
$(WERROR_FLAGS).
I'd prefer to keep the rest just here for now. I think that adding it 
world-wide
requires testing on really many compiler versions etc.

>> +
>> +EXPORT_MAP := rte_pmd_sfc_efx_version.map
>> +
>> +LIBABIVER := 1
>> +
>> +#
>> +# all source are stored in SRCS-y
>> +#
>> +SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += sfc_ethdev.c
>> +SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += sfc_kvargs.c
>> +
>> +
>> +# this lib depends upon:
>> +DEPDIRS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += lib/librte_eal
>> +DEPDIRS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += lib/librte_kvargs
>> +DEPDIRS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += lib/librte_ether
>> +DEPDIRS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += lib/librte_mempool
>> +DEPDIRS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += lib/librte_mbuf
>> +
>> +include $(RTE_SDK)/mk/rte.lib.mk
>> diff --git a/drivers/net/sfc/efx/rte_pmd_sfc_efx_version.map 
>> b/drivers/net/sfc/efx/rte_pmd_sfc_efx_version.map
>> new file mode 100644
>> index 000..1901bcb
>> --- /dev/null
>> +++ b/drivers/net/sfc/efx/rte_pmd_sfc_efx_version.map
>> 

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

2016-11-24 Thread Andrew Rybchenko
On 11/23/2016 06:29 PM, Ferruh Yigit wrote:
> On 11/21/2016 3:00 PM, Andrew Rybchenko wrote:
>> 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/
>>
>> ---
> I would like to note that very well organized patchset. Thank you for
> your effort.

Thanks a lot, it is very pleasant to read it.

Please, see my questions in thread for patches 01/56 (about compiler
versions to test on) and 30/56 (about libefx configuration documentation).

Also I'd like to ask a question about the further patches submission.
We have about 40 patches which support various features (RSS, stats,
flow control and many others). What is the preferred way to submit it?
A. Separately since they are not so tightly related (but in fact cannot be
applied in random order since some touch the same lines in code)
B. As a series to process everything in one go.

Thanks,
Andrew.


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

2016-11-25 Thread Andrew Rybchenko
On 11/25/2016 01:24 PM, Ferruh Yigit wrote:
> On 11/23/2016 7:49 AM, Andrew Rybchenko wrote:
>> On 11/23/2016 03:02 AM, Ferruh Yigit wrote:
>>> On 11/21/2016 3:00 PM, Andrew Rybchenko wrote:
>>>> 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 strea

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

2016-11-25 Thread Andrew Rybchenko
On 11/23/2016 03:02 AM, Ferruh Yigit wrote:
> On 11/21/2016 3:00 PM, Andrew Rybchenko wrote:
>> 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: 

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

2016-11-25 Thread Andrew Rybchenko
On 11/25/2016 04:00 PM, Thomas Monjalon wrote:
> 2016-11-25 12:43, Ferruh Yigit:
>> On 11/25/2016 12:02 PM, Andrew Rybchenko wrote:
>>> On 11/25/2016 01:24 PM, Ferruh Yigit wrote:
>>>> On 11/23/2016 7:49 AM, Andrew Rybchenko wrote:
>>>>> On 11/23/2016 03:02 AM, Ferruh Yigit wrote:
>>>>>> Also folder structure is drivers/net/sfc/efx/, why /sfc/
>>>>>> layer is created?
>>>>>> sfc is company name (solarflare communications), right? Other driver
>>>>>> folders not structured based on company, what about using
>>>>>> drivers/net/efx/* ?
>>>>> I've tried to explain it above in item (2):
>>>>>
>>>>>   >>>
>>>>>
>>>>>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.
>>>>>
>>>>> <<<
>>>>>
>>>>> So, main reason is to have location for the code shared by two Solarflare
>>>>> network PMDs. May be it better to relocate when we really have it.
>>>>> I'm open for other ideas/suggestions.
>>>> If there will be another PMD that shares code with current one, the
>>>> logic seems good, but I am not sure about start using company names, I
>>>> am not against it, just I don't know.
>>> I think that mlx4 and mlx5 are tightly bound to the company name (plus
>>> adapter generation, I guess).
>>>
>>>> Let's relocate later, this buys some time to think / get feedback on issue.
>>> Do I understand correctly that you suggest to avoid extra level inside
>>> for now
>>> and relocate later if required? If so, that's fine for me.
>>>
>>> As for naming, we think that just "efx" is a bad idea. The prefix is
>>> occupied by
>>> the libefx functions and driver should use something else. We have chosen
>>> "sfc" mainly to follow naming used in Linux kernel for Solarflare driver
>>> (the first level of Ethernet driver names is company bound in the Linux
>>> kernel).
>>> If we avoid extra level as discussed above, I think "sfc_efx", "sfcefx"
>>> (may be it
>>> will look better nearby other drivers) or just "sfc" are fine for us.
>>>
>> Thomas, Bruce, any comment on this?
> You can add multiple drivers in the same library. As an example, ixgbe
> directory have several drivers for PF/VF, scalar/vector, etc.
> If you really want separate directories for your drivers while sharing some
> code, you can link some files from the other directory.

Thanks for ideas/examples. I'll remove extra level.

> About the name of this directory, I have no strong opinion.
> sfcefx looks good.

If there is no strong opinion against "sfc" , we'd prefer to keep it:
  1. sfc is used in Linux (and, hopefully, well know)
  2. sfc is shorter and already used in sources
  3. sfc seems to be more future proof if we would like to add more drivers
  inside (efx binds it to libefx)
  4. sfc could be read as well as Solarflare Flareon Controller ;)

Andrew.


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

2016-11-25 Thread Andrew Rybchenko
On 11/25/2016 01:17 PM, Ferruh Yigit wrote:
> On 11/24/2016 3:59 PM, Andrew Rybchenko wrote:
>> On 11/23/2016 06:26 PM, Ferruh Yigit wrote:
>>> On 11/21/2016 3:00 PM, Andrew Rybchenko wrote:
>>>> 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 
>>>> +

<...>

>>> And you can add extra options here, please keep in mind that there are
>>> three compiler supported right now: gcc, clang and icc. You may require
>>> to add compiler and version checks..
>> I've tried to disable the driver build on ICC since we've never tested it.
> I believe we don't support selective config per compiler. Currently if a
> code is enabled by default, it should support compilation with all three
> compilers.

I thought that the following lines in 
config/defconfig_x86_64-native-linuxapp-icc
do the job:
#
# Solarflare PMD build is not supported using icc toolchain
#
CONFIG_RTE_LIBRTE_SFC_EFX_PMD=n

>> I've failed to find list of compiler versions which must/should be checked.
> That list is not clear as far as I know. Mostly version related fixes
> added based on reported build errors. So you can leave as it is right
> now, or can test with default compiler versions of some common
> distributions.

I see. Thanks.

<...>


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

2016-11-25 Thread Andrew Rybchenko
On 11/25/2016 01:24 PM, Ferruh Yigit wrote:
> On 11/24/2016 3:44 PM, Andrew Rybchenko wrote:
>> See one question below.
>>
>> On 11/23/2016 06:26 PM, Ferruh Yigit wrote:
>>> On 11/21/2016 3:00 PM, Andrew Rybchenko wrote:
>>>> 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/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 @@
>>> <...>
>>>
>>> I guess below is hardcoded compile time configuration for libefx, do you
>>> think does it make sense to document this default configuration?
>> Yes, it is libefx configuration and more options will be enabled when
>> corresponding
>> functionality is supported in the PMD.
>> I'm sorry, but I don't understand what would you like to see in the
>> documentation.
>> Could you clarify, please?
> This is mostly a question, following defines how libefx behaves, and a
> little hard to find, do you think does it make sense to document these
> in nic documentation, guides/nics/sfc_efx.rst, to highlight default
> configuration.
>
> Like by default filtering capabilities and SFN7xxx family support
> enabled but 5xxx/6xxx family support disabled... These can be listed in
> a bullet listed way in two groups (default enabled / default disabled) ?

I think that the information about dependencies is not very useful in 
the user
guide documentation. For almost all options is not sufficient just to 
enable it
here. Support in the PMD is required to bind libefx to corresponding 
external
interfaces.

I think it is a good idea to document here why some options are enabled
and why SFN5xxx/SFN6xxx (Siena) support is disabled. Will do in v2.

>>>> +
>>>> +#define   EFSYS_OPT_NAMES 0
>>>> +
>>>> +#define   EFSYS_OPT_SIENA 0
>>>> +#define   EFSYS_OPT_HUNTINGTON 1
>>>> +#define   EFSYS_OPT_MEDFORD 1
>>>> +#ifdef RTE_LIBRTE_SFC_EFX_DEBUG
>>>> +#define   EFSYS_OPT_CHECK_REG 1
>>>> +#else
>>>> +#define   EFSYS_OPT_CHECK_REG 0
>>>> +#endif
>>>> +
>>>> +#define   EFSYS_OPT_MCDI 1
>>>> +#define   EFSYS_OPT_MCDI_LOGGING 0
>>>> +#define   EFSYS_OPT_MCDI_PROXY_AUTH 0
>>>> +
>>>> +#define   EFSYS_OPT_MAC_STATS 0
>>>> +
>>>> +#define   EFSYS_OPT_LOOPBACK 0
>>>> +
>>>> +#define   EFSYS_OPT_MON_MCDI 0
>>>> +#define   EFSYS_OPT_MON_STATS 0
>>>> +
>>>> +#define   EFSYS_OPT_PHY_STATS 0
>>>> +#define   EFSYS_OPT_BIST 0
>>>> +#define   EFSYS_OPT_PHY_LED_CONTROL 0
>>>> +#define   EFSYS_OPT_PHY_FLAGS 0
>>>> +
>>>> +#define   EFSYS_OPT_VPD 0
>>>> +#define   EFSYS_OPT_NVRAM 0
>>>> +#define   EFSYS_OPT_BOOTCFG 0
>>>> +
>>>> +#define   EFSYS_OPT_DIAG 0
>>>> +#define   EFSYS_OPT_RX_SCALE 0
>>>> +#define   EFSYS_OPT_QSTATS 0
>>>> +#define   EFSYS_OPT_FILTER 1
>>>> +#define   EFSYS_OPT_RX_SCATTER 0
>>>> +
>>>> +#define   EFSYS_OPT_EV_PREFETCH 0
>>>> +
>>>> +#define   EFSYS_OPT_DECODE_INTR_FATAL 0
>>>> +
>>>> +#define   EFSYS_OPT_LICENSING 0
>>>> +
>>>> +#define   EFSYS_OPT_ALLOW_UNCONFIGURED_NIC 0
>>>> +
>>>> +#define   EFSYS_OPT_RX_PACKED_STREAM 0
>>> <...>




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

2016-11-29 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/base/efx.h   |  3 ++
 drivers/net/sfc/base/efx_check.h |  7 
 drivers/net/sfc/base/efx_mcdi.c  | 74 
 drivers/net/sfc/base/efx_mcdi.h  | 17 +
 4 files changed, 101 insertions(+)

diff --git a/drivers/net/sfc/base/efx.h b/drivers/net/sfc/base/efx.h
index 9fdfb96..d68a36b 100644
--- a/drivers/net/sfc/base/efx.h
+++ b/drivers/net/sfc/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/base/efx_check.h b/drivers/net/sfc/base/efx_check.h
index 228b42c..470f73c 100644
--- a/drivers/net/sfc/base/efx_check.h
+++ b/drivers/net/sfc/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/base/efx_mcdi.c b/drivers/net/sfc/base/efx_mcdi.c
index a87a223..474c505 100644
--- a/drivers/net/sfc/base/efx_mcdi.c
+++ b/drivers/net/sfc/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 

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

2016-11-29 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 ++
 doc/guides/rel_notes/release_17_02.rst   |   5 ++
 drivers/net/Makefile |   1 +
 drivers/net/sfc/Makefile |  73 +++
 drivers/net/sfc/rte_pmd_sfc_efx_version.map  |   4 +
 drivers/net/sfc/sfc.h|  53 +++
 drivers/net/sfc/sfc_debug.h  |  45 ++
 drivers/net/sfc/sfc_ethdev.c | 129 +++
 drivers/net/sfc/sfc_kvargs.c | 109 ++
 drivers/net/sfc/sfc_kvargs.h |  58 
 drivers/net/sfc/sfc_log.h|  74 +++
 mk/rte.app.mk|   1 +
 24 files changed, 708 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/rte_pmd_sfc_efx_version.map
 create mode 100644 drivers/net/sfc/sfc.h
 create mode 100644 drivers/net/sfc/sfc_debug.h
 create mode 100644 drivers/net/sfc/sfc_ethdev.c
 create mode 100644 drivers/net/sfc/sfc_kvargs.c
 create mode 100644 drivers/net/sfc/sfc_kvargs.h
 create mode 100644 drivers/net/sfc/sfc_log.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 5ec84ad..421cc24 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
--- a/config/defconfig_ppc_64-power8-linuxapp-gcc
+++ b/config/defconfig_ppc_64-power8-linuxapp-gcc
@@ -55,4 +55,5 @@ CONFIG_RTE_LIBRTE_VMXNET3_PMD

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

2016-11-29 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/base/ef10_phy.c  | 4 
 drivers/net/sfc/base/efx.h   | 3 +++
 drivers/net/sfc/base/efx_check.h | 7 +++
 drivers/net/sfc/base/efx_impl.h  | 3 +++
 drivers/net/sfc/base/efx_mcdi.c  | 3 +++
 drivers/net/sfc/base/siena_phy.c | 4 
 6 files changed, 24 insertions(+)

diff --git a/drivers/net/sfc/base/ef10_phy.c b/drivers/net/sfc/base/ef10_phy.c
index 9e1b9c2..c7e584b 100644
--- a/drivers/net/sfc/base/ef10_phy.c
+++ b/drivers/net/sfc/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/base/efx.h b/drivers/net/sfc/base/efx.h
index 22338c5..54d39c2 100644
--- a/drivers/net/sfc/base/efx.h
+++ b/drivers/net/sfc/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/base/efx_check.h b/drivers/net/sfc/base/efx_check.h
index 6f0c216..68c01f3 100644
--- a/drivers/net/sfc/base/efx_check.h
+++ b/drivers/net/sfc/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/base/efx_impl.h b/drivers/net/sfc/base/efx_impl.h
index f776656..489fcbc 100644
--- a/drivers/net/sfc/base/efx_impl.h
+++ b/drivers/net/sfc/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/base/efx_mcdi.c b/drivers/net/sfc/base/efx_mcdi.c
index b14cba1..85c1ac1 100644
--- a/drivers/net/sfc/base/efx_mcdi.c
+++ b/drivers/net/sfc/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/base/siena_phy.c b/drivers/net/sfc/base/siena_phy.c
index d7e7d77..6451298 100644
--- a/drivers/net/sfc/base/siena_phy.c
+++ b/drivers/net/sfc/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 v2 07/55] net/sfc: import libefx MCDI logging support

2016-11-29 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/base/efx.h   | 12 
 drivers/net/sfc/base/efx_check.h |  7 +++
 drivers/net/sfc/base/efx_mcdi.c  | 34 ++
 3 files changed, 53 insertions(+)

diff --git a/drivers/net/sfc/base/efx.h b/drivers/net/sfc/base/efx.h
index 8d0e691..9fdfb96 100644
--- a/drivers/net/sfc/base/efx.h
+++ b/drivers/net/sfc/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/base/efx_check.h b/drivers/net/sfc/base/efx_check.h
index 9d0e988..228b42c 100644
--- a/drivers/net/sfc/base/efx_check.h
+++ b/drivers/net/sfc/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/base/efx_mcdi.c b/drivers/net/sfc/base/efx_mcdi.c
index c11ece9..a87a223 100644
--- a/drivers/net/sfc/base/efx_mcdi.c
+++ b/drivers/net/sfc/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,
+   

[dpdk-dev] [PATCH v2 17/55] net/sfc: import libefx PHY LEDs control support

2016-11-29 Thread Andrew Rybchenko
EFSYS_OPT_PHY_LED_CONTROL should be enabled to use it.

>From Solarflare Communications Inc.

Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/ef10_phy.c  | 19 +
 drivers/net/sfc/base/efx.h   | 20 ++
 drivers/net/sfc/base/efx_check.h |  7 +++
 drivers/net/sfc/base/efx_impl.h  |  3 +++
 drivers/net/sfc/base/efx_mcdi.c  |  5 +
 drivers/net/sfc/base/efx_phy.c   | 45 
 drivers/net/sfc/base/siena_phy.c | 19 +
 7 files changed, 118 insertions(+)

diff --git a/drivers/net/sfc/base/ef10_phy.c b/drivers/net/sfc/base/ef10_phy.c
index b15b693..cc00250 100644
--- a/drivers/net/sfc/base/ef10_phy.c
+++ b/drivers/net/sfc/base/ef10_phy.c
@@ -314,7 +314,26 @@ ef10_phy_reconfigure(
req.emr_out_buf = payload;
req.emr_out_length = MC_CMD_SET_ID_LED_OUT_LEN;

+#if EFSYS_OPT_PHY_LED_CONTROL
+   switch (epp->ep_phy_led_mode) {
+   case EFX_PHY_LED_DEFAULT:
+   led_mode = MC_CMD_LED_DEFAULT;
+   break;
+   case EFX_PHY_LED_OFF:
+   led_mode = MC_CMD_LED_OFF;
+   break;
+   case EFX_PHY_LED_ON:
+   led_mode = MC_CMD_LED_ON;
+   break;
+   default:
+   EFSYS_ASSERT(0);
+   led_mode = MC_CMD_LED_DEFAULT;
+   }
+
+   MCDI_IN_SET_DWORD(req, SET_ID_LED_IN_STATE, led_mode);
+#else
MCDI_IN_SET_DWORD(req, SET_ID_LED_IN_STATE, MC_CMD_LED_DEFAULT);
+#endif /* EFSYS_OPT_PHY_LED_CONTROL */

efx_mcdi_execute(enp, );

diff --git a/drivers/net/sfc/base/efx.h b/drivers/net/sfc/base/efx.h
index d2fe43e..794ba4b 100644
--- a/drivers/net/sfc/base/efx.h
+++ b/drivers/net/sfc/base/efx.h
@@ -463,6 +463,23 @@ extern __checkReturn   efx_rc_t
 efx_phy_verify(
__inefx_nic_t *enp);

+#if EFSYS_OPT_PHY_LED_CONTROL
+
+typedef enum efx_phy_led_mode_e {
+   EFX_PHY_LED_DEFAULT = 0,
+   EFX_PHY_LED_OFF,
+   EFX_PHY_LED_ON,
+   EFX_PHY_LED_FLASH,
+   EFX_PHY_LED_NMODES
+} efx_phy_led_mode_t;
+
+extern __checkReturn   efx_rc_t
+efx_phy_led_set(
+   __inefx_nic_t *enp,
+   __inefx_phy_led_mode_t mode);
+
+#endif /* EFSYS_OPT_PHY_LED_CONTROL */
+
 extern __checkReturn   efx_rc_t
 efx_port_init(
__inefx_nic_t *enp);
@@ -745,6 +762,9 @@ typedef struct efx_nic_cfg_s {
 #if EFSYS_OPT_PHY_FLAGS
uint32_tenc_phy_flags_mask;
 #endif /* EFSYS_OPT_PHY_FLAGS */
+#if EFSYS_OPT_PHY_LED_CONTROL
+   uint32_tenc_led_mask;
+#endif /* EFSYS_OPT_PHY_LED_CONTROL */
 #if EFSYS_OPT_PHY_STATS
uint64_tenc_phy_stat_mask;
 #endif /* EFSYS_OPT_PHY_STATS */
diff --git a/drivers/net/sfc/base/efx_check.h b/drivers/net/sfc/base/efx_check.h
index adda531..4e76dc1 100644
--- a/drivers/net/sfc/base/efx_check.h
+++ b/drivers/net/sfc/base/efx_check.h
@@ -173,6 +173,13 @@
 # endif
 #endif /* EFSYS_OPT_PHY_FLAGS */

+#if EFSYS_OPT_PHY_LED_CONTROL
+/* Support for PHY LED control */
+# if !EFSYS_OPT_SIENA
+#  error "PHY_LED_CONTROL requires SIENA"
+# endif
+#endif /* EFSYS_OPT_PHY_LED_CONTROL */
+
 #ifdef EFSYS_OPT_PHY_NULL
 # error "PHY_NULL is obsolete and is not supported."
 #endif
diff --git a/drivers/net/sfc/base/efx_impl.h b/drivers/net/sfc/base/efx_impl.h
index 2b81768..6077114 100644
--- a/drivers/net/sfc/base/efx_impl.h
+++ b/drivers/net/sfc/base/efx_impl.h
@@ -244,6 +244,9 @@ typedef struct efx_port_s {
 #if EFSYS_OPT_PHY_FLAGS
uint32_tep_phy_flags;
 #endif /* EFSYS_OPT_PHY_FLAGS */
+#if EFSYS_OPT_PHY_LED_CONTROL
+   efx_phy_led_mode_t  ep_phy_led_mode;
+#endif /* EFSYS_OPT_PHY_LED_CONTROL */
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/base/efx_mcdi.c b/drivers/net/sfc/base/efx_mcdi.c
index c5422da..34ba960 100644
--- a/drivers/net/sfc/base/efx_mcdi.c
+++ b/drivers/net/sfc/base/efx_mcdi.c
@@ -1409,6 +1409,11 @@ efx_mcdi_get_phy_cfg(
MCDI_OUT2(req, char, GET_PHY_CFG_OUT_REVISION),
MIN(sizeof (encp->enc_phy_revision) - 1,
MC_CMD_GET_PHY_CFG_OUT_REVISION_LEN));
+#if EFSYS_OPT_PHY_LED_CONTROL
+   encp->enc_led_mask = ((1 << EFX_PHY_LED_DEFAULT) |
+   (1 << EFX_PHY_LED_OFF) |
+   (1 << EFX_PHY_LED_ON));
+#endif /* EFSYS_OPT_PHY_LED_CONTROL */

/* Get the media type of the fixed port, if recognised. */
EFX_STATIC_ASSERT(MC_CMD_MEDIA_XAUI == EFX_PHY_MEDIA_XAUI);
diff --git a/drivers/net/sfc/base/efx_phy.c b/drivers/net/sfc/base/efx_phy.c
index 20debd3..752cd52 100644
--- a/drivers/net/sfc/base/efx_phy.c
+++ b/drivers/net/sfc/base/efx_phy.c
@@ -132,6 +132,51 @@ efx_phy_verify(
return (epop->epo_verify(enp));
 }

+#if EFSYS_OPT_PHY_LED_CONTROL
+
+   __

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

2016-11-29 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/base/efx.h| 159 ++
 drivers/net/sfc/base/efx_check.h  |   5 +
 drivers/net/sfc/base/efx_filter.c | 332 ++
 drivers/net/sfc/base/efx_impl.h   |  38 +
 4 files changed, 534 insertions(+)
 create mode 100644 drivers/net/sfc/base/efx_filter.c

diff --git a/drivers/net/sfc/base/efx.h b/drivers/net/sfc/base/efx.h
index 572520d..1814aef 100644
--- a/drivers/net/sfc/base/efx.h
+++ b/drivers/net/sfc/base/efx.h
@@ -1044,6 +1044,165 @@ 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
+
+/* Use RSS to spread across multiple queues */
+#defineEFX_FILTER_FLAG_RX_RSS  0x01
+/* Enable RX scatter */
+#defineEFX_FILTER_FLAG_RX_SCATTER  0x02
+/*
+ * 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.
+ */
+#defineEFX_FILTER_FLAG_RX_OVER_AUTO0x04
+/* Filter is for RX */
+#defineEFX_FILTER_FLAG_RX  0x08
+/* Filter is for TX */
+#defineEFX_FILTER_FLAG_TX  0x10
+
+typedef unsigned int efx_filter_flags_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 efs_rem_mac[EFX_MAC_ADDR_LEN];
+   uint16_tefs_ether_type;
+   uint8_t efs_ip_proto;
+   uint16_tefs_loc_port;
+   uint16_tefs_rem_port;
+   efx_oword_t efs_rem_host;
+   efx_oword_t efs_loc_host;
+} efx_filter_spec_t;
+
+
+/* Default values for use in filter specifications */
+#def

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

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

>From Solarflare Communications Inc.

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

diff --git a/drivers/net/sfc/base/ef10_ev.c b/drivers/net/sfc/base/ef10_ev.c
index 46ecd42..b4fe9a7 100644
--- a/drivers/net/sfc/base/ef10_ev.c
+++ b/drivers/net/sfc/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/base/ef10_impl.h b/drivers/net/sfc/base/ef10_impl.h
index 1cc6a72..3af5b0a 100644
--- a/drivers/net/sfc/base/ef10_impl.h
+++ b/drivers/net/sfc/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/base/ef10_tx.c b/drivers/net/sfc/base/ef10_tx.c
index 59343a3..aa19cce 100644
--- a/drivers/net/sfc/base/ef10_tx.c
+++ b/drivers/net/sfc/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/base/efx.h b/drivers/net/sfc/base/efx.h
index 84d60b6..22338c5 100644
--- a/drivers/net/sfc/base/efx.h
+++ b/drivers/net/sfc/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,
+   EV_RX_ETH_CRC_ERR,
+   EV_RX_IP_FRAG_E

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

2016-11-29 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-42) implement minimal device level operations in steps
 4. (43-50) implement Rx subsystem
 5. (51-55) 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. 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.

 3. 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/

---

v2:
* Fix spelling
* Fix ICC and clang build warnings
* Remove efx subdirectory
* Fix bug in Makefile which results in duplication of warnings options
* Use WERROR_FLAGS and remove warnings disabling for the PMD itself
* Comment enabled EFSYS_OPT_
* Use space after #define instead of TAB
* Update version map to upcoming release
* Use bool for boolean_t in efsys.h


Andrew Rybchenko (48):
  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 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

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

2016-11-29 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/base/ef10_impl.h  |  10 +++
 drivers/net/sfc/base/ef10_phy.c   |  17 +
 drivers/net/sfc/base/efx.h|  80 
 drivers/net/sfc/base/efx_check.h  |   7 ++
 drivers/net/sfc/base/efx_impl.h   |   4 +
 drivers/net/sfc/base/efx_mcdi.c   |   5 ++
 drivers/net/sfc/base/efx_phy.c|  93 +++
 drivers/net/sfc/base/siena_impl.h |  18 +
 drivers/net/sfc/base/siena_nic.c  |   6 ++
 drivers/net/sfc/base/siena_phy.c  | 152 ++
 10 files changed, 392 insertions(+)

diff --git a/drivers/net/sfc/base/ef10_impl.h b/drivers/net/sfc/base/ef10_impl.h
index 3af5b0a..3efba1f 100644
--- a/drivers/net/sfc/base/ef10_impl.h
+++ b/drivers/net/sfc/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/base/ef10_phy.c b/drivers/net/sfc/base/ef10_phy.c
index c7e584b..b15b693 100644
--- a/drivers/net/sfc/base/ef10_phy.c
+++ b/drivers/net/sfc/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/base/efx.h b/drivers/net/sfc/base/efx.h
index 54d39c2..d2fe43e 100644
--- a/drivers/net/sfc/base/efx.h
+++ b/drivers/net/sfc/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)  uint32_t *stat);
+
+#endif /* EFSYS_OPT_PHY_STATS */
+

 #if EFSYS_OPT_B

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

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

>From Solarflare Communications Inc.

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

diff --git a/drivers/net/sfc/base/ef10_impl.h b/drivers/net/sfc/base/ef10_impl.h
index 697e99b..6afe0bc 100644
--- a/drivers/net/sfc/base/ef10_impl.h
+++ b/drivers/net/sfc/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/base/ef10_nic.c b/drivers/net/sfc/base/ef10_nic.c
index 538e18c..0eb72a7 100644
--- a/drivers/net/sfc/base/ef10_nic.c
+++ b/drivers/net/sfc/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/base/efx.h b/drivers/net/sfc/base/efx.h
index df56aa2..c7108a9 100644
--- a/drivers/net/sfc/base/efx.h
+++ b/drivers/net/sfc/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/base/efx_check.h b/drivers/net/sfc/base/efx_check.h
index ef88645..feaccd0 100644
--- a/drivers/net/sfc/base/efx_check.h
+++ b/drivers/net/sfc/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/base/efx_impl.h b/drivers/net/sfc/base/efx_impl.h
index 97057e4..a7c6b29 100644
--- a/drivers/net/sfc/base/efx_impl.h
+++ b/drivers/net/sfc/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   __efx_sram_pattern_fns[];
+
+typedef struct efx_register_set_s {
+   unsigned intaddres

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

2016-11-29 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/base/efx.h   |  9 +
 drivers/net/sfc/base/efx_check.h |  7 +++
 drivers/net/sfc/base/efx_ev.c| 38 ++
 3 files changed, 54 insertions(+)

diff --git a/drivers/net/sfc/base/efx.h b/drivers/net/sfc/base/efx.h
index abd264a..389fe41 100644
--- a/drivers/net/sfc/base/efx.h
+++ b/drivers/net/sfc/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/base/efx_check.h b/drivers/net/sfc/base/efx_check.h
index 5956052..df46410 100644
--- a/drivers/net/sfc/base/efx_check.h
+++ b/drivers/net/sfc/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/base/efx_ev.c b/drivers/net/sfc/base/efx_ev.c
index 74d146e..c172a06 100644
--- a/drivers/net/sfc/base/efx_ev.c
+++ b/drivers/net/sfc/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 v2 11/55] net/sfc: import libefx SFN8xxx family support

2016-11-29 Thread Andrew Rybchenko
SFN8xxx is the second family based on EF10 architecture.

It has few differences from SFN7xxx adapters family.

EFSYS_OPT_MEDFORD should be enabled to use it.

>From Solarflare Communications Inc.

Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/ef10_impl.h|   6 +-
 drivers/net/sfc/base/efx_check.h|   2 +
 drivers/net/sfc/base/efx_ev.c   |   6 +
 drivers/net/sfc/base/efx_filter.c   |   6 +
 drivers/net/sfc/base/efx_impl.h |   4 +
 drivers/net/sfc/base/efx_intr.c |   6 +
 drivers/net/sfc/base/efx_mac.c  |   7 +
 drivers/net/sfc/base/efx_mcdi.c |   6 +
 drivers/net/sfc/base/efx_nic.c  |  54 +
 drivers/net/sfc/base/efx_phy.c  |   5 +
 drivers/net/sfc/base/efx_rx.c   |   6 +
 drivers/net/sfc/base/efx_tx.c   |  29 +++
 drivers/net/sfc/base/medford_impl.h |  67 ++
 drivers/net/sfc/base/medford_nic.c  | 398 
 14 files changed, 601 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/sfc/base/medford_impl.h
 create mode 100644 drivers/net/sfc/base/medford_nic.c

diff --git a/drivers/net/sfc/base/ef10_impl.h b/drivers/net/sfc/base/ef10_impl.h
index b901ccc..697e99b 100644
--- a/drivers/net/sfc/base/ef10_impl.h
+++ b/drivers/net/sfc/base/ef10_impl.h
@@ -35,8 +35,12 @@
 extern "C" {
 #endif

-#if   EFSYS_OPT_HUNTINGTON
+#if (EFSYS_OPT_HUNTINGTON && EFSYS_OPT_MEDFORD)
+#defineEF10_MAX_PIOBUF_NBUFS   MAX(HUNT_PIOBUF_NBUFS, 
MEDFORD_PIOBUF_NBUFS)
+#elif EFSYS_OPT_HUNTINGTON
 #defineEF10_MAX_PIOBUF_NBUFS   HUNT_PIOBUF_NBUFS
+#elif EFSYS_OPT_MEDFORD
+#defineEF10_MAX_PIOBUF_NBUFS   MEDFORD_PIOBUF_NBUFS
 #endif

 /*
diff --git a/drivers/net/sfc/base/efx_check.h b/drivers/net/sfc/base/efx_check.h
index 63c809c..ef88645 100644
--- a/drivers/net/sfc/base/efx_check.h
+++ b/drivers/net/sfc/base/efx_check.h
@@ -209,7 +209,9 @@

 #if EFSYS_OPT_ALLOW_UNCONFIGURED_NIC
 /* Support adapters with missing static config (for factory use only) */
+# if !EFSYS_OPT_MEDFORD
 #  error "ALLOW_UNCONFIGURED_NIC requires MEDFORD"
+# endif
 #endif /* EFSYS_OPT_ALLOW_UNCONFIGURED_NIC */

 #endif /* _SYS_EFX_CHECK_H */
diff --git a/drivers/net/sfc/base/efx_ev.c b/drivers/net/sfc/base/efx_ev.c
index 65094c1..8cb78be 100644
--- a/drivers/net/sfc/base/efx_ev.c
+++ b/drivers/net/sfc/base/efx_ev.c
@@ -134,6 +134,12 @@ efx_ev_init(
break;
 #endif /* EFSYS_OPT_HUNTINGTON */

+#if EFSYS_OPT_MEDFORD
+   case EFX_FAMILY_MEDFORD:
+   eevop = &__efx_ev_ef10_ops;
+   break;
+#endif /* EFSYS_OPT_MEDFORD */
+
default:
EFSYS_ASSERT(0);
rc = ENOTSUP;
diff --git a/drivers/net/sfc/base/efx_filter.c 
b/drivers/net/sfc/base/efx_filter.c
index 47e2ae4..c878b78 100644
--- a/drivers/net/sfc/base/efx_filter.c
+++ b/drivers/net/sfc/base/efx_filter.c
@@ -165,6 +165,12 @@ efx_filter_init(
break;
 #endif /* EFSYS_OPT_HUNTINGTON */

+#if EFSYS_OPT_MEDFORD
+   case EFX_FAMILY_MEDFORD:
+   efop = &__efx_filter_ef10_ops;
+   break;
+#endif /* EFSYS_OPT_MEDFORD */
+
default:
EFSYS_ASSERT(0);
rc = ENOTSUP;
diff --git a/drivers/net/sfc/base/efx_impl.h b/drivers/net/sfc/base/efx_impl.h
index 10ab36b..97057e4 100644
--- a/drivers/net/sfc/base/efx_impl.h
+++ b/drivers/net/sfc/base/efx_impl.h
@@ -49,6 +49,10 @@
 #include "hunt_impl.h"
 #endif /* EFSYS_OPT_HUNTINGTON */

+#if EFSYS_OPT_MEDFORD
+#include "medford_impl.h"
+#endif /* EFSYS_OPT_MEDFORD */
+
 #if (EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD)
 #include "ef10_impl.h"
 #endif /* (EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD) */
diff --git a/drivers/net/sfc/base/efx_intr.c b/drivers/net/sfc/base/efx_intr.c
index 50cf388..f0422d5 100644
--- a/drivers/net/sfc/base/efx_intr.c
+++ b/drivers/net/sfc/base/efx_intr.c
@@ -150,6 +150,12 @@ efx_intr_init(
break;
 #endif /* EFSYS_OPT_HUNTINGTON */

+#if EFSYS_OPT_MEDFORD
+   case EFX_FAMILY_MEDFORD:
+   eiop = &__efx_intr_ef10_ops;
+   break;
+#endif /* EFSYS_OPT_MEDFORD */
+
default:
EFSYS_ASSERT(B_FALSE);
rc = ENOTSUP;
diff --git a/drivers/net/sfc/base/efx_mac.c b/drivers/net/sfc/base/efx_mac.c
index 1d50128..c10c79a 100644
--- a/drivers/net/sfc/base/efx_mac.c
+++ b/drivers/net/sfc/base/efx_mac.c
@@ -516,6 +516,13 @@ efx_mac_select(
break;
 #endif /* EFSYS_OPT_HUNTINGTON */

+#if EFSYS_OPT_MEDFORD
+   case EFX_FAMILY_MEDFORD:
+   emop = &__efx_ef10_mac_ops;
+   type = EFX_MAC_MEDFORD;
+   break;
+#endif /* EFSYS_OPT_MEDFORD */
+
default:
rc = EINVAL;
goto fail1;
diff --git a/drivers/net/sfc/base/efx_mcdi.c b/drivers/net/sfc/base/efx_mcdi.c
index 338ff49..8d91812 100644
--- a/drivers/net/sfc/base/efx_mcdi.c
+++ b/drivers/net/sfc/base/

[dpdk-dev] [PATCH v2 32/55] net/sfc: add device configure and close stubs

2016-11-29 Thread Andrew Rybchenko
Reviewed-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/sfc.c| 29 ++
 drivers/net/sfc/sfc.h| 29 ++
 drivers/net/sfc/sfc_ethdev.c | 58 
 3 files changed, 111 insertions(+), 5 deletions(-)

diff --git a/drivers/net/sfc/sfc.c b/drivers/net/sfc/sfc.c
index 2a17d26..cbb14d7 100644
--- a/drivers/net/sfc/sfc.c
+++ b/drivers/net/sfc/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/sfc.h b/drivers/net/sfc/sfc.h
index b9a0b0b..c664fb6 100644
--- a/drivers/net/sfc/sfc.h
+++ b/drivers/net/sfc/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;
@@ -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/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c
index 381f90c..ca46b7d 100644
--- a/drivers/net/sfc/sfc_ethdev.c
+++ b/drivers/net/sfc/sfc_ethdev.c
@@ -49,7 +49,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 = dev->data->dev_private;
+
+   sfc_log_init(sa, "entry");
+
+   sfc_adapter_lock(sa);
+   switch (sa->state) {
+   ca

[dpdk-dev] [PATCH v2 35/55] net/sfc: make available resources estimation and allocation

2016-11-29 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/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
 <http://solarflare.com>`_.


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

diff --git a/drivers/net/sfc/sfc.c b/drivers/net/sfc/sfc.c
index 8c780ac..6d5fb9a 100644
--- a/drivers/net/sfc/sfc.c
+++ b/drivers/net/sfc/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 

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

2016-11-29 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/base/efx.h   |   59 ++
 drivers/net/sfc/base/efx_check.h |5 +
 drivers/net/sfc/base/efx_ev.c|   10 +
 drivers/net/sfc/base/efx_impl.h  |   47 ++
 drivers/net/sfc/base/efx_mcdi.c  | 1725 ++
 drivers/net/sfc/base/efx_mcdi.h  |  371 
 drivers/net/sfc/base/efx_nic.c   |6 +
 7 files changed, 2223 insertions(+)
 create mode 100644 drivers/net/sfc/base/efx_mcdi.c
 create mode 100644 drivers/net/sfc/base/efx_mcdi.h

diff --git a/drivers/net/sfc/base/efx.h b/drivers/net/sfc/base/efx.h
index 1814aef..8d0e691 100644
--- a/drivers/net/sfc/base/efx.h
+++ b/drivers/net/sfc/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/base/efx_check.h b/drivers/net/sfc/base/efx_check.h
index 555c184..9d0e988 100644
--- a/drivers/net/sfc/base/efx_check.h
+++ b/drivers/net/sfc/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/base/efx_ev.c b/drivers/net/sfc/base/efx_ev.c
index 2bd365f..942dac6 100644
--- a/drivers/net/sfc/base/efx_ev.c
+++ b/drivers/net/sfc/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 FSE_AZ_EV_CODE_MCDI_EVRESPONSE:
+   

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

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

>From Solarflare Communications Inc.

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

diff --git a/drivers/net/sfc/base/ef10_impl.h b/drivers/net/sfc/base/ef10_impl.h
index 6afe0bc..1cc6a72 100644
--- a/drivers/net/sfc/base/ef10_impl.h
+++ b/drivers/net/sfc/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/base/ef10_phy.c b/drivers/net/sfc/base/ef10_phy.c
index 36e2603..9e1b9c2 100644
--- a/drivers/net/sfc/base/ef10_phy.c
+++ b/drivers/net/sfc/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 v2 28/55] net/sfc: import libefx bootrom configuration support

2016-11-29 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/base/efx.h |  39 +++
 drivers/net/sfc/base/efx_bootcfg.c | 563 +
 drivers/net/sfc/base/efx_check.h   |   7 +
 3 files changed, 609 insertions(+)
 create mode 100644 drivers/net/sfc/base/efx_bootcfg.c

diff --git a/drivers/net/sfc/base/efx.h b/drivers/net/sfc/base/efx.h
index bfa548e..232a62a 100644
--- a/drivers/net/sfc/base/efx.h
+++ b/drivers/net/sfc/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/base/efx_bootcfg.c 
b/drivers/net/sfc/base/efx_bootcfg.c
new file mode 100644
index 000..d589c86
--- /dev/null
+++ b/drivers/net/sfc/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 (enp-&

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

2016-11-29 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/base/ef10_ev.c   |  20 ++
 drivers/net/sfc/base/ef10_nic.c  |  15 +
 drivers/net/sfc/base/efx.h   | 140 +++
 drivers/net/sfc/base/efx_check.h |   7 ++
 drivers/net/sfc/base/efx_ev.c|  18 +
 drivers/net/sfc/base/efx_impl.h  |   4 ++
 drivers/net/sfc/base/efx_mon.c   | 118 +
 drivers/net/sfc/base/siena_nic.c |  12 
 8 files changed, 334 insertions(+)

diff --git a/drivers/net/sfc/base/ef10_ev.c b/drivers/net/sfc/base/ef10_ev.c
index f58ccc6..e93b458 100644
--- a/drivers/net/sfc/base/ef10_ev.c
+++ b/drivers/net/sfc/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/base/ef10_nic.c b/drivers/net/sfc/base/ef10_nic.c
index fec6a69..32706f4 100644
--- a/drivers/net/sfc/base/ef10_nic.c
+++ b/drivers/net/sfc/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/base/efx.h b/drivers/net/sfc/base/efx.h
index 40a7e56..700e45d 100644
--- a/drivers/net/sfc/base/efx.h
+++ b/drivers/net/sfc/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,
+   EF

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

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

>From Solarflare Communications Inc.

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

diff --git a/drivers/net/sfc/base/ef10_impl.h b/drivers/net/sfc/base/ef10_impl.h
index 0e5561e..01c48c8 100644
--- a/drivers/net/sfc/base/ef10_impl.h
+++ b/drivers/net/sfc/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/base/ef10_mac.c b/drivers/net/sfc/base/ef10_mac.c
index 477d0e7..488633f 100644
--- a/drivers/net/sfc/base/ef10_mac.c
+++ b/drivers/net/sfc/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/base/ef10_nic.c b/drivers/net/sfc/base/ef10_nic.c
index f28edd2..fec6a69 100644
--- a/drivers/net/sfc/base/ef10_nic.c
+++ b/drivers/net/sfc/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/base/ef10_phy.c b/drivers/net/sfc/base/ef10_phy.c
index cc00250..81309f2 100644
--- a/drivers/net/sfc/base/ef10_phy.c
+++ b/drivers/net/sfc/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);
+   EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_XGBR == EFX_LOOPBACK_XGBR);

[dpdk-dev] [PATCH v2 38/55] net/sfc: implement EVQ dummy exception handling

2016-11-29 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/sfc_ev.c | 20 ++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/drivers/net/sfc/sfc_ev.c b/drivers/net/sfc/sfc_ev.c
index 2ee579a..42009c0 100644
--- a/drivers/net/sfc/sfc_ev.c
+++ b/drivers/net/sfc/sfc_ev.c
@@ -85,8 +85,24 @@ sfc_ev_exception(void *arg, __rte_unused uint32_t code,
 {
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 v2 29/55] net/sfc: import libefx licensing support

2016-11-29 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/base/efx.h   |  145 
 drivers/net/sfc/base/efx_check.h |   10 +
 drivers/net/sfc/base/efx_impl.h  |   37 +
 drivers/net/sfc/base/efx_lic.c   | 1751 ++
 4 files changed, 1943 insertions(+)
 create mode 100644 drivers/net/sfc/base/efx_lic.c

diff --git a/drivers/net/sfc/base/efx.h b/drivers/net/sfc/base/efx.h
index 232a62a..025721f 100644
--- a/drivers/net/sfc/base/efx.h
+++ b/drivers/net/sfc/base/efx.h
@@ -2351,6 +2351,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,
+   __inuint32_t length,
+   _

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

2016-11-29 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/base/ef10_impl.h  |   63 +++
 drivers/net/sfc/base/ef10_vpd.c   |  463 +
 drivers/net/sfc/base/efx.h|   82 +++
 drivers/net/sfc/base/efx_check.h  |7 +
 drivers/net/sfc/base/efx_impl.h   |   78 +++
 drivers/net/sfc/base/efx_vpd.c| 1016 +
 drivers/net/sfc/base/siena_impl.h |   63 +++
 drivers/net/sfc/base/siena_vpd.c  |  618 ++
 8 files changed, 2390 insertions(+)
 create mode 100644 drivers/net/sfc/base/ef10_vpd.c
 create mode 100644 drivers/net/sfc/base/efx_vpd.c
 create mode 100644 drivers/net/sfc/base/siena_vpd.c

diff --git a/drivers/net/sfc/base/ef10_impl.h b/drivers/net/sfc/base/ef10_impl.h
index e3b2621..192be5d 100644
--- a/drivers/net/sfc/base/ef10_impl.h
+++ b/drivers/net/sfc/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/base/ef10_vpd.c b/drivers/net/sfc/base/ef10_vpd.c
new file mode 100644
index 000..71123a9
--- /dev/null
+++ b/drivers/net/sfc/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.
+ */
+
+#include "efx.h"
+#include "efx_im

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

2016-11-29 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/base/ef10_nic.c  |   3 +
 drivers/net/sfc/base/efx_check.h |   7 +
 drivers/net/sfc/base/efx_ev.c|   3 +
 drivers/net/sfc/base/efx_mon.c   |  21 +-
 drivers/net/sfc/base/hunt_nic.c  |   3 +
 drivers/net/sfc/base/mcdi_mon.c  | 565 +++
 drivers/net/sfc/base/mcdi_mon.h  |  74 +
 7 files changed, 675 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/sfc/base/mcdi_mon.c
 create mode 100644 drivers/net/sfc/base/mcdi_mon.h

diff --git a/drivers/net/sfc/base/ef10_nic.c b/drivers/net/sfc/base/ef10_nic.c
index 32706f4..7af8935 100644
--- a/drivers/net/sfc/base/ef10_nic.c
+++ b/drivers/net/sfc/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/base/efx_check.h b/drivers/net/sfc/base/efx_check.h
index 3e4e9ba..35615e6 100644
--- a/drivers/net/sfc/base/efx_check.h
+++ b/drivers/net/sfc/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/base/efx_ev.c b/drivers/net/sfc/base/efx_ev.c
index ac3ebe3..42ded5a 100644
--- a/drivers/net/sfc/base/efx_ev.c
+++ b/drivers/net/sfc/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/base/efx_mon.c b/drivers/net/sfc/base/efx_mon.c
index 68314cf..c2f1e97 100644
--- a/drivers/net/sfc/base/efx_mon.c
+++ b/drivers/net/sfc/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/base/hunt_nic.c b/drivers/net/sfc/base/hunt_nic.c
index 263f474..c2c4d74 100644
--- a/drivers/net/sfc/base/hunt_nic.c
+++ b/drivers/net/sfc/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/base/mcdi_mon.c b/drivers/net/sfc/base/mcdi_mon.c
new file mode 100644
index 000..c5360c3
--- /dev/null
+++ b/drivers/net/sfc/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 

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

2016-11-29 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/base/README|   36 +
 drivers/net/sfc/base/efx.h | 1067 +++
 drivers/net/sfc/base/efx_check.h   |  171 
 drivers/net/sfc/base/efx_crc32.c   |  122 +++
 drivers/net/sfc/base/efx_ev.c  |  432 ++
 drivers/net/sfc/base/efx_hash.c|  328 +++
 drivers/net/sfc/base/efx_impl.h|  658 ++
 drivers/net/sfc/base/efx_intr.c|  201 +
 drivers/net/sfc/base/efx_mac.c |  489 +++
 drivers/net/sfc/base/efx_mon.c |  118 +++
 drivers/net/sfc/base/efx_nic.c |  549 
 drivers/net/sfc/base/efx_phy.c |  248 ++
 drivers/net/sfc/base/efx_phy_ids.h |   51 ++
 drivers/net/sfc/base/efx_port.c|  151 
 drivers/net/sfc/base/efx_rx.c  |  242 ++
 drivers/net/sfc/base/efx_sram.c|  168 
 drivers/net/sfc/base/efx_tx.c  |  463 ++
 drivers/net/sfc/base/efx_types.h   | 1647 
 18 files changed, 7141 insertions(+)
 create mode 100644 drivers/net/sfc/base/README
 create mode 100644 drivers/net/sfc/base/efx.h
 create mode 100644 drivers/net/sfc/base/efx_check.h
 create mode 100644 drivers/net/sfc/base/efx_crc32.c
 create mode 100644 drivers/net/sfc/base/efx_ev.c
 create mode 100644 drivers/net/sfc/base/efx_hash.c
 create mode 100644 drivers/net/sfc/base/efx_impl.h
 create mode 100644 drivers/net/sfc/base/efx_intr.c
 create mode 100644 drivers/net/sfc/base/efx_mac.c
 create mode 100644 drivers/net/sfc/base/efx_mon.c
 create mode 100644 drivers/net/sfc/base/efx_nic.c
 create mode 100644 drivers/net/sfc/base/efx_phy.c
 create mode 100644 drivers/net/sfc/base/efx_phy_ids.h
 create mode 100644 drivers/net/sfc/base/efx_port.c
 create mode 100644 drivers/net/sfc/base/efx_rx.c
 create mode 100644 drivers/net/sfc/base/efx_sram.c
 create mode 100644 drivers/net/sfc/base/efx_tx.c
 create mode 100644 drivers/net/sfc/base/efx_types.h

diff --git a/drivers/net/sfc/base/README b/drivers/net/sfc/base/README
new file mode 100644
index 000..9019e8b
--- /dev/null
+++ b/drivers/net/sfc/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/base/efx.h b/drivers/net/sfc/base/efx.h
new file mode 100644
index 000..572520d
--- /dev/null
+++ b/drivers/net/sfc/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 code must retain the above copyright notice,
+ *this list of conditions and the following disclaimer.
+ * 2. Redistributions in bin

[dpdk-dev] [PATCH v2 44/55] net/sfc: check configured rxmode

2016-11-29 Thread Andrew Rybchenko
Reviewed-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 doc/guides/nics/sfc_efx.rst | 12 +
 drivers/net/sfc/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/sfc_rx.c b/drivers/net/sfc/sfc_rx.c
index e2c7d00..88e3319 100644
--- a/drivers/net/sfc/sfc_rx.c
+++ b/drivers/net/sfc/sfc_rx.c
@@ -47,6 +47,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.
  *
@@ -58,9 +113,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;
@@ -84,6 +144,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 v2 03/55] net/sfc: import libefx register definitions

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

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

diff --git a/drivers/net/sfc/base/efx_regs.h b/drivers/net/sfc/base/efx_regs.h
new file mode 100644
index 000..a1a7f9d
--- /dev/null
+++ b/drivers/net/sfc/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
+#defineFRF_AB_PCIE_TEST

[dpdk-dev] [PATCH v2 33/55] net/sfc: add device configuration checks

2016-11-29 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/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
 <http://solarflare.com>`_.


+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/sfc.c b/drivers/net/sfc/sfc.c
index cbb14d7..befe68d 100644
--- a/drivers/net/sfc/sfc.c
+++ b/drivers/net/sfc/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 v2 21/55] net/sfc: import libefx RSS support

2016-11-29 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/base/ef10_filter.c |  10 +
 drivers/net/sfc/base/ef10_impl.h   |  29 +++
 drivers/net/sfc/base/ef10_rx.c | 443 +++
 drivers/net/sfc/base/efx.h |  67 ++
 drivers/net/sfc/base/efx_check.h   |   7 +
 drivers/net/sfc/base/efx_ev.c  |  11 +
 drivers/net/sfc/base/efx_filter.c  |   4 +
 drivers/net/sfc/base/efx_impl.h|  14 ++
 drivers/net/sfc/base/efx_rx.c  | 456 +
 9 files changed, 1041 insertions(+)

diff --git a/drivers/net/sfc/base/ef10_filter.c 
b/drivers/net/sfc/base/ef10_filter.c
index 4514160..c161977 100644
--- a/drivers/net/sfc/base/ef10_filter.c
+++ b/drivers/net/sfc/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/base/ef10_impl.h b/drivers/net/sfc/base/ef10_impl.h
index 9d24651..0e5561e 100644
--- a/drivers/net/sfc/base/ef10_impl.h
+++ b/drivers/net/sfc/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/base/ef10_rx.c b/drivers/net/sfc/base/ef10_rx.c
index 95a182b..09a6314 100644
--- a/drivers/net/sfc/base/ef10_rx.c
+++ b/drivers/net/sfc/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 = EMSGSIZE;
+   goto fa

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

2016-11-29 Thread Andrew Rybchenko
From: Artem Andreev <artem.andr...@oktetlabs.ru>

Implement efsys.h for the PMD.

Reviewed-by: Andy Moreton 
Signed-off-by: Artem Andreev 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/Makefile |  62 +++-
 drivers/net/sfc/efsys.h  | 773 +++
 2 files changed, 834 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/sfc/efsys.h

diff --git a/drivers/net/sfc/Makefile b/drivers/net/sfc/Makefile
index 827b183..80d35f6 100644
--- a/drivers/net/sfc/Makefile
+++ b/drivers/net/sfc/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
 CFLAGS += $(WERROR_FLAGS)

@@ -42,16 +44,33 @@ CFLAGS += -Wextra
 # More warnings not enabled by above aggregators
 CFLAGS += -Wdisabled-optimization

+# Extra CFLAGS for base driver files
+CFLAGS_BASE_DRIVER += -Wno-sign-compare
+CFLAGS_BASE_DRIVER += -Wno-unused-parameter
+CFLAGS_BASE_DRIVER += -Wno-unused-variable
+
 # Compiler and version dependent flags
 ifeq ($(CONFIG_RTE_TOOLCHAIN_GCC),y)
 CFLAGS += -Waggregate-return
-CFLAGS += -Wbad-function-cast
+CFLAGS += -Wnested-externs
+CFLAGS_BASE_DRIVER += -Wno-empty-body
+CFLAGS_BASE_DRIVER += -Wno-unused-but-set-variable
 else ifeq ($(CONFIG_RTE_TOOLCHAIN_CLANG),y)
 CFLAGS += -Waggregate-return
 CFLAGS += -Wbad-function-cast
+CFLAGS_BASE_DRIVER += -Wno-empty-body
 else ifeq ($(CONFIG_RTE_TOOLCHAIN_ICC),y)
+CFLAGS_BASE_DRIVER += -Wno-unused-but-set-variable
 endif

+#
+# 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_$(obj)+=$(CFLAGS_BASE_DRIVER)))
+
 EXPORT_MAP := rte_pmd_sfc_efx_version.map

 LIBABIVER := 1
@@ -62,6 +81,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/efsys.h b/drivers/net/sfc/efsys.h
new file mode 100644
index 000..e4d5035
--- /dev/null
+++ b/drivers/net/sfc/efsys.h
@@ -0,0 +1,773 @@
+/*-
+ * 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 cond

[dpdk-dev] [PATCH v2 37/55] net/sfc: implement event queue support

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

diff --git a/drivers/net/sfc/Makefile b/drivers/net/sfc/Makefile
index d19497c..3286fd8 100644
--- a/drivers/net/sfc/Makefile
+++ b/drivers/net/sfc/Makefile
@@ -83,6 +83,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/sfc.c b/drivers/net/sfc/sfc.c
index d66ea4a..6870efe 100644
--- a/drivers/net/sfc/sfc.c
+++ b/drivers/net/sfc/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/sfc.h b/drivers/net/sfc/sfc.h
index 102a324..cbad989 100644
--- a/drivers/net/sfc/sfc.h
+++ b/drivers/net/sfc/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/sfc_ev.c b/drivers/net/sfc/sfc_ev.c
new file mode 100644
index 000..2ee579a
--- /dev/null
+++ b/drivers/net/sfc/sfc_ev.c
@@ -0,0 +1,482 @@
+/*-
+ * 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"
+
+
+/

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

2016-11-29 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/base/ef10_ev.c|   6 +
 drivers/net/sfc/base/ef10_impl.h  |  17 ++
 drivers/net/sfc/base/ef10_mac.c   | 415 ++
 drivers/net/sfc/base/ef10_nic.c   |  10 +
 drivers/net/sfc/base/efx.h| 175 
 drivers/net/sfc/base/efx_check.h  |   7 +
 drivers/net/sfc/base/efx_ev.c |   6 +
 drivers/net/sfc/base/efx_impl.h   |  29 +++
 drivers/net/sfc/base/efx_mac.c| 305 
 drivers/net/sfc/base/efx_mcdi.c   | 158 +++
 drivers/net/sfc/base/siena_impl.h |  17 ++
 drivers/net/sfc/base/siena_mac.c  | 235 +
 drivers/net/sfc/base/siena_nic.c  |  10 +
 13 files changed, 1390 insertions(+)

diff --git a/drivers/net/sfc/base/ef10_ev.c b/drivers/net/sfc/base/ef10_ev.c
index b4fe9a7..f58ccc6 100644
--- a/drivers/net/sfc/base/ef10_ev.c
+++ b/drivers/net/sfc/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/base/ef10_impl.h b/drivers/net/sfc/base/ef10_impl.h
index 3efba1f..7635e80 100644
--- a/drivers/net/sfc/base/ef10_impl.h
+++ b/drivers/net/sfc/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/base/ef10_mac.c b/drivers/net/sfc/base/ef10_mac.c
index 7960067..477d0e7 100644
--- a/drivers/net/sfc/base/ef10_mac.c
+++ b/drivers/net/sfc/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) {
+   const s

[dpdk-dev] [PATCH v2 40/55] net/sfc: periodic management EVQ polling using alarm

2016-11-29 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/sfc_ev.c | 42 ++
 1 file changed, 42 insertions(+)

diff --git a/drivers/net/sfc/sfc_ev.c b/drivers/net/sfc/sfc_ev.c
index a6a1ee2..179c4f8 100644
--- a/drivers/net/sfc/sfc_ev.c
+++ b/drivers/net/sfc/sfc_ev.c
@@ -29,6 +29,7 @@

 #include 
 #include 
+#include 

 #include "efx.h"

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

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

 static boolean_t
 sfc_ev_initialized(void *arg)
@@ -328,6 +332,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)
 {
@@ -349,6 +381,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.
 */
@@ -371,6 +411,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



  1   2   >