Re: [dpdk-dev] [PATCH 1/2] eal: add API to align integer to previous power of 2

2018-02-19 Thread Pavan Nikhilesh
Hi Matan,

On Sun, Feb 18, 2018 at 06:11:20AM +, Matan Azrad wrote:
> Hi Pavan
>
> Please see some comments below.
>
>  From: Pavan Nikhilesh, Saturday, February 17, 2018 12:50 PM
> > Add 32b and 64b API's to align the given integer to the previous power of 2.
> >
> > Signed-off-by: Pavan Nikhilesh 
> > ---
> >  lib/librte_eal/common/include/rte_common.h | 36
> > ++
> >  1 file changed, 36 insertions(+)
> >
> > diff --git a/lib/librte_eal/common/include/rte_common.h
> > b/lib/librte_eal/common/include/rte_common.h
> > index c7803e41c..126914f07 100644
> > --- a/lib/librte_eal/common/include/rte_common.h
> > +++ b/lib/librte_eal/common/include/rte_common.h
> > @@ -259,6 +259,24 @@ rte_align32pow2(uint32_t x)
> > return x + 1;
> >  }
> >
> > +/**
> > + * Aligns input parameter to the previous power of 2
> > + *
> > + * @param x
> > + *   The integer value to algin
> > + *
> > + * @return
> > + *   Input parameter aligned to the previous power of 2
>
> I think the zero case(x=0) result should be documented.

The existing API i.e. rte_align32pow2() behaves in similar manner i.e. returns
0 when 0 is passed.

>
> > + */
> > +static inline uint32_t
> > +rte_align32lowpow2(uint32_t x)
>
> What do you think about " rte_align32prevpow2"?

I think rte_align32prevpow2() fits better will modify and send v2.

>
> > +{
> > +   x = rte_align32pow2(x);
>
>   In case of  x is power of 2 number(already aligned), looks like the 
> result here is x and the final result is (x >> 1)?
>   Is it as you expect?

I overlooked that bit while trying to make use of the existing API, will modify
the implementation to return x if its already a power of 2.

>
> > +   x--;
> > +
> > +   return x - (x >> 1);
>
> Why can't the implementation just be:
> return  rte_align32pow2(x) >> 1;
>
> If the above is correct, Are you sure we need this API?
>
> > +}
> > +
> >  /**
> >   * Aligns 64b input parameter to the next power of 2
> >   *
> > @@ -282,6 +300,24 @@ rte_align64pow2(uint64_t v)
> > return v + 1;
> >  }
> >
> > +/**
> > + * Aligns 64b input parameter to the previous power of 2
> > + *
> > + * @param v
> > + *   The 64b value to align
> > + *
> > + * @return
> > + *   Input parameter aligned to the previous power of 2
> > + */
> > +static inline uint64_t
> > +rte_align64lowpow2(uint64_t v)
> > +{
> > +   v = rte_align64pow2(v);
> > +   v--;
> > +
> > +   return v - (v >> 1);
> > +}
> > +
>
> Same comments for 64b API.
>
> >  /*** Macros for calculating min and max **/
> >
> >  /**
> > --
> > 2.16.1
>
>
> If it is a new API, I think it should be added to the map file and to be 
> tagged as experimental. No?

Static inline functions need not be a part of map files, as for experimental
tag I don't think its needed for a math API. I don't have a strong opinion
tagging it experimental, if it is really needed I will send a re-do the patch
marking it experimental.

>
> Matan

Thanks,
Pavan


Re: [dpdk-dev] [PATCH 08/10] event/octeontx: add option to use fpavf as chunk pool

2018-02-19 Thread Pavan Nikhilesh
Hi Santosh,

On Sun, Feb 18, 2018 at 05:12:33PM +0530, santosh wrote:
> Hi Pavan,
>
>
> On Saturday 17 February 2018 03:06 AM, Pavan Nikhilesh wrote:
> > Add compile-time configurable option to force TIMvf to use Octeontx
> > FPAvf pool manager as its chunk pool.
> > When FPAvf is used as pool manager the TIMvf automatically frees the
> > chunks to FPAvf through gpool-id.
> >
> > Signed-off-by: Pavan Nikhilesh 
> > ---
> >  config/common_base|  1 +
> >  drivers/event/octeontx/timvf_evdev.c  | 23 +++
> >  drivers/event/octeontx/timvf_evdev.h  |  3 +++
> >  drivers/event/octeontx/timvf_worker.h | 35 
> > +++
> >  4 files changed, 62 insertions(+)
> >
> > diff --git a/config/common_base b/config/common_base
> > index ad03cf433..00010de92 100644
> > --- a/config/common_base
> > +++ b/config/common_base
> > @@ -562,6 +562,7 @@ CONFIG_RTE_LIBRTE_PMD_SW_EVENTDEV=y
> >  # Compile PMD for octeontx sso event device
> >  #
> >  CONFIG_RTE_LIBRTE_PMD_OCTEONTX_SSOVF=y
> > +CONFIG_RTE_PMD_OCTEONTX_TIMVF_USE_FPAVF=n
> >
>
> How about using CONFIG_RTE_LIBRTE_OCTEONTX_MEMPOOL?

I think CONFIG_RTE_LIBRTE_OCTEONTX_MEMPOOL is always enabled by default,using
something like CONFIG_RTE_LIBRTE_TIMVF_USE_OCTEONTX_MEMPOOL be better? i.e
telling TIMvf to specifically use fpa.

>
> >  #
> >  # Compile PMD for OPDL event device
> > diff --git a/drivers/event/octeontx/timvf_evdev.c 
> > b/drivers/event/octeontx/timvf_evdev.c
> > index ffdfbb387..386eaa08f 100644
> > --- a/drivers/event/octeontx/timvf_evdev.c
> > +++ b/drivers/event/octeontx/timvf_evdev.c
> > @@ -162,10 +162,27 @@ timvf_ring_start(const struct rte_event_timer_adapter 
> > *adptr)
> > 1ull << 48 |
> > 1ull << 47 |
> > 1ull << 44 |
> > +#ifndef RTE_PMD_OCTEONTX_TIMVF_USE_FPAVF
> > +   1ull << 43 |
> > +#endif
> > (timr->meta.nb_bkts - 1);
> >
> > rctrl.rctrl2 = (uint64_t)(TIM_CHUNK_SIZE / 16) << 40;
> >
> > +#ifdef RTE_PMD_OCTEONTX_TIMVF_USE_FPAVF
> > +   uintptr_t pool;
> > +   pool = (uintptr_t)((struct rte_mempool *)
> > +   timr->meta.chunk_pool)->pool_id;
> > +   ret = octeontx_fpa_bufpool_gpool(pool);
> > +   if (ret < 0) {
> > +   timvf_log_dbg("Unable to get gaura id");
> > +   ret = -ENOMEM;
> > +   goto error;
> > +   }
> > +   timvf_write64((uint64_t)ret,
> > +   (uint8_t *)timr->vbar0 + TIM_VRING_AURA);
> > +#endif
> > +
> > timvf_write64((uint64_t)timr->meta.bkt,
> > (uint8_t *)timr->vbar0 + TIM_VRING_BASE);
> > if (timvf_ring_conf_set(&rctrl, timr->tim_ring_id)) {
> > @@ -296,9 +313,15 @@ timvf_ring_create(struct rte_event_timer_adapter 
> > *adptr)
> > return -ENOMEM;
> > }
> >
> > +#ifdef RTE_PMD_OCTEONTX_TIMVF_USE_FPAVF
> > +   ret = rte_mempool_set_ops_byname(timr->meta.chunk_pool,
> > +   "octeontx_fpavf", NULL);
> > +   timvf_log_dbg("Giving back chunks to fpa gaura : %d", ret);
> > +#else
> > ret = rte_mempool_set_ops_byname(timr->meta.chunk_pool,
> > RTE_MBUF_DEFAULT_MEMPOOL_OPS, NULL);
> > timvf_log_dbg("Not giving back chunks to fpa");
> > +#endif
> >
>
> May be use rte_mbuf_best_mempool_ops Or rte_mbuf_user_mempool_ops,
> that way avoid above ifdef.

In timvf_worker.h the logic used to arm the event timer changes with the
mempool used i.e. octeontx_fpavf has a different implementation vs ring.
We could use rte_mbuf_best_mempool_ops() but again need check if the
returned ops is fpa to enable automatic buffer recycling.

>
> Also a suggestion, Try to reduce ifdef by creating a new header file
> called timvf_fpa_evdev.h, abstract all possible ifdefs their,
> create small static inline API and call them in timvf eventdev driver.
> [...]

Agreed, will modify arm logic to reduce ifdef clutter.

>
> Thanks.
>

Thanks,
Pavan.


Re: [dpdk-dev] [PATCH 02/10] mempool/octeontx: probe timvf PCIe devices

2018-02-19 Thread Pavan Nikhilesh
On Sat, Feb 17, 2018 at 10:24:07AM +0530, Jerin Jacob wrote:
> -Original Message-
> > Date: Sat, 17 Feb 2018 03:06:52 +0530
> > From: Pavan Nikhilesh 
> > To: jerin.ja...@caviumnetworks.com, santosh.shu...@caviumnetworks.com,
> >  erik.g.carri...@intel.com
> > Cc: dev@dpdk.org, Pavan Nikhilesh 
> > Subject: [dpdk-dev] [PATCH 02/10] mempool/octeontx: probe timvf PCIe devices
> > X-Mailer: git-send-email 2.16.1
> >
> > On Octeontx HW, each event timer device is enumerated as separate SRIOV VF
> > PCIe device.
> >
> > In order to expose as a event timer device:
> > On PCIe probe, the driver stores the information associated with the
> > PCIe device and later when appliacation requests for a event timer device
> > through `rte_event_timer_adapter_create` the driver infrastructure creates
> > the timer adapter with earlier probed PCIe VF devices.
> >
> > Signed-off-by: Pavan Nikhilesh 
> > ---
> >  drivers/mempool/octeontx/Makefile  |   1 +
> >  drivers/mempool/octeontx/meson.build   |   1 +
> >  drivers/mempool/octeontx/octeontx_mbox.h   |   7 +
> >  drivers/mempool/octeontx/octeontx_timvf.c  | 145 
> > +
> >  .../octeontx/rte_mempool_octeontx_version.map  |   3 +
> >  usertools/dpdk-devbind.py  |   8 ++
>
> I suggest to have separate patch for usertools/dpdk-devbind.py
> common code change.
>
> > diff --git a/usertools/dpdk-devbind.py b/usertools/dpdk-devbind.py
> > index 18d938607..340643b70 100755
> > --- a/usertools/dpdk-devbind.py
> > +++ b/usertools/dpdk-devbind.py
> > @@ -22,11 +22,14 @@
> >'SVendor': None, 'SDevice': None}
> >  cavium_pkx = {'Class': '08', 'Vendor': '177d', 'Device': 'a0dd,a049',
> >'SVendor': None, 'SDevice': None}
> > +cavium_tim = {'Class': '08', 'Vendor': '177d', 'Device': 'a051',
> > +  'SVendor': None, 'SDevice': None}
> >
> >  network_devices = [network_class, cavium_pkx]
> >  crypto_devices = [encryption_class, intel_processor_class]
> >  eventdev_devices = [cavium_sso]
> >  mempool_devices = [cavium_fpa]
> > +eventtimer_devices = [cavium_tim]
>
> In order to reduce number of different type of device, IMO, we could
> group this also as "eventdev_devices" as it comes as sub device of
> eventdev.
>
> ie.
> eventdev_devices = [cavium_sso, cavium_tim]

Agreed, will do the specified changes and send it as a sperate patch.

Thanks,
Pavan.


Re: [dpdk-dev] [PATCH 07/10] event/octeontx: optimize timer adapter resolution parameters

2018-02-19 Thread Pavan Nikhilesh
On Sat, Feb 17, 2018 at 10:36:24AM +0530, Jerin Jacob wrote:
> -Original Message-
> > Date: Sat, 17 Feb 2018 03:06:57 +0530
> > From: Pavan Nikhilesh 
> > To: jerin.ja...@caviumnetworks.com, santosh.shu...@caviumnetworks.com,
> >  erik.g.carri...@intel.com
> > Cc: dev@dpdk.org, Pavan Nikhilesh 
> > Subject: [dpdk-dev] [PATCH 07/10] event/octeontx: optimize timer adapter
> >  resolution parameters
> > X-Mailer: git-send-email 2.16.1
> >
> > When application sets `RTE_EVENT_TIMER_ADAPTER_F_ADJUST_RES` flag
> > while creating adapter underlying driver is free to optimize the
> > resolution for best possible configuration.
> >
> > Signed-off-by: Pavan Nikhilesh 
> > ---
> >  drivers/event/octeontx/timvf_evdev.c | 51 
> > +++-
> >  drivers/event/octeontx/timvf_evdev.h |  6 +
> >  2 files changed, 56 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/event/octeontx/timvf_evdev.c 
> > b/drivers/event/octeontx/timvf_evdev.c
> > index 6cf5d4846..ffdfbb387 100644
> > --- a/drivers/event/octeontx/timvf_evdev.c
> > +++ b/drivers/event/octeontx/timvf_evdev.c
> > @@ -82,6 +82,48 @@ timvf_get_start_cyc(uint64_t *now, uint8_t ring_id)
> > return octeontx_ssovf_mbox_send(&hdr, NULL, 0, now, sizeof(uint64_t));
> >  }
> >
> > +#define ALIGN_CEIL(a, b) \
> > +   (((a + (typeof(a)) b - 1) / ((typeof(a)) b)) * (typeof(a))b)
> > +
>
> Can this moved to common code if this not already available?
>
Currently, align macros support aligning given value to a power of 2 and not
to a given multiple.
Will move this to common code and send a seperate patch.



[dpdk-dev] Linking with -ldpdk

2018-02-19 Thread tom . barbette
Hi list,

I found out that to staticly compile against DPDK using the combined lib, I 
needed all these options :

-I${RTE_SDK}/${RTE_TARGET}/include -L${RTE_SDK}/${RTE_TARGET}/lib 
-Wl,--whole-archive -ldpdk -Wl,--no-whole-archive -lnuma -ldl -lpthread -lm 
-lmlx4 -lmlx5 -libverbs

The whole-archive makes sense, as we need to embed drivers that wouldn't be 
found at linking time (failing to include it prevents port discovery).
However it leads to missing inclusion. That's why I added all the libs at the 
end of the line. The mlx4 libs particularly leads me to think that there must 
be a more programmatic way, portable accross versions of DPDK to find out which 
libraries referenced in DPDK I should include, right? Morveover if the DPDK 
user didn't include mlx4, it will fail to compile...

What should I use? (the whole rte.extapp.mk DPDK build process is not an option 
as the build system is rather complex in this project)

Or maybe some of these libraries should be included in the dpdk static lib?

I use the last git version (but it's the same problem with previous ones).

Thanks,

Tom


Re: [dpdk-dev] Linking with -ldpdk

2018-02-19 Thread Bruce Richardson
On Mon, Feb 19, 2018 at 10:39:39AM +0100, tom.barbe...@uliege.be wrote:
> Hi list,
> 
> I found out that to staticly compile against DPDK using the combined lib, I 
> needed all these options :
> 
> -I${RTE_SDK}/${RTE_TARGET}/include -L${RTE_SDK}/${RTE_TARGET}/lib 
> -Wl,--whole-archive -ldpdk -Wl,--no-whole-archive -lnuma -ldl -lpthread -lm 
> -lmlx4 -lmlx5 -libverbs
> 
> The whole-archive makes sense, as we need to embed drivers that wouldn't be 
> found at linking time (failing to include it prevents port discovery).
> However it leads to missing inclusion. That's why I added all the libs at the 
> end of the line. The mlx4 libs particularly leads me to think that there must 
> be a more programmatic way, portable accross versions of DPDK to find out 
> which libraries referenced in DPDK I should include, right? Morveover if the 
> DPDK user didn't include mlx4, it will fail to compile...
> 
> What should I use? (the whole rte.extapp.mk DPDK build process is not an 
> option as the build system is rather complex in this project)
> 
> Or maybe some of these libraries should be included in the dpdk static lib?
> 
> I use the last git version (but it's the same problem with previous ones).
> 
> Thanks,
> 
> Tom

Hi Tom,

this is something that I was hoping to achieve using pkg-config files
generated by the meson build system. This is still a work in progress,
but you can use "ninja install" to install a pkg-config file for DPDK at
the end of the build process, and the Makefiles for the DPDK examples
show how to build a static binary using that information. 

Now the limitations: there is no support for building all of DPDK as a
single static library, but pkg-config does provide the list of all DPDK
libs and drivers individually, as well as a list of the extra lib names
that have to be added to the end. [Given what pkg-config provides, I
fail to see the need to produce the single .a file any more too] Sadly
for the use case you mention above, the mlx* drivers aren't available as
part of the build yet either.

In the meantime, while the gaps are being filled out, any feedback on
building using pkg-config output would be appreciated. I admit it is a
bit more geared towards shared library building, but static should work
also.

Regards,
/Bruce


Re: [dpdk-dev] [RFC v2, 2/2] eventdev: add crypto adapter API header

2018-02-19 Thread Gujjar, Abhinandan S
Hi Jerin,

Thanks for the review. Please find few comments inline.

> -Original Message-
> From: Jerin Jacob [mailto:jerin.ja...@caviumnetworks.com]
> Sent: Saturday, February 17, 2018 1:04 AM
> To: Gujjar, Abhinandan S 
> Cc: dev@dpdk.org; Vangati, Narender ; Rao,
> Nikhil ; Eads, Gage ;
> hemant.agra...@nxp.com; akhil.go...@nxp.com;
> narayanaprasad.athr...@cavium.com; nidadavolu.mur...@cavium.com;
> nithin.dabilpu...@cavium.com
> Subject: Re: [RFC v2, 2/2] eventdev: add crypto adapter API header
> 
> -Original Message-
> > Date: Mon, 15 Jan 2018 16:23:50 +0530
> > From: Abhinandan Gujjar 
> > To: jerin.ja...@caviumnetworks.com
> > CC: dev@dpdk.org, narender.vang...@intel.com, Abhinandan Gujjar
> > , Nikhil Rao , Gage
> > Eads 
> > Subject: [RFC v2, 2/2] eventdev: add crypto adapter API header
> > X-Mailer: git-send-email 1.9.1
> >
> > Add crypto event adapter APIs to support packet transfer mechanism
> > between cryptodev and event device.
> >
> > Signed-off-by: Abhinandan Gujjar 
> > Signed-off-by: Nikhil Rao 
> > Signed-off-by: Gage Eads 
> > ---
> 
> Overall it looks good to me. Though I have some confusion over ENQ-DEQ
> scheme. May be it will be get cleared along with implementation.
> 
> > Notes:
> > V2:
> > 1. Updated type as ENQ-DEQ in rte_event_crypto_adapter_type
> > 2. Removed enum rte_event_crypto_conf_type
> > 3. Updated struct rte_event_crypto_metadata
> > 4. Removed struct rte_event_crypto_queue_pair_conf
> > 5. Updated rte_event_crypto_adapter_queue_pair_add() API
> >
> >  lib/librte_eventdev/Makefile   |   1 +
> >  lib/librte_eventdev/rte_event_crypto_adapter.h | 452
> > +
> 
> 1) Please update MAINTAINERS file
> 2) Add meson build support
> 3) Update doc/api/doxy-api-index.md file and check the doxygen output using
> "make doc-api-html"
> 4) Please add the programmers guide in doc/guides/prog_guide/
Sure
> 
> >
> > +++ b/lib/librte_eventdev/rte_event_crypto_adapter.h
> > @@ -0,0 +1,452 @@
> > +/*
> > + *   Copyright(c) 2018 Intel Corporation. All rights reserved.
> > + *   All rights reserved.
> > + *
> > + *   Redistribution and use in source and binary forms, with or without
> 
> Use SPDX tag scheme
Ok
> 
> > +#ifndef _RTE_EVENT_CRYPTO_ADAPTER_
> > +#define _RTE_EVENT_CRYPTO_ADAPTER_
> > +
> > +/**
> > + * This adapter adds support to enqueue crypto completions to event device.
> > + * The packet flow from cryptodev to the event device can be
> > +accomplished
> > + * using both SW and HW based transfer mechanisms.
> > + * The adapter uses a EAL service core function for SW based packet
> > +transfer
> > + * and uses the eventdev PMD functions to configure HW based packet
> > +transfer
> > + * between the cryptodev and the event device.
> > + *
> > + * In the case of SW based transfers, application can choose to
> > +submit a
> 
> I think, we can remove "In the case of SW based transfers" as it should be
> applicable for HW case too
Ok. In that case, adapter will detect the presence of HW connection between
cryptodev & eventdev and will not dequeue crypto completions.

> 
> > + * crypto operation directly to cryptodev or send it  to the
> > + cryptodev
> > + * adapter via eventdev, the cryptodev adapter then submits the
> > + crypto
> > + * operation to the crypto device. The first mode is known as the
> 
> The first mode (DEQ) is very clear. In the second mode(ENQ_DEQ),
> - How does "worker" submits the crypto work through crypto-adapter?
> If I understand it correctly, "workers" always deals with only cryptodev's
> rte_cryptodev_enqueue_burst() API and "service" function in crypto adapter
> would be responsible for dequeue() from cryptodev and enqueue to eventdev?
> 
> I understand the need for OP_NEW vs OP_FWD mode difference in both modes.
> Other than that, What makes ENQ_DEQ different? Could you share the flow for
> ENQ_DEQ mode with APIs.

/*
Application changes for ENQ_DEQ mode:
-
/* In ENQ_DEQ mode, to enqueue to adapter app
 * has to fill out following details.
 */
struct rte_event_crypto_request *req;
struct rte_crypto_op *op = rte_crypto_op_alloc();

/* fill request info */
req = (void *)((char *)op + op.private_data_offset);
req->cdev_id = 1;
req->queue_pair_id = 1;

/* fill response info */
...

/* send event to crypto adapter */
ev->event_ptr = op;
ev->queue_id = dst_event_qid;
ev->priority = dst_priority;
ev->sched_type = dst_sched_type;
ev->event_type = RTE_EVENT_TYPE_CRYPTODEV;
ev->sub_event_type = sub_event_type;
ev->flow_id = dst_flow_id;
ret = rte_event_enqueue_burst(event_dev_id, event_port_id, ev, 1);


Adapter in ENQ_DEQ mode, submitting crypto ops to cryptodev:
-
n = rte_event_dequeue_b

[dpdk-dev] [PATCH v2 1/2] eal: add API to align integer to previous power of 2

2018-02-19 Thread Pavan Nikhilesh
Add 32b and 64b API's to align the given integer to the previous power
of 2.

Signed-off-by: Pavan Nikhilesh 
---
 v2 Changes:
 - Modified api name to `rte_align(32/64)prevpow2` from
 `rte_align(32/64)lowpow2`.
 - corrected fuction to return if the integer is already aligned to
 power of 2.

 lib/librte_eal/common/include/rte_common.h | 43 ++
 1 file changed, 43 insertions(+)

diff --git a/lib/librte_eal/common/include/rte_common.h 
b/lib/librte_eal/common/include/rte_common.h
index c7803e41c..b2017ee5c 100644
--- a/lib/librte_eal/common/include/rte_common.h
+++ b/lib/librte_eal/common/include/rte_common.h
@@ -259,6 +259,27 @@ rte_align32pow2(uint32_t x)
return x + 1;
 }

+/**
+ * Aligns input parameter to the previous power of 2
+ *
+ * @param x
+ *   The integer value to algin
+ *
+ * @return
+ *   Input parameter aligned to the previous power of 2
+ */
+static inline uint32_t
+rte_align32prevpow2(uint32_t x)
+{
+   x |= x >> 1;
+   x |= x >> 2;
+   x |= x >> 4;
+   x |= x >> 8;
+   x |= x >> 16;
+
+   return x - (x >> 1);
+}
+
 /**
  * Aligns 64b input parameter to the next power of 2
  *
@@ -282,6 +303,28 @@ rte_align64pow2(uint64_t v)
return v + 1;
 }

+/**
+ * Aligns 64b input parameter to the previous power of 2
+ *
+ * @param v
+ *   The 64b value to align
+ *
+ * @return
+ *   Input parameter aligned to the previous power of 2
+ */
+static inline uint64_t
+rte_align64prevpow2(uint64_t v)
+{
+   v |= v >> 1;
+   v |= v >> 2;
+   v |= v >> 4;
+   v |= v >> 8;
+   v |= v >> 16;
+   v |= v >> 32;
+
+   return v - (v >> 1);
+}
+
 /*** Macros for calculating min and max **/

 /**
--
2.16.1



[dpdk-dev] [PATCH v2 2/2] test: update common auto test

2018-02-19 Thread Pavan Nikhilesh
Update common auto test to include test for previous power of 2 for both
32 and 64bit integers.

Signed-off-by: Pavan Nikhilesh 
---
 test/test/test_common.c | 24 
 1 file changed, 24 insertions(+)

diff --git a/test/test/test_common.c b/test/test/test_common.c
index d0342430f..2115cc78f 100644
--- a/test/test/test_common.c
+++ b/test/test/test_common.c
@@ -80,6 +80,7 @@ test_align(void)
val / pow != (i / pow) + 1) /* if not 
aligned, hence +1 */
 
uint32_t i, p, val;
+   uint64_t j, q;
 
for (i = 1, p = 1; i <= MAX_NUM; i ++) {
if (rte_align32pow2(i) != p)
@@ -88,6 +89,29 @@ test_align(void)
p <<= 1;
}
 
+   for (i = 1, p = 1; i <= MAX_NUM; i++) {
+   if (rte_align32prevpow2(i) != p)
+   FAIL_ALIGN("rte_align32prevpow2", i, p);
+   if (rte_is_power_of_2(i + 1))
+   p = i + 1;
+   }
+
+   for (j = 1, q = 1; j <= MAX_NUM ; j++) {
+   if (rte_align64pow2(j) != q)
+   printf("rte_align64pow2() test failed: %lu %lu\n", j,
+   q);
+   if (j == q)
+   q <<= 1;
+   }
+
+   for (j = 1, q = 1; j <= MAX_NUM ; j++) {
+   if (rte_align64prevpow2(j) != q)
+   printf("rte_align64prevpow2() test failed: %lu %lu\n",
+   j, q);
+   if (rte_is_power_of_2(j + 1))
+   q = j + 1;
+   }
+
for (p = 2; p <= MAX_NUM; p <<= 1) {
 
if (!rte_is_power_of_2(p))
-- 
2.16.1



Re: [dpdk-dev] [PATCH v2 1/2] eal: add API to align integer to previous power of 2

2018-02-19 Thread Matan Azrad

Hi Pavan
> From: Pavan Nikhilesh, Monday, February 19, 2018 1:37 PM
> Add 32b and 64b API's to align the given integer to the previous power of 2.
> 
> Signed-off-by: Pavan Nikhilesh 
> ---
>  v2 Changes:
>  - Modified api name to `rte_align(32/64)prevpow2` from
> `rte_align(32/64)lowpow2`.
>  - corrected fuction to return if the integer is already aligned to  power of 
> 2.
> 
>  lib/librte_eal/common/include/rte_common.h | 43
> ++
>  1 file changed, 43 insertions(+)
> 
> diff --git a/lib/librte_eal/common/include/rte_common.h
> b/lib/librte_eal/common/include/rte_common.h
> index c7803e41c..b2017ee5c 100644
> --- a/lib/librte_eal/common/include/rte_common.h
> +++ b/lib/librte_eal/common/include/rte_common.h
> @@ -259,6 +259,27 @@ rte_align32pow2(uint32_t x)
>   return x + 1;
>  }
> 
> +/**
> + * Aligns input parameter to the previous power of 2
> + *
> + * @param x
> + *   The integer value to algin
> + *
> + * @return
> + *   Input parameter aligned to the previous power of 2
> + */
> +static inline uint32_t
> +rte_align32prevpow2(uint32_t x)
> +{
> + x |= x >> 1;
> + x |= x >> 2;
> + x |= x >> 4;
> + x |= x >> 8;
> + x |= x >> 16;
> +
> + return x - (x >> 1);
> +}

Nice.

Since you are using the same 5 lines from the rte_align32pow2() function, I 
think this part can be in a separate function to do reuse.
Also the "fill ones 32" function can be used for other purpose.
What do you think?
 

>  /**
>   * Aligns 64b input parameter to the next power of 2
>   *
> @@ -282,6 +303,28 @@ rte_align64pow2(uint64_t v)
>   return v + 1;
>  }
> 
> +/**
> + * Aligns 64b input parameter to the previous power of 2
> + *
> + * @param v
> + *   The 64b value to align
> + *
> + * @return
> + *   Input parameter aligned to the previous power of 2
> + */
> +static inline uint64_t
> +rte_align64prevpow2(uint64_t v)
> +{
> + v |= v >> 1;
> + v |= v >> 2;
> + v |= v >> 4;
> + v |= v >> 8;
> + v |= v >> 16;
> + v |= v >> 32;
> +
> + return v - (v >> 1);
> +}
> +
>  /*** Macros for calculating min and max **/
> 
>  /**
> --
> 2.16.1



Re: [dpdk-dev] [PATCH] net/e1000: add mac_addr_set set to em

2018-02-19 Thread David Marchand
On Mon, Feb 19, 2018 at 1:39 AM, Chas Williams <3ch...@gmail.com> wrote:
> From: Chas Williams 
>
> Based on the equivalent code in the igb driver.
>
> Signed-off-by: Chas Williams 
> ---
>  drivers/net/e1000/em_ethdev.c | 12 
>  1 file changed, 12 insertions(+)
>
> diff --git a/drivers/net/e1000/em_ethdev.c b/drivers/net/e1000/em_ethdev.c
> index 242375f..5bb9cc9 100644
> --- a/drivers/net/e1000/em_ethdev.c
> +++ b/drivers/net/e1000/em_ethdev.c
> @@ -94,6 +94,8 @@ static int em_get_rx_buffer_size(struct e1000_hw *hw);
>  static int eth_em_rar_set(struct rte_eth_dev *dev, struct ether_addr 
> *mac_addr,
>   uint32_t index, uint32_t pool);
>  static void eth_em_rar_clear(struct rte_eth_dev *dev, uint32_t index);
> +static void eth_em_default_mac_addr_set(struct rte_eth_dev *dev,
> +struct ether_addr *addr);
>
>  static int eth_em_set_mc_addr_list(struct rte_eth_dev *dev,
>struct ether_addr *mc_addr_set,
> @@ -190,6 +192,7 @@ static const struct eth_dev_ops eth_em_ops = {
> .dev_led_off  = eth_em_led_off,
> .flow_ctrl_get= eth_em_flow_ctrl_get,
> .flow_ctrl_set= eth_em_flow_ctrl_set,
> +   .mac_addr_set = eth_em_default_mac_addr_set,
> .mac_addr_add = eth_em_rar_set,
> .mac_addr_remove  = eth_em_rar_clear,
> .set_mc_addr_list = eth_em_set_mc_addr_list,
> @@ -1809,6 +1812,15 @@ eth_em_rar_clear(struct rte_eth_dev *dev, uint32_t 
> index)
> e1000_rar_set(hw, addr, index);
>  }
>
> +static void
> +eth_em_default_mac_addr_set(struct rte_eth_dev *dev,
> +   struct ether_addr *addr)
> +{
> +   eth_em_rar_clear(dev, 0);
> +
> +   eth_em_rar_set(dev, (void *)addr, 0, 0);
> +}
> +

Even if copied from igb, this cast is unneeded.
I wrote a similar patch which was in the "upstream" queue, so looks good to me.

Reviewed-by: David Marchand 


-- 
David Marchand


[dpdk-dev] [PATCH] net/enic: add primary mac address handler

2018-02-19 Thread David Marchand
Reused the .mac_addr_add and .mac_addr_del callbacks code to implement
primary mac address handler.

Signed-off-by: David Marchand 
---
 drivers/net/enic/enic_ethdev.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/net/enic/enic_ethdev.c b/drivers/net/enic/enic_ethdev.c
index 669dbf336..802fd3623 100644
--- a/drivers/net/enic/enic_ethdev.c
+++ b/drivers/net/enic/enic_ethdev.c
@@ -610,6 +610,13 @@ static void enicpmd_remove_mac_addr(struct rte_eth_dev 
*eth_dev, uint32_t index)
enic_del_mac_address(enic, index);
 }
 
+static void enicpmd_set_mac_addr(struct rte_eth_dev *eth_dev,
+   struct ether_addr *addr)
+{
+   enicpmd_remove_mac_addr(eth_dev, 0);
+   enicpmd_add_mac_addr(eth_dev, addr, 0, 0);
+}
+
 static int enicpmd_mtu_set(struct rte_eth_dev *eth_dev, uint16_t mtu)
 {
struct enic *enic = pmd_priv(eth_dev);
@@ -657,6 +664,7 @@ static const struct eth_dev_ops enicpmd_eth_dev_ops = {
.priority_flow_ctrl_set = NULL,
.mac_addr_add = enicpmd_add_mac_addr,
.mac_addr_remove  = enicpmd_remove_mac_addr,
+   .mac_addr_set = enicpmd_set_mac_addr,
.filter_ctrl  = enicpmd_dev_filter_ctrl,
 };
 
-- 
2.11.0



[dpdk-dev] 17.11.1 patches review and test

2018-02-19 Thread Yuanhan Liu
Hi all,

Here is a list of patches targeted for LTS release 17.11.1. Please
help review and test. The planned date for the final release is 27th,
Feb. Before that, please shout if anyone has objections with these
patches being applied.

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

Thanks.

--yliu

---
Adrien Mazarguil (7):
  net/mlx4: fix unnecessary include
  net/i40e: fix ISO C in exported header
  flow_classify: fix ISO C in exported header
  member: fix ISO C in exported header
  lib: fix missing includes in exported headers
  net/failsafe: fix invalid free
  net/mlx4: fix drop flow resources leak

Ajit Khaparde (7):
  net/bnxt: fix double increment of idx during Tx ring alloc
  net/bnxt: parse checksum offload flags
  net/bnxt: fix group info usage
  net/bnxt: fix check for ether type
  net/bnxt: fix size of Tx ring in HW
  net/bnxt: fix number of pools for RSS
  net/bnxt: fix return code in MAC address set

Akhil Goyal (2):
  security: fix enum start value
  examples/ipsec-secgw: fix corner case for SPI value

Alejandro Lucero (3):
  net/nfp: fix MTU settings
  net/nfp: fix jumbo settings
  net/nfp: fix CRC strip check behaviour

Anatoly Burakov (16):
  memzone: fix leak on allocation error
  malloc: protect stats with lock
  malloc: fix end for bounded elements
  vfio: fix enabled check on error
  app/procinfo: add compilation option in config
  test: register test as failed if setup failed
  test/table: fix uninitialized parameter
  test/memzone: fix wrong test
  member: fix memory leak on error
  usertools/devbind: fix kernel module reporting
  test/bitmap: fix memory leak
  test/reorder: fix memory leak
  test/ring: fix memory leak
  test/ring_perf: fix memory leak
  test/table: fix memory leak
  test/timer_perf: fix memory leak

Andrea Grandi (2):
  doc: fix lists of supported crypto algorithms
  doc: fix format in OpenSSL installation guide

Andrew Rybchenko (7):
  net/sfc: stop periodic DMA if MAC stats upload fails
  net/sfc: fix multicast address list copy memory leak
  net/sfc: fix DMA memory leak after kvarg processing failure
  net/sfc: fix label name to be consistent
  net/sfc: do not hold management event queue lock while MCDI
  net/sfc: fix incorrect bitwise ORing of L3/L4 packet types
  mempool: fix physical contiguous check

Andriy Berestovskyy (1):
  keepalive: fix state alignment

Anoob Joseph (1):
  examples/ipsec-secgw: fix usage of incorrect port

Ashish Jain (1):
  net/dpaa: fix the mbuf packet type if zero

Bao-Long Tran (1):
  examples/ip_pipeline: fix timer period unit

Beilei Xing (12):
  net/i40e: fix VLAN offload setting issue
  net/i40e: fix FDIR input set conflict
  net/i40e: fix FDIR rule confiliction issue
  net/i40e: fix setting MAC address of VF
  net/i40e: fix flow director Rx resource defect
  net/i40e: warn when writing global registers
  net/i40e: add debug logs when writing global registers
  net/i40e: fix multiple driver support
  net/i40e: fix interrupt conflict with multi-driver
  net/i40e: fix Rx interrupt
  net/i40e: check multi-driver option parsing
  app/testpmd: fix flow director filter

Chas Williams (1):
  net/bonding: fix setting slave MAC addresses

David Harton (1):
  net/i40e: fix VF reset stats crash

Didier Pallard (1):
  net/virtio: fix incorrect cast

Erik Gabriel Carrillo (1):
  timer: fix reset on service cores

Ferruh Yigit (4):
  kni: fix build with kernel 4.15
  mk: remove TILE-Gx machine type
  bus/dpaa: fix build when assert enabled
  kni: fix build dependency

Fiona Trahe (1):
  crypto/qat: fix null auth algo overwrite

Gage Eads (2):
  eventdev: set error code in port link/unlink functions
  event/sw: fix queue memory leak and multi-link bug

Gowrishankar Muthukrishnan (1):
  eal/ppc: remove the braces in memory barrier macros

Harish Patil (5):
  net/qede: fix to enable LRO over tunnels
  net/qede: fix to reject config with no Rx queue
  net/qede: check tunnel L3 header
  net/qede: fix tunnel header size in Tx BD configuration
  net/qede/base: fix VF LRO tunnel configuration

Harry van Haaren (3):
  service: fix lcore role after delete
  service: fix service core launch
  service: fix possible mem leak on initialize

Hemant Agrawal (10):
  pmdinfogen: fix cross compilation for ARM big endian
  lpm: fix ARM big endian build
  bus/dpaa: fix ARM big endian build
  net/i40e: fix ARM big endian build
  net/ixgbe: fix ARM big endian build
  bus/fslmc: fix the cplusplus macro closure
  drivers: change the deprecated memseg physaddr to IOVA
  net/dpaa: fix uninitialized and unused variables
  net/dpaa: fix FW version code

Re: [dpdk-dev] [PATCH 0/8] vhost: input validation enhancements

2018-02-19 Thread Maxime Coquelin



On 02/05/2018 01:16 PM, Stefan Hajnoczi wrote:

This patch series addresses missing input validation that I came across when
reviewing vhost_user.c.

The first patch explains the security model and the rest fixes places with
missing checks.

Now is a good time to discuss the security model if anyone disagrees or has
questions about what Patch 1 says.

Stefan Hajnoczi (8):
   vhost: add security model documentation to vhost_user.c
   vhost: avoid enum fields in VhostUserMsg
   vhost: validate untrusted memory.nregions field
   vhost: clear out unused SCM_RIGHTS file descriptors
   vhost: reject invalid log base mmap_offset values
   vhost: fix msg->payload union typo in vhost_user_set_vring_addr()
   vhost: validate virtqueue size
   vhost: check for memory_size + mmap_offset overflow

  lib/librte_vhost/vhost_user.h |  4 +--
  lib/librte_vhost/socket.c |  8 +-
  lib/librte_vhost/vhost_user.c | 57 +--
  3 files changed, 64 insertions(+), 5 deletions(-)



Applied to dpdk-next-virtio.

Thanks,
Maxime


Re: [dpdk-dev] [PATCH 1/2] eal: add API to align integer to previous power of 2

2018-02-19 Thread Wiles, Keith


> On Feb 19, 2018, at 12:03 AM, Matan Azrad  wrote:
> 
> 
>> 
>> Is this the type of API that needs to be marked experimental,
> 
> I think it is relevant to any exposed API(not only for internal libraries).
> 
>> we should be able to prove these functions, correct?
> 
> Don't we need to prove any function in DPDK?
> What is your point?


My point is this is a inline function and can not be placed in the .map file as 
a external API. These simple type of APIs are easy to prove and making them 
experimental seems to just cause an extra step. If the functions are not 
required that is a different problem or if the API is really only ever used by 
a single function or module of files then it should be moved to the module/file 
and made locate to the module/file.

> 
>>> Matan
>> 
>> Regards,
>> Keith

Regards,
Keith



Re: [dpdk-dev] Linking with -ldpdk

2018-02-19 Thread Neil Horman
On Mon, Feb 19, 2018 at 10:39:39AM +0100, tom.barbe...@uliege.be wrote:
> Hi list,
> 
> I found out that to staticly compile against DPDK using the combined lib, I 
> needed all these options :
> 
> -I${RTE_SDK}/${RTE_TARGET}/include -L${RTE_SDK}/${RTE_TARGET}/lib 
> -Wl,--whole-archive -ldpdk -Wl,--no-whole-archive -lnuma -ldl -lpthread -lm 
> -lmlx4 -lmlx5 -libverbs
> 
> The whole-archive makes sense, as we need to embed drivers that wouldn't be 
> found at linking time (failing to include it prevents port discovery).
> However it leads to missing inclusion. That's why I added all the libs at the 
> end of the line. The mlx4 libs particularly leads me to think that there must 
> be a more programmatic way, portable accross versions of DPDK to find out 
> which libraries referenced in DPDK I should include, right? Morveover if the 
> DPDK user didn't include mlx4, it will fail to compile...
> 
Thats really the problem with static linking, theres no built-in dependency
tracking, the way the DT_NEEDED entries provide in dynamic linking.  The build
environment is responsible for understanding the libraries needed to resolve all
the symbols that an application and its libraries require at compile time.  In
the case of the mlx drivers, I beleive there is an effort to break the symbol
dependency by using the dlopen interface to resolve those symbols at run time,
but the scope of that effort is strictly for the mellanox drivers.  You still
need to manually track the numa, pthreead, math, etc libraries.

> What should I use? (the whole rte.extapp.mk DPDK build process is not an 
> option as the build system is rather complex in this project)
> 
I'd recommend building dpdk as a shared library.  Then the DSO embodies the
subordonate libraries that have to be loaded by the linker at run time, and you
don't have to worry about it at all.  You just have to link with -ldpdk (the
shared build creates a linker script called dpdk.so that automagically pulls in
all the component DSOs).

> Or maybe some of these libraries should be included in the dpdk static lib?
> 
Thats not a scalable solution.  Some libraries don't have static versions that
you can link to (or don't have versions that build commonly as such).  And even
if they do, determining if you need to link them is a bit of a trick.  As Bruce
notes, he's trying to use package-config to solve the problem, but that tool
isnt meant for conditional compilation.  

> I use the last git version (but it's the same problem with previous ones).
> 
> Thanks,
> 
> Tom
> 


Re: [dpdk-dev] [PATCH 1/2] eal: add API to align integer to previous power of 2

2018-02-19 Thread Matan Azrad
Hi Wiles

From: Wiles, Keith, Monday, February 19, 2018 3:56 PM
> > On Feb 19, 2018, at 12:03 AM, Matan Azrad  wrote:
> >> Is this the type of API that needs to be marked experimental,
> >
> > I think it is relevant to any exposed API(not only for internal libraries).
> >
> >> we should be able to prove these functions, correct?
> >
> > Don't we need to prove any function in DPDK?
> > What is your point?
> 
> 
> My point is this is a inline function and can not be placed in the .map file 
> as a
> external API.

Doesn't each API in .h file external? Why not?
If it shouldn't be external and should be in .h file, I think it should be 
marked as internal, no?

> These simple type of APIs are easy to prove and making them
> experimental seems to just cause an extra step.

As Thomas mentioned here:
https://dpdk.org/ml/archives/dev/2018-January/087719.html

Any new API should be experimental.

Thomas, Is it different for .h file inline APIs?
 
> If the functions are not required that is a different problem or if the API 
> is really only ever used by a
> single function or module of files then it should be moved to the module/file
> and made locate to the module/file.

Agree.
Looks like this function makes sense and may be used by other modules later.



Re: [dpdk-dev] [PATCH 1/2] eal: add API to align integer to previous power of 2

2018-02-19 Thread Wiles, Keith


> On Feb 19, 2018, at 8:13 AM, Matan Azrad  wrote:
> 
> Hi Wiles
> 
> From: Wiles, Keith, Monday, February 19, 2018 3:56 PM
>>> On Feb 19, 2018, at 12:03 AM, Matan Azrad  wrote:
 Is this the type of API that needs to be marked experimental,
>>> 
>>> I think it is relevant to any exposed API(not only for internal libraries).
>>> 
 we should be able to prove these functions, correct?
>>> 
>>> Don't we need to prove any function in DPDK?
>>> What is your point?
>> 
>> 
>> My point is this is a inline function and can not be placed in the .map file 
>> as a
>> external API.
> 
> Doesn't each API in .h file external? Why not?
> If it shouldn't be external and should be in .h file, I think it should be 
> marked as internal, no?

We do not do a great job of using private headers as most of our headers are 
public ones and in the case or private they would not be external.

> 
>> These simple type of APIs are easy to prove and making them
>> experimental seems to just cause an extra step.
> 
> As Thomas mentioned here:
> https://dpdk.org/ml/archives/dev/2018-January/087719.html
> 
> Any new API should be experimental.
> 
> Thomas, Is it different for .h file inline APIs?
> 
>> If the functions are not required that is a different problem or if the API 
>> is really only ever used by a
>> single function or module of files then it should be moved to the module/file
>> and made locate to the module/file.
> 
> Agree.
> Looks like this function makes sense and may be used by other modules later.
> 

Regards,
Keith



Re: [dpdk-dev] [PATCH 1/2] eal: add API to align integer to previous power of 2

2018-02-19 Thread Thomas Monjalon
19/02/2018 15:13, Matan Azrad:
> Hi Wiles
> 
> From: Wiles, Keith, Monday, February 19, 2018 3:56 PM
> > > On Feb 19, 2018, at 12:03 AM, Matan Azrad  wrote:
> > >> Is this the type of API that needs to be marked experimental,
> > >
> > > I think it is relevant to any exposed API(not only for internal 
> > > libraries).
> > >
> > >> we should be able to prove these functions, correct?
> > >
> > > Don't we need to prove any function in DPDK?
> > > What is your point?
> > 
> > 
> > My point is this is a inline function and can not be placed in the .map 
> > file as a
> > external API.
> 
> Doesn't each API in .h file external? Why not?
> If it shouldn't be external and should be in .h file, I think it should be 
> marked as internal, no?
> 
> > These simple type of APIs are easy to prove and making them
> > experimental seems to just cause an extra step.
> 
> As Thomas mentioned here:
> https://dpdk.org/ml/archives/dev/2018-January/087719.html
> 
> Any new API should be experimental.
> 
> Thomas, Is it different for .h file inline APIs?

No, it is not different for inline functions.
If we are discussing the policy for every function, it is not
a policy anymore :)

It was agreed to notify the users of the new functions,
so it gives time to confirm the function before making it "stable".
Even if the function looks obvious, I think we should follow the policy.

So, yes, please add the experimental tag.


Re: [dpdk-dev] Request to create a draft repo for Windows DPDK Patches

2018-02-19 Thread Jason Messer
Resending on dev alias

-Original Message-
From: Jason Messer 
Sent: Friday, February 16, 2018 10:52 AM
To: us...@dpdk.org
Cc: Kappler, Elizabeth M ; Omar Cardona 
; techbo...@dpdk.org
Subject: Request to create a draft repo for Windows DPDK Patches

Hello -

As we reported at the DPDK Summit in November, we have brought support for 
several of the DPDK core libraries as well as a UIO driver for use on Windows. 
While there is still work to do (outlined below) we are requesting a draft repo 
be created to continue this work more openly in the community and to provide a 
forum to address any technical concerns. 

We expect the initial commit for this draft repo (branch tentatively named 
windpdk-v17.11-rc2) to include the following libraries. 
- librte_bus_pci
- librte_cmdline
- librte_distributor
- librte_eal
- librte_ether
- librte_hash
- librte_kvargs
- librte_lpm
- librte_mbuf
- librte_mempool
- librte_mempool_ring
- librte_pci
- librte_pmd_i40e (Intel PMD for Fortville NICs)
- librte_ring

Additionally, these two toy applications are building and running correctly:
- l2fwd
- l3fwd

Note: code is currently based on v17.11 release but we plan to quickly rebase 
so that we are current with the latest 18.02 release and eventually in-sync 
with upstream. 

Outstanding Issues:
- Confirm DPDK libraries and UIO driver build correctly with Clang on windows
- Update Visual Studio projects / solutions to reference clang compiler 
(currently expects ICC)
- [Tangential] Make DPDK C-Standards Compliant to not require specific GNU/GCC 
extensions
- Clean-up code and refactor to remove as many #ifdefs as possible
- Bring remaining DPDK core libraries to Windows and confirm
- Integrate with Meson build tool suite

Thanks,
Jason




Re: [dpdk-dev] [PATCH 4/4] vhost: avoid populate guest memory

2018-02-19 Thread Maxime Coquelin

Hi Jianfeng,

On 02/14/2018 05:01 AM, Jianfeng Tan wrote:

It's not necessary to polulate guest memory from vhost side.

Cc: maxime.coque...@redhat.com
Cc: y...@fridaylinux.org

Signed-off-by: Jianfeng Tan 
---
  lib/librte_vhost/vhost_user.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
index 90ed211..9bd0391 100644
--- a/lib/librte_vhost/vhost_user.c
+++ b/lib/librte_vhost/vhost_user.c
@@ -644,6 +644,7 @@ vhost_user_set_mem_table(struct virtio_net *dev, struct 
VhostUserMsg *pmsg)
uint64_t mmap_offset;
uint64_t alignment;
uint32_t i;
+   int populate;
int fd;
  
  	if (dev->mem && !vhost_memory_changed(&memory, dev->mem)) {

@@ -714,8 +715,9 @@ vhost_user_set_mem_table(struct virtio_net *dev, struct 
VhostUserMsg *pmsg)
}
mmap_size = RTE_ALIGN_CEIL(mmap_size, alignment);
  
+		populate = (dev->dequeue_zero_copy) ? MAP_POPULATE : 0;

mmap_addr = mmap(NULL, mmap_size, PROT_READ | PROT_WRITE,
-MAP_SHARED | MAP_POPULATE, fd, 0);
+MAP_SHARED | populate, fd, 0);
  
  		if (mmap_addr == MAP_FAILED) {

RTE_LOG(ERR, VHOST_CONFIG,



Wouldn't not populating all the guest memory have a bad impact on 0%
acceptable loss use-cases?

Thanks,
Maxime


Re: [dpdk-dev] [PATCH v1] doc: add template release notes for 18.05

2018-02-19 Thread Thomas Monjalon
> > Add template release notes for DPDK 18.05 with inline comments and
> > explanations of the various sections.
> > 
> > Signed-off-by: John McNamara 
> 
> Acked-by:  Erik Gabriel Carrillo 

Added to the index and applied, thanks.


Re: [dpdk-dev] [PATCH 2/4] vhost: avoid function call in data path

2018-02-19 Thread Maxime Coquelin



On 02/14/2018 05:01 AM, Jianfeng Tan wrote:

Previously, get_device() is a function call. It's OK for slow path
configuration, but takes some cycles for data path.

To avoid that, we turn this function to inline type.

Cc: maxime.coque...@redhat.com
Cc: y...@fridaylinux.org

Signed-off-by: Jianfeng Tan 
---
  lib/librte_vhost/vhost.c | 13 -
  lib/librte_vhost/vhost.h | 13 -
  2 files changed, 12 insertions(+), 14 deletions(-)


Reviewed-by: Maxime Coquelin 

Thanks,
Maxime


Re: [dpdk-dev] [PATCH 1/4] vhost: remove unused macro

2018-02-19 Thread Maxime Coquelin



On 02/14/2018 05:01 AM, Jianfeng Tan wrote:

Cc: tomaszx.kula...@intel.com
Cc: maxime.coque...@redhat.com
Cc: y...@fridaylinux.org

Signed-off-by: Jianfeng Tan 
---
  lib/librte_vhost/vhost.h | 2 --
  1 file changed, 2 deletions(-)


Reviewed-by: Maxime Coquelin 

Thanks,
Maxime


[dpdk-dev] [PATCH] version: 18.05-rc0

2018-02-19 Thread Thomas Monjalon
Signed-off-by: Thomas Monjalon 
---
 lib/librte_eal/common/include/rte_version.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/librte_eal/common/include/rte_version.h 
b/lib/librte_eal/common/include/rte_version.h
index 8173802bf..f2c899d03 100644
--- a/lib/librte_eal/common/include/rte_version.h
+++ b/lib/librte_eal/common/include/rte_version.h
@@ -32,7 +32,7 @@ extern "C" {
 /**
  * Minor version/month number i.e. the mm in yy.mm.z
  */
-#define RTE_VER_MONTH 02
+#define RTE_VER_MONTH 05
 
 /**
  * Patch level number i.e. the z in yy.mm.z
@@ -42,14 +42,14 @@ extern "C" {
 /**
  * Extra string to be appended to version number
  */
-#define RTE_VER_SUFFIX ""
+#define RTE_VER_SUFFIX "-rc"
 
 /**
  * Patch release number
  *   0-15 = release candidates
  *   16   = release
  */
-#define RTE_VER_RELEASE 16
+#define RTE_VER_RELEASE 0
 
 /**
  * Macro to compute a version number usable for comparisons
-- 
2.15.1



Re: [dpdk-dev] [PATCH] vhost: fix offset while mmaping log base address

2018-02-19 Thread Maxime Coquelin



On 02/08/2018 05:59 PM, Tomasz Kulasek wrote:

QEMU always set offset to 0 but for sanity we should take the offset
into account.

Fixes: 54f9e32305d4 ("vhost: handle dirty pages logging request")
Cc: yuanhan@linux.intel.com
Cc: sta...@dpdk.org

Signed-off-by: Pawel Wodkowski 
Signed-off-by: Tomasz Kulasek 
---
  lib/librte_vhost/vhost_user.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)


Reviewed-by: Maxime Coquelin 

and applied to dpdk-next-virtio/master.

Thanks,
Maxime


Re: [dpdk-dev] [PATCH] version: 18.05-rc0

2018-02-19 Thread Thomas Monjalon
The new release cycle is started!

If you think some patches are already ready for integration in master,
please notify me.

Note that changes impacting a lot of future patches (big changes, renames,
or core features) are preferred to be integrated early in the cycle.

Thanks for your attention


Re: [dpdk-dev] [PATCH v4] lib/librte_meter: add meter configuration profile

2018-02-19 Thread Thomas Monjalon
08/01/2018 16:43, Jasvinder Singh:
> From: Cristian Dumitrescu 
> 
> This patch adds support for meter configuration profiles.
> Benefits: simplified configuration procedure, improved performance.
> 
> Q1: What is the configuration profile and why does it make sense?
> A1: The configuration profile represents the set of configuration
> parameters for a given meter object, such as the rates and sizes for
> the token buckets. The configuration profile concept makes sense when
> many meter objects share the same configuration, which is the typical
> usage model: thousands of traffic flows are each individually metered
> according to just a few service levels (i.e. profiles).
> 
> Q2: How is the configuration profile improving the performance?
> A2: The performance improvement is achieved by reducing the memory
> footprint of a meter object, which results in better cache utilization
> for the typical case when large arrays of meter objects are used. The
> internal data structures stored for each meter object contain:
>a) Constant fields: Low level translation of the configuration
>   parameters that does not change post-configuration. This is
>   really duplicated for all meters that use the same
>   configuration. This is the configuration profile data that is
>   moved away from the meter object. Current size (implementation
>   dependent): srTCM = 32 bytes, trTCM = 32 bytes.
>b) Variable fields: Time stamps and running counters that change
>   during the on-going traffic metering process. Current size
>   (implementation dependant): srTCM = 24 bytes, trTCM = 32 bytes.
>   Therefore, by moving the constant fields to a separate profile
>   data structure shared by all the meters with the same
>   configuration, the size of the meter object is reduced by ~50%.
> 
> Signed-off-by: Cristian Dumitrescu 
> Signed-off-by: Jasvinder Singh 

Applied for 18.05 (was postponed to preserve 18.02 ABI), thanks.



Re: [dpdk-dev] [PATCH] net/enic: add primary mac address handler

2018-02-19 Thread Hyong Youb Kim
On Mon, Feb 19, 2018 at 01:42:27PM +0100, David Marchand wrote:
> Reused the .mac_addr_add and .mac_addr_del callbacks code to implement
> primary mac address handler.
> 
> Signed-off-by: David Marchand 

Hi, thanks for taking a stab at this.

> +static void enicpmd_set_mac_addr(struct rte_eth_dev *eth_dev,
> + struct ether_addr *addr)
> +{
> + enicpmd_remove_mac_addr(eth_dev, 0);
> + enicpmd_add_mac_addr(eth_dev, addr, 0, 0);
> +}

Unfortunately, this does not work as expected. The caller updates
mac_addrs[0] prior to calling mac_addr_set.

int
rte_eth_dev_default_mac_addr_set(uint16_t port_id, struct ether_addr *addr)
{
[...]
/* Update default address in NIC data structure */
ether_addr_copy(addr, &dev->data->mac_addrs[0]);

(*dev->dev_ops->mac_addr_set)(dev, addr);
[...]

So, enicpmd_remove_mac_addr tries to remove mac_addrs[0], which is the
'new' default address and does not exist on the NIC. Then,
enicpmd_add_mac_addr adds the new address to the NIC. At the end, the
NIC ends up with both the old and the new addresses.

I think the driver would have to treat the 'default' mac address
differently. I can submit a new patch as part of our next upstream
patch set. Or you are welcome to spin a new version. Up to you.

Thanks.
-Hyong


Re: [dpdk-dev] [PATCH] version: 18.05-rc0

2018-02-19 Thread Hemant Agrawal
Hi Thomas,
Can you integrate ?
http://dpdk.org/dev/patchwork/patch/33666/

An early integration will help the subsequent kernel module patches to use new 
path.

Regards,
Hemant

> -Original Message-
> From: dev [mailto:dev-boun...@dpdk.org] On Behalf Of Thomas Monjalon
> Sent: Tuesday, February 20, 2018 2:34 AM
> To: dev@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH] version: 18.05-rc0
> 
> The new release cycle is started!
> 
> If you think some patches are already ready for integration in master, please
> notify me.
> 
> Note that changes impacting a lot of future patches (big changes, renames, or
> core features) are preferred to be integrated early in the cycle.
> 
> Thanks for your attention


[dpdk-dev] [PATCH 15/80] net/sfc/base: add Medford2 support to PHY module

2018-02-19 Thread Andrew Rybchenko
From: Andy Moreton 

Signed-off-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/ef10_phy.c |  4 ++--
 drivers/net/sfc/base/efx_phy.c  | 13 +++--
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/net/sfc/base/ef10_phy.c b/drivers/net/sfc/base/ef10_phy.c
index aa8d6a2..4b2aa76 100644
--- a/drivers/net/sfc/base/ef10_phy.c
+++ b/drivers/net/sfc/base/ef10_phy.c
@@ -7,7 +7,7 @@
 #include "efx.h"
 #include "efx_impl.h"
 
-#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD
+#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2
 
 static void
 mcdi_phy_decode_cap(
@@ -606,4 +606,4 @@ ef10_bist_stop(
 
 #endif /* EFSYS_OPT_BIST */
 
-#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */
+#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2 */
diff --git a/drivers/net/sfc/base/efx_phy.c b/drivers/net/sfc/base/efx_phy.c
index 069c283..2598928 100644
--- a/drivers/net/sfc/base/efx_phy.c
+++ b/drivers/net/sfc/base/efx_phy.c
@@ -27,7 +27,7 @@ static const efx_phy_ops_t__efx_phy_siena_ops = {
 };
 #endif /* EFSYS_OPT_SIENA */
 
-#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD
+#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2
 static const efx_phy_ops_t __efx_phy_ef10_ops = {
ef10_phy_power, /* epo_power */
NULL,   /* epo_reset */
@@ -44,7 +44,7 @@ static const efx_phy_ops_t__efx_phy_ef10_ops = {
ef10_bist_stop, /* epo_bist_stop */
 #endif /* EFSYS_OPT_BIST */
 };
-#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */
+#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2 */
 
__checkReturn   efx_rc_t
 efx_phy_probe(
@@ -67,16 +67,25 @@ efx_phy_probe(
epop = &__efx_phy_siena_ops;
break;
 #endif /* EFSYS_OPT_SIENA */
+
 #if EFSYS_OPT_HUNTINGTON
case EFX_FAMILY_HUNTINGTON:
epop = &__efx_phy_ef10_ops;
break;
 #endif /* EFSYS_OPT_HUNTINGTON */
+
 #if EFSYS_OPT_MEDFORD
case EFX_FAMILY_MEDFORD:
epop = &__efx_phy_ef10_ops;
break;
 #endif /* EFSYS_OPT_MEDFORD */
+
+#if EFSYS_OPT_MEDFORD2
+   case EFX_FAMILY_MEDFORD2:
+   epop = &__efx_phy_ef10_ops;
+   break;
+#endif /* EFSYS_OPT_MEDFORD2 */
+
default:
rc = ENOTSUP;
goto fail1;
-- 
2.7.4



[dpdk-dev] [PATCH 11/80] net/sfc/base: add Medford2 support to FILTER module

2018-02-19 Thread Andrew Rybchenko
From: Andy Moreton 

Signed-off-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/ef10_filter.c | 19 ---
 drivers/net/sfc/base/efx_filter.c  | 10 --
 2 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/drivers/net/sfc/base/ef10_filter.c 
b/drivers/net/sfc/base/ef10_filter.c
index 27b5998..2b7a09c 100644
--- a/drivers/net/sfc/base/ef10_filter.c
+++ b/drivers/net/sfc/base/ef10_filter.c
@@ -7,7 +7,7 @@
 #include "efx.h"
 #include "efx_impl.h"
 
-#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD
+#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2
 
 #if EFSYS_OPT_FILTER
 
@@ -95,7 +95,8 @@ ef10_filter_init(
ef10_filter_table_t *eftp;
 
EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
-   enp->en_family == EFX_FAMILY_MEDFORD);
+   enp->en_family == EFX_FAMILY_MEDFORD ||
+   enp->en_family == EFX_FAMILY_MEDFORD2);
 
 #defineMATCH_MASK(match) (EFX_MASK32(match) << EFX_LOW_BIT(match))
EFX_STATIC_ASSERT(EFX_FILTER_MATCH_REM_HOST ==
@@ -150,7 +151,8 @@ ef10_filter_fini(
__inefx_nic_t *enp)
 {
EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
-   enp->en_family == EFX_FAMILY_MEDFORD);
+   enp->en_family == EFX_FAMILY_MEDFORD ||
+   enp->en_family == EFX_FAMILY_MEDFORD2);
 
if (enp->en_filter.ef_ef10_filter_table != NULL) {
EFSYS_KMEM_FREE(enp->en_esip, sizeof (ef10_filter_table_t),
@@ -495,7 +497,8 @@ ef10_filter_restore(
efx_rc_t rc;
 
EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
-   enp->en_family == EFX_FAMILY_MEDFORD);
+   enp->en_family == EFX_FAMILY_MEDFORD ||
+   enp->en_family == EFX_FAMILY_MEDFORD2);
 
for (tbl_id = 0; tbl_id < EFX_EF10_FILTER_TBL_ROWS; tbl_id++) {
 
@@ -570,7 +573,8 @@ ef10_filter_add_internal(
boolean_t locked = B_FALSE;
 
EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
-   enp->en_family == EFX_FAMILY_MEDFORD);
+   enp->en_family == EFX_FAMILY_MEDFORD ||
+   enp->en_family == EFX_FAMILY_MEDFORD2);
 
hash = ef10_filter_hash(spec);
 
@@ -842,7 +846,8 @@ ef10_filter_delete(
boolean_t locked = B_FALSE;
 
EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
-   enp->en_family == EFX_FAMILY_MEDFORD);
+   enp->en_family == EFX_FAMILY_MEDFORD ||
+   enp->en_family == EFX_FAMILY_MEDFORD2);
 
hash = ef10_filter_hash(spec);
 
@@ -1636,4 +1641,4 @@ ef10_filter_default_rxq_clear(
 
 #endif /* EFSYS_OPT_FILTER */
 
-#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */
+#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2 */
diff --git a/drivers/net/sfc/base/efx_filter.c 
b/drivers/net/sfc/base/efx_filter.c
index b92541a..e31accb 100644
--- a/drivers/net/sfc/base/efx_filter.c
+++ b/drivers/net/sfc/base/efx_filter.c
@@ -56,7 +56,7 @@ static const efx_filter_ops_t __efx_filter_siena_ops = {
 };
 #endif /* EFSYS_OPT_SIENA */
 
-#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD
+#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2
 static const efx_filter_ops_t  __efx_filter_ef10_ops = {
ef10_filter_init,   /* efo_init */
ef10_filter_fini,   /* efo_fini */
@@ -66,7 +66,7 @@ static const efx_filter_ops_t __efx_filter_ef10_ops = {
ef10_filter_supported_filters,  /* efo_supported_filters */
ef10_filter_reconfigure,/* efo_reconfigure */
 };
-#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */
+#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2 */
 
__checkReturn   efx_rc_t
 efx_filter_insert(
@@ -145,6 +145,12 @@ efx_filter_init(
break;
 #endif /* EFSYS_OPT_MEDFORD */
 
+#if EFSYS_OPT_MEDFORD2
+   case EFX_FAMILY_MEDFORD2:
+   efop = &__efx_filter_ef10_ops;
+   break;
+#endif /* EFSYS_OPT_MEDFORD2 */
+
default:
EFSYS_ASSERT(0);
rc = ENOTSUP;
-- 
2.7.4



[dpdk-dev] [PATCH 05/80] net/sfc/base: add Medford2 PCI IDs

2018-02-19 Thread Andrew Rybchenko
From: Andy Moreton 

Signed-off-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/efx.h | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/sfc/base/efx.h b/drivers/net/sfc/base/efx.h
index 5158434..1bea124 100644
--- a/drivers/net/sfc/base/efx.h
+++ b/drivers/net/sfc/base/efx.h
@@ -40,6 +40,7 @@ typedef enum efx_family_e {
EFX_FAMILY_SIENA,
EFX_FAMILY_HUNTINGTON,
EFX_FAMILY_MEDFORD,
+   EFX_FAMILY_MEDFORD2,
EFX_FAMILY_NTYPES
 } efx_family_t;
 
@@ -69,6 +70,10 @@ efx_family(
 #defineEFX_PCI_DEVID_MEDFORD   0x0A03  /* SFC9240 PF */
 #defineEFX_PCI_DEVID_MEDFORD_VF0x1A03  /* SFC9240 VF */
 
+#defineEFX_PCI_DEVID_MEDFORD2_PF_UNINIT0x0B13
+#defineEFX_PCI_DEVID_MEDFORD2  0x0B03  /* SFC9250 PF */
+#defineEFX_PCI_DEVID_MEDFORD2_VF   0x1B03  /* SFC9250 VF */
+
 #defineEFX_MEM_BAR 2
 
 /* Error codes */
-- 
2.7.4



[dpdk-dev] [PATCH 06/80] net/sfc/base: add efsys option for Medford2

2018-02-19 Thread Andrew Rybchenko
From: Andy Moreton 

Signed-off-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/efx_check.h | 97 +++-
 drivers/net/sfc/efsys.h  |  2 +
 2 files changed, 59 insertions(+), 40 deletions(-)

diff --git a/drivers/net/sfc/base/efx_check.h b/drivers/net/sfc/base/efx_check.h
index 5837775..0c85702 100644
--- a/drivers/net/sfc/base/efx_check.h
+++ b/drivers/net/sfc/base/efx_check.h
@@ -30,8 +30,9 @@
 
 #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"
+# if !(EFSYS_OPT_SIENA || EFSYS_OPT_HUNTINGTON || \
+   EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2)
+#  error "CHECK_REG requires SIENA or HUNTINGTON or MEDFORD or MEDFORD2"
 # endif
 #endif /* EFSYS_OPT_CHECK_REG */
 
@@ -44,15 +45,17 @@
 
 #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"
+# if !(EFSYS_OPT_SIENA || EFSYS_OPT_HUNTINGTON || \
+   EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2)
+#  error "DIAG requires SIENA or HUNTINGTON or MEDFORD or MEDFORD2"
 # 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"
+# if !(EFSYS_OPT_SIENA || EFSYS_OPT_HUNTINGTON || \
+   EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2)
+#  error "EV_PREFETCH requires SIENA or HUNTINGTON or MEDFORD or MEDFORD2"
 # endif
 #endif /* EFSYS_OPT_EV_PREFETCH */
 
@@ -62,21 +65,23 @@
 
 #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"
+# if !(EFSYS_OPT_SIENA || EFSYS_OPT_HUNTINGTON || \
+   EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2)
+#  error "FILTER requires SIENA or HUNTINGTON or MEDFORD or MEDFORD2"
 # endif
 #endif /* EFSYS_OPT_FILTER */
 
-#if (EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD)
+#if (EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2)
 # if !EFSYS_OPT_FILTER
-#  error "HUNTINGTON or MEDFORD requires FILTER"
+#  error "HUNTINGTON or MEDFORD or MEDFORD2 requires FILTER"
 # endif
 #endif /* EFSYS_OPT_HUNTINGTON */
 
 #if EFSYS_OPT_LOOPBACK
 /* Support hardware loopback modes */
-# if !(EFSYS_OPT_SIENA || EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD)
-#  error "LOOPBACK requires SIENA or HUNTINGTON or MEDFORD"
+# if !(EFSYS_OPT_SIENA || EFSYS_OPT_HUNTINGTON || \
+   EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2)
+#  error "LOOPBACK requires SIENA or HUNTINGTON or MEDFORD or MEDFORD2"
 # endif
 #endif /* EFSYS_OPT_LOOPBACK */
 
@@ -90,21 +95,24 @@
 
 #if EFSYS_OPT_MAC_STATS
 /* Support MAC statistics */
-# if !(EFSYS_OPT_SIENA || EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD)
-#  error "MAC_STATS requires SIENA or HUNTINGTON or MEDFORD"
+# if !(EFSYS_OPT_SIENA || EFSYS_OPT_HUNTINGTON || \
+   EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2)
+#  error "MAC_STATS requires SIENA or HUNTINGTON or MEDFORD or MEDFORD2"
 # endif
 #endif /* EFSYS_OPT_MAC_STATS */
 
 #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"
+# if !(EFSYS_OPT_SIENA || EFSYS_OPT_HUNTINGTON || \
+   EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2)
+#  error "MCDI requires SIENA or HUNTINGTON or MEDFORD or MEDFORD2"
 # endif
 #endif /* EFSYS_OPT_MCDI */
 
-#if (EFSYS_OPT_SIENA || EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD)
+#if (EFSYS_OPT_SIENA || EFSYS_OPT_HUNTINGTON || \
+   EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2)
 # if !EFSYS_OPT_MCDI
-#  error "SIENA or HUNTINGTON or MEDFORD requires MCDI"
+#  error "SIENA or HUNTINGTON or MEDFORD or MEDFORD2 requires MCDI"
 # endif
 #endif
 
@@ -144,15 +152,17 @@
 
 #if EFSYS_OPT_MON_STATS
 /* Support monitor statistics (voltage/temperature) */
-# if !(EFSYS_OPT_SIENA || EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD)
-#  error "MON_STATS requires SIENA or HUNTINGTON or MEDFORD"
+# if !(EFSYS_OPT_SIENA || EFSYS_OPT_HUNTINGTON || \
+   EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2)
+#  error "MON_STATS requires SIENA or HUNTINGTON or MEDFORD or MEDFORD2"
 # 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"
+# if !(EFSYS_OPT_SIENA || EFSYS_OPT_HUNTINGTON || \
+   EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2)
+#  error "MON_MCDI requires SIENA or HUNTINGTON or MEDFORD or MEDFORD2"
 # endif
 #endif /* EFSYS_OPT_MON_MCDI*/
 
@@ -166,8 +176,9 @@
 
 #if EFSYS_OPT_NVRAM
 /* Support non volatile configuratio

[dpdk-dev] [PATCH 12/80] net/sfc/base: add Medford2 support to INTR module

2018-02-19 Thread Andrew Rybchenko
From: Andy Moreton 

Signed-off-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/ef10_intr.c | 13 -
 drivers/net/sfc/base/efx_intr.c  | 10 --
 2 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/drivers/net/sfc/base/ef10_intr.c b/drivers/net/sfc/base/ef10_intr.c
index f79c44e..1ffe266 100644
--- a/drivers/net/sfc/base/ef10_intr.c
+++ b/drivers/net/sfc/base/ef10_intr.c
@@ -8,7 +8,7 @@
 #include "efx_impl.h"
 
 
-#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD
+#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2
 
__checkReturn   efx_rc_t
 ef10_intr_init(
@@ -56,7 +56,8 @@ efx_mcdi_trigger_interrupt(
efx_rc_t rc;
 
EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
-   enp->en_family == EFX_FAMILY_MEDFORD);
+   enp->en_family == EFX_FAMILY_MEDFORD ||
+   enp->en_family == EFX_FAMILY_MEDFORD2);
 
if (level >= enp->en_nic_cfg.enc_intr_limit) {
rc = EINVAL;
@@ -129,7 +130,8 @@ ef10_intr_status_line(
efx_dword_t dword;
 
EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
-   enp->en_family == EFX_FAMILY_MEDFORD);
+   enp->en_family == EFX_FAMILY_MEDFORD ||
+   enp->en_family == EFX_FAMILY_MEDFORD2);
 
/* Read the queue mask and implicitly acknowledge the interrupt. */
EFX_BAR_READD(enp, ER_DZ_BIU_INT_ISR_REG, &dword, B_FALSE);
@@ -147,7 +149,8 @@ ef10_intr_status_message(
__out   boolean_t *fatalp)
 {
EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
-   enp->en_family == EFX_FAMILY_MEDFORD);
+   enp->en_family == EFX_FAMILY_MEDFORD ||
+   enp->en_family == EFX_FAMILY_MEDFORD2);
 
_NOTE(ARGUNUSED(enp, message))
 
@@ -170,4 +173,4 @@ ef10_intr_fini(
_NOTE(ARGUNUSED(enp))
 }
 
-#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */
+#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2 */
diff --git a/drivers/net/sfc/base/efx_intr.c b/drivers/net/sfc/base/efx_intr.c
index 83ca177..49cfaf7 100644
--- a/drivers/net/sfc/base/efx_intr.c
+++ b/drivers/net/sfc/base/efx_intr.c
@@ -75,7 +75,7 @@ static const efx_intr_ops_t   __efx_intr_siena_ops = {
 };
 #endif /* EFSYS_OPT_SIENA */
 
-#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD
+#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2
 static const efx_intr_ops_t__efx_intr_ef10_ops = {
ef10_intr_init, /* eio_init */
ef10_intr_enable,   /* eio_enable */
@@ -87,7 +87,7 @@ static const efx_intr_ops_t   __efx_intr_ef10_ops = {
ef10_intr_fatal,/* eio_fatal */
ef10_intr_fini, /* eio_fini */
 };
-#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */
+#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2 */
 
__checkReturn   efx_rc_t
 efx_intr_init(
@@ -132,6 +132,12 @@ efx_intr_init(
break;
 #endif /* EFSYS_OPT_MEDFORD */
 
+#if EFSYS_OPT_MEDFORD2
+   case EFX_FAMILY_MEDFORD2:
+   eiop = &__efx_intr_ef10_ops;
+   break;
+#endif /* EFSYS_OPT_MEDFORD2 */
+
default:
EFSYS_ASSERT(B_FALSE);
rc = ENOTSUP;
-- 
2.7.4



[dpdk-dev] [PATCH 14/80] net/sfc/base: add Medford2 support to MCDI module

2018-02-19 Thread Andrew Rybchenko
From: Andy Moreton 

Signed-off-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/ef10_mcdi.c | 13 -
 drivers/net/sfc/base/efx_mcdi.c  | 18 --
 drivers/net/sfc/base/efx_mcdi.h  |  4 ++--
 3 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/drivers/net/sfc/base/ef10_mcdi.c b/drivers/net/sfc/base/ef10_mcdi.c
index 1f9e573..b533033 100644
--- a/drivers/net/sfc/base/ef10_mcdi.c
+++ b/drivers/net/sfc/base/ef10_mcdi.c
@@ -8,7 +8,7 @@
 #include "efx_impl.h"
 
 
-#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD
+#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2
 
 #if EFSYS_OPT_MCDI
 
@@ -28,7 +28,8 @@ ef10_mcdi_init(
efx_rc_t rc;
 
EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
-   enp->en_family == EFX_FAMILY_MEDFORD);
+   enp->en_family == EFX_FAMILY_MEDFORD ||
+   enp->en_family == EFX_FAMILY_MEDFORD2);
EFSYS_ASSERT(enp->en_features & EFX_FEATURE_MCDI_DMA);
 
/*
@@ -135,7 +136,8 @@ ef10_mcdi_send_request(
unsigned int pos;
 
EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
-   enp->en_family == EFX_FAMILY_MEDFORD);
+   enp->en_family == EFX_FAMILY_MEDFORD ||
+   enp->en_family == EFX_FAMILY_MEDFORD2);
 
/* Write the header */
for (pos = 0; pos < hdr_len; pos += sizeof (efx_dword_t)) {
@@ -254,7 +256,8 @@ ef10_mcdi_feature_supported(
efx_rc_t rc;
 
EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
-   enp->en_family == EFX_FAMILY_MEDFORD);
+   enp->en_family == EFX_FAMILY_MEDFORD ||
+   enp->en_family == EFX_FAMILY_MEDFORD2);
 
/*
 * Use privilege mask state at MCDI attach.
@@ -315,4 +318,4 @@ ef10_mcdi_feature_supported(
 
 #endif /* EFSYS_OPT_MCDI */
 
-#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */
+#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2 */
diff --git a/drivers/net/sfc/base/efx_mcdi.c b/drivers/net/sfc/base/efx_mcdi.c
index 347a5b3..254eb00 100644
--- a/drivers/net/sfc/base/efx_mcdi.c
+++ b/drivers/net/sfc/base/efx_mcdi.c
@@ -45,7 +45,7 @@ static const efx_mcdi_ops_t   __efx_mcdi_siena_ops = {
 
 #endif /* EFSYS_OPT_SIENA */
 
-#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD
+#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2
 
 static const efx_mcdi_ops_t__efx_mcdi_ef10_ops = {
ef10_mcdi_init, /* emco_init */
@@ -58,7 +58,7 @@ static const efx_mcdi_ops_t   __efx_mcdi_ef10_ops = {
ef10_mcdi_get_timeout,  /* emco_get_timeout */
 };
 
-#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */
+#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2 */
 
 
 
@@ -92,6 +92,12 @@ efx_mcdi_init(
break;
 #endif /* EFSYS_OPT_MEDFORD */
 
+#if EFSYS_OPT_MEDFORD2
+   case EFX_FAMILY_MEDFORD2:
+   emcop = &__efx_mcdi_ef10_ops;
+   break;
+#endif /* EFSYS_OPT_MEDFORD2 */
+
default:
EFSYS_ASSERT(0);
rc = ENOTSUP;
@@ -1621,7 +1627,7 @@ efx_mcdi_mac_spoofing_supported(
 
 #if EFSYS_OPT_BIST
 
-#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD
+#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2
 /*
  * Enter bist offline mode. This is a fw mode which puts the NIC into a state
  * where memory BIST tests can be run and not much else can interfere or 
happen.
@@ -1657,7 +1663,7 @@ efx_mcdi_bist_enable_offline(
 
return (rc);
 }
-#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */
+#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2 */
 
__checkReturn   efx_rc_t
 efx_mcdi_bist_start(
@@ -1921,7 +1927,7 @@ efx_mcdi_mac_stats_periodic(
 
 #endif /* EFSYS_OPT_MAC_STATS */
 
-#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD
+#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2
 
 /*
  * This function returns the pf and vf number of a function.  If it is a pf the
@@ -2020,7 +2026,7 @@ efx_mcdi_privilege_mask(
return (rc);
 }
 
-#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */
+#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2 */
 
__checkReturn   efx_rc_t
 efx_mcdi_set_workaround(
diff --git a/drivers/net/sfc/base/efx_mcdi.h b/drivers/net/sfc/base/efx_mcdi.h
index 4e69f04..253a9e6 100644
--- a/drivers/net/sfc/base/efx_mcdi.h
+++ b/drivers/net/sfc/base/efx_mcdi.h
@@ -166,11 +166,11 @@ efx_mcdi_mac_spoofing_supported(
 
 
 #if EFSYS_OPT_BIST
-#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD
+#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2
 extern __checkReturn   efx_rc_t
 efx_mcdi_bist_enable_offline(
__inefx_nic_t *enp);
-#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */
+#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2 */
 extern __check

[dpdk-dev] [PATCH 20/80] net/sfc/base: add Medford2 support to BOOTCFG module

2018-02-19 Thread Andrew Rybchenko
From: Andy Moreton 

Signed-off-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/efx_bootcfg.c | 22 --
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/drivers/net/sfc/base/efx_bootcfg.c 
b/drivers/net/sfc/base/efx_bootcfg.c
index 0f71936..3a29306 100644
--- a/drivers/net/sfc/base/efx_bootcfg.c
+++ b/drivers/net/sfc/base/efx_bootcfg.c
@@ -68,6 +68,20 @@ efx_bootcfg_sector_info(
}
 #endif /* EFSYS_OPT_MEDFORD */
 
+#if EFSYS_OPT_MEDFORD2
+   case EFX_FAMILY_MEDFORD2: {
+   /* Shared partition (array indexed by PF) */
+   max_size = BOOTCFG_PER_PF;
+   count = BOOTCFG_PF_COUNT;
+   if (pf >= count) {
+   rc = EINVAL;
+   goto fail3;
+   }
+   offset = max_size * pf;
+   break;
+   }
+#endif /* EFSYS_OPT_MEDFORD2 */
+
default:
EFSYS_ASSERT(0);
rc = ENOTSUP;
@@ -82,6 +96,10 @@ efx_bootcfg_sector_info(
 
return (0);
 
+#if EFSYS_OPT_MEDFORD2
+fail3:
+   EFSYS_PROBE(fail3);
+#endif
 #if EFSYS_OPT_MEDFORD
 fail2:
EFSYS_PROBE(fail2);
@@ -277,7 +295,7 @@ efx_bootcfg_read(
efx_rc_t rc;
uint32_t sector_number;
 
-#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD
+#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2
sector_number = enp->en_nic_cfg.enc_pf;
 #else
sector_number = 0;
@@ -418,7 +436,7 @@ efx_bootcfg_write(
efx_rc_t rc;
uint32_t sector_number;
 
-#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD
+#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2
sector_number = enp->en_nic_cfg.enc_pf;
 #else
sector_number = 0;
-- 
2.7.4



[dpdk-dev] [PATCH 23/80] net/sfc/base: support runtime VI window size

2018-02-19 Thread Andrew Rybchenko
From: Andy Moreton 

Medford2 uses a configurable VI window size, and requires
updates to register accesses to use a runtime VI window size
rather than the *_STEP register constants used for earlier
controllers.

Update the common code to query the VI window size via MCDI,
and add new EFX_BAR_VI_* accessor macros for per-VI registers.

The existing EFX_BAR_TBL_* macros can be used for non-VI
register tables (and for code that can never be called for
a Medford2 controller e.g. Siena-only code).

Signed-off-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/ef10_ev.c  | 10 ++---
 drivers/net/sfc/base/ef10_impl.h|  5 +++
 drivers/net/sfc/base/ef10_nic.c | 78 --
 drivers/net/sfc/base/ef10_rx.c  |  6 +--
 drivers/net/sfc/base/ef10_tx.c  |  8 ++--
 drivers/net/sfc/base/efx.h  |  8 
 drivers/net/sfc/base/efx_impl.h | 83 -
 drivers/net/sfc/base/hunt_nic.c | 11 +
 drivers/net/sfc/base/medford2_nic.c |  9 
 drivers/net/sfc/base/medford_nic.c  | 11 +
 drivers/net/sfc/base/siena_nic.c|  4 ++
 11 files changed, 199 insertions(+), 34 deletions(-)

diff --git a/drivers/net/sfc/base/ef10_ev.c b/drivers/net/sfc/base/ef10_ev.c
index a05a35a..36ff2cb 100644
--- a/drivers/net/sfc/base/ef10_ev.c
+++ b/drivers/net/sfc/base/ef10_ev.c
@@ -577,7 +577,7 @@ ef10_ev_qprime(
EFE_DD_EVQ_IND_RPTR_FLAGS_HIGH,
ERF_DD_EVQ_IND_RPTR,
(rptr >> ERF_DD_EVQ_IND_RPTR_WIDTH));
-   EFX_BAR_TBL_WRITED(enp, ER_DD_EVQ_INDIRECT, eep->ee_index,
+   EFX_BAR_VI_WRITED(enp, ER_DD_EVQ_INDIRECT, eep->ee_index,
&dword, B_FALSE);
 
EFX_POPULATE_DWORD_2(dword,
@@ -585,11 +585,11 @@ ef10_ev_qprime(
EFE_DD_EVQ_IND_RPTR_FLAGS_LOW,
ERF_DD_EVQ_IND_RPTR,
rptr & ((1 << ERF_DD_EVQ_IND_RPTR_WIDTH) - 1));
-   EFX_BAR_TBL_WRITED(enp, ER_DD_EVQ_INDIRECT, eep->ee_index,
+   EFX_BAR_VI_WRITED(enp, ER_DD_EVQ_INDIRECT, eep->ee_index,
&dword, B_FALSE);
} else {
EFX_POPULATE_DWORD_1(dword, ERF_DZ_EVQ_RPTR, rptr);
-   EFX_BAR_TBL_WRITED(enp, ER_DZ_EVQ_RPTR_REG, eep->ee_index,
+   EFX_BAR_VI_WRITED(enp, ER_DZ_EVQ_RPTR_REG, eep->ee_index,
&dword, B_FALSE);
}
 
@@ -702,13 +702,13 @@ ef10_ev_qmoderate(
EFE_DD_EVQ_IND_TIMER_FLAGS,
ERF_DD_EVQ_IND_TIMER_MODE, mode,
ERF_DD_EVQ_IND_TIMER_VAL, ticks);
-   EFX_BAR_TBL_WRITED(enp, ER_DD_EVQ_INDIRECT,
+   EFX_BAR_VI_WRITED(enp, ER_DD_EVQ_INDIRECT,
eep->ee_index, &dword, 0);
} else {
EFX_POPULATE_DWORD_2(dword,
ERF_DZ_TC_TIMER_MODE, mode,
ERF_DZ_TC_TIMER_VAL, ticks);
-   EFX_BAR_TBL_WRITED(enp, ER_DZ_EVQ_TMR_REG,
+   EFX_BAR_VI_WRITED(enp, ER_DZ_EVQ_TMR_REG,
eep->ee_index, &dword, 0);
}
}
diff --git a/drivers/net/sfc/base/ef10_impl.h b/drivers/net/sfc/base/ef10_impl.h
index e004d15..08e2f9f 100644
--- a/drivers/net/sfc/base/ef10_impl.h
+++ b/drivers/net/sfc/base/ef10_impl.h
@@ -1160,6 +1160,11 @@ extern   __checkReturn   efx_rc_t
 ef10_get_datapath_caps(
__inefx_nic_t *enp);
 
+extern __checkReturn   efx_rc_t
+ef10_get_vi_window_shift(
+   __inefx_nic_t *enp,
+   __out   uint32_t *vi_window_shiftp);
+
 extern __checkReturn   efx_rc_t
 ef10_get_privilege_mask(
__inefx_nic_t *enp,
diff --git a/drivers/net/sfc/base/ef10_nic.c b/drivers/net/sfc/base/ef10_nic.c
index 8b9ef15..a48f2ac 100644
--- a/drivers/net/sfc/base/ef10_nic.c
+++ b/drivers/net/sfc/base/ef10_nic.c
@@ -1143,6 +1143,71 @@ ef10_get_datapath_caps(
return (rc);
 }
 
+   __checkReturn   efx_rc_t
+ef10_get_vi_window_shift(
+   __inefx_nic_t *enp,
+   __out   uint32_t *vi_window_shiftp)
+{
+   efx_mcdi_req_t req;
+   uint8_t payload[MAX(MC_CMD_GET_CAPABILITIES_IN_LEN,
+   MC_CMD_GET_CAPABILITIES_V3_OUT_LEN)];
+   uint32_t mode;
+   efx_rc_t rc;
+
+   (void) memset(payload, 0, sizeof (payload));
+   req.emr_cmd = MC_CMD_GET_CAPABILITIES;
+   req.emr_in_buf = payload;
+   req.emr_in_length = MC_CMD_GET_CAPABILITIES_IN_LEN;
+   req.emr_out_buf = payload;
+   req.emr_out_length = MC_CMD_GET_CAPABILITIES_V3_OUT_LEN;
+
+   efx_mcdi_execute_quiet(enp, &req);
+
+   if (req.emr_rc != 0) {
+   rc = req.emr_rc;
+   goto fail1;
+   }
+
+   if (req.emr_out_length_used < MC_CMD_GET_CAPABILITIES_V3_OUT_LE

[dpdk-dev] [PATCH 24/80] net/sfc/base: improve comments for EF10 ext port mapping

2018-02-19 Thread Andrew Rybchenko
From: Richard Houldsworth 

Signed-off-by: Richard Houldsworth 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/ef10_nic.c | 108 ++--
 1 file changed, 92 insertions(+), 16 deletions(-)

diff --git a/drivers/net/sfc/base/ef10_nic.c b/drivers/net/sfc/base/ef10_nic.c
index a48f2ac..62d41d2 100644
--- a/drivers/net/sfc/base/ef10_nic.c
+++ b/drivers/net/sfc/base/ef10_nic.c
@@ -1261,26 +1261,58 @@ ef10_get_privilege_mask(
 
 
 /*
- * Table of mapping schemes from port number to the number of the external
- * connector on the board. The external numbering does not distinguish
- * off-board separated outputs such as from multi-headed cables.
+ * Table of mapping schemes from port number to external number.
  *
- * The count of adjacent port numbers that map to each external port
+ * Each port number ultimately corresponds to a connector: either as part of
+ * a cable assembly attached to a module inserted in an SFP+/QSFP+ cage on
+ * the board, or fixed to the board (e.g. 10GBASE-T magjack on SFN5121T
+ * "Salina"). In general:
+ *
+ * Port number (0-based)
+ * |
+ *   port mapping (n:1)
+ * |
+ * v
+ * External port number (normally 1-based)
+ * |
+ *   fixed (1:1) or cable assembly (1:m)
+ * |
+ * v
+ * Connector
+ *
+ * The external numbering refers to the cages or magjacks on the board,
+ * as visibly annotated on the board or back panel. This table describes
+ * how to determine which external cage/magjack corresponds to the port
+ * numbers used by the driver.
+ *
+ * The count of adjacent port numbers that map to each external number,
  * and the offset in the numbering, is determined by the chip family and
  * current port mode.
  *
  * For the Huntington family, the current port mode cannot be discovered,
+ * but a single mapping is used by all modes for a given chip variant,
  * so the mapping used is instead the last match in the table to the full
  * set of port modes to which the NIC can be configured. Therefore the
  * ordering of entries in the mapping table is significant.
  */
-static struct {
+static struct ef10_external_port_map_s {
efx_family_tfamily;
uint32_tmodes_mask;
int32_t count;
int32_t offset;
 }  __ef10_external_port_mappings[] = {
-   /* Supported modes with 1 output per external port */
+   /*
+* Modes used by Huntington family controllers where each port
+* number maps to a separate cage.
+* SFN7x22F (Torino):
+*  port 0 -> cage 1
+*  port 1 -> cage 2
+* SFN7xx4F (Pavia):
+*  port 0 -> cage 1
+*  port 1 -> cage 2
+*  port 2 -> cage 3
+*  port 3 -> cage 4
+*/
{
EFX_FAMILY_HUNTINGTON,
(1 << TLV_PORT_MODE_10G) |
@@ -1289,6 +1321,14 @@ static struct {
1,
1
},
+   /*
+* Modes that on Medford allocate each port number to a separate
+* cage.
+*  port 0 -> cage 1
+*  port 1 -> cage 2
+*  port 2 -> cage 3
+*  port 3 -> cage 4
+*/
{
EFX_FAMILY_MEDFORD,
(1 << TLV_PORT_MODE_10G) |
@@ -1296,7 +1336,15 @@ static struct {
1,
1
},
-   /* Supported modes with 2 outputs per external port */
+   /*
+* Modes which for Huntington identify a chip variant where 2
+* adjacent port numbers map to each cage.
+* SFN7x42Q (Monza):
+*  port 0 -> cage 1
+*  port 1 -> cage 1
+*  port 2 -> cage 2
+*  port 3 -> cage 2
+*/
{
EFX_FAMILY_HUNTINGTON,
(1 << TLV_PORT_MODE_40G) |
@@ -1306,6 +1354,14 @@ static struct {
2,
1
},
+   /*
+* Modes that on Medford allocate 2 adjacent port numbers to each
+* cage.
+*  port 0 -> cage 1
+*  port 1 -> cage 1
+*  port 2 -> cage 2
+*  port 3 -> cage 2
+*/
{
EFX_FAMILY_MEDFORD,
(1 << TLV_PORT_MODE_40G) |
@@ -1316,7 +1372,14 @@ static struct {
2,
1
},
-   /* Supported modes with 4 outputs per external port */
+   /*
+* Modes that on Medford allocate 4 adjacent port numbers to each
+* connector, starting on cage 1.
+*  port 0 -> cage 1
+*  port 1 -> cage 1
+*  port 2 -> cage 1
+*  port 3 -> cage 1
+*/
{
EFX_FAMILY_MEDFORD,
(1 << TLV_PORT_MODE_10G_10G_10G_10G_Q) |
@@ -1324,6 +1387,14 @@ static struct {
4,
1,
},
+   /*
+* Modes that on Medford allocate 4 adjacent port numbers to each
+* connector, starting on cage

[dpdk-dev] [PATCH 32/80] net/sfc/base: add support new link modes

2018-02-19 Thread Andrew Rybchenko
From: Andy Moreton 

Add basic support for new link modes for Medford2.

Signed-off-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/ef10_phy.c | 48 +
 drivers/net/sfc/base/efx.h  |  7 ++
 2 files changed, 55 insertions(+)

diff --git a/drivers/net/sfc/base/ef10_phy.c b/drivers/net/sfc/base/ef10_phy.c
index e47ca22..e05fe2b 100644
--- a/drivers/net/sfc/base/ef10_phy.c
+++ b/drivers/net/sfc/base/ef10_phy.c
@@ -16,6 +16,26 @@ mcdi_phy_decode_cap(
 {
uint32_t mask;
 
+#defineCHECK_CAP(_cap) \
+   EFX_STATIC_ASSERT(EFX_PHY_CAP_##_cap == MC_CMD_PHY_CAP_##_cap##_LBN)
+
+   CHECK_CAP(10HDX);
+   CHECK_CAP(10FDX);
+   CHECK_CAP(100HDX);
+   CHECK_CAP(100FDX);
+   CHECK_CAP(1000HDX);
+   CHECK_CAP(1000FDX);
+   CHECK_CAP(1FDX);
+   CHECK_CAP(25000FDX);
+   CHECK_CAP(4FDX);
+   CHECK_CAP(5FDX);
+   CHECK_CAP(10FDX);
+   CHECK_CAP(PAUSE);
+   CHECK_CAP(ASYM);
+   CHECK_CAP(AN);
+   CHECK_CAP(DDM);
+#undef CHECK_CAP
+
mask = 0;
if (mcdi_cap & (1 << MC_CMD_PHY_CAP_10HDX_LBN))
mask |= (1 << EFX_PHY_CAP_10HDX);
@@ -31,8 +51,15 @@ mcdi_phy_decode_cap(
mask |= (1 << EFX_PHY_CAP_1000FDX);
if (mcdi_cap & (1 << MC_CMD_PHY_CAP_1FDX_LBN))
mask |= (1 << EFX_PHY_CAP_1FDX);
+   if (mcdi_cap & (1 << MC_CMD_PHY_CAP_25000FDX_LBN))
+   mask |= (1 << EFX_PHY_CAP_25000FDX);
if (mcdi_cap & (1 << MC_CMD_PHY_CAP_4FDX_LBN))
mask |= (1 << EFX_PHY_CAP_4FDX);
+   if (mcdi_cap & (1 << MC_CMD_PHY_CAP_5FDX_LBN))
+   mask |= (1 << EFX_PHY_CAP_5FDX);
+   if (mcdi_cap & (1 << MC_CMD_PHY_CAP_10FDX_LBN))
+   mask |= (1 << EFX_PHY_CAP_10FDX);
+
if (mcdi_cap & (1 << MC_CMD_PHY_CAP_PAUSE_LBN))
mask |= (1 << EFX_PHY_CAP_PAUSE);
if (mcdi_cap & (1 << MC_CMD_PHY_CAP_ASYM_LBN))
@@ -61,8 +88,14 @@ mcdi_phy_decode_link_mode(
 
if (!up)
*link_modep = EFX_LINK_DOWN;
+   else if (speed == 10 && fd)
+   *link_modep = EFX_LINK_10FDX;
+   else if (speed == 5 && fd)
+   *link_modep = EFX_LINK_5FDX;
else if (speed == 4 && fd)
*link_modep = EFX_LINK_4FDX;
+   else if (speed == 25000 && fd)
+   *link_modep = EFX_LINK_25000FDX;
else if (speed == 1 && fd)
*link_modep = EFX_LINK_1FDX;
else if (speed == 1000)
@@ -273,7 +306,13 @@ ef10_phy_reconfigure(
PHY_CAP_AN, (cap_mask >> EFX_PHY_CAP_AN) & 0x1);
/* Too many fields for for POPULATE macros, so insert this afterwards */
MCDI_IN_SET_DWORD_FIELD(req, SET_LINK_IN_CAP,
+   PHY_CAP_25000FDX, (cap_mask >> EFX_PHY_CAP_25000FDX) & 0x1);
+   MCDI_IN_SET_DWORD_FIELD(req, SET_LINK_IN_CAP,
PHY_CAP_4FDX, (cap_mask >> EFX_PHY_CAP_4FDX) & 0x1);
+   MCDI_IN_SET_DWORD_FIELD(req, SET_LINK_IN_CAP,
+   PHY_CAP_5FDX, (cap_mask >> EFX_PHY_CAP_5FDX) & 0x1);
+   MCDI_IN_SET_DWORD_FIELD(req, SET_LINK_IN_CAP,
+   PHY_CAP_10FDX, (cap_mask >> EFX_PHY_CAP_10FDX) & 0x1);
 
 #if EFSYS_OPT_LOOPBACK
MCDI_IN_SET_DWORD(req, SET_LINK_IN_LOOPBACK_MODE,
@@ -288,9 +327,18 @@ ef10_phy_reconfigure(
case EFX_LINK_1FDX:
speed = 1;
break;
+   case EFX_LINK_25000FDX:
+   speed = 25000;
+   break;
case EFX_LINK_4FDX:
speed = 4;
break;
+   case EFX_LINK_5FDX:
+   speed = 5;
+   break;
+   case EFX_LINK_10FDX:
+   speed = 10;
+   break;
default:
speed = 0;
}
diff --git a/drivers/net/sfc/base/efx.h b/drivers/net/sfc/base/efx.h
index 6149abf..1b92027 100644
--- a/drivers/net/sfc/base/efx.h
+++ b/drivers/net/sfc/base/efx.h
@@ -424,6 +424,9 @@ typedef enum efx_link_mode_e {
EFX_LINK_1000FDX,
EFX_LINK_1FDX,
EFX_LINK_4FDX,
+   EFX_LINK_25000FDX,
+   EFX_LINK_5FDX,
+   EFX_LINK_10FDX,
EFX_LINK_NMODES
 } efx_link_mode_t;
 
@@ -861,6 +864,10 @@ typedef enum efx_phy_cap_type_e {
EFX_PHY_CAP_ASYM,
EFX_PHY_CAP_AN,
EFX_PHY_CAP_4FDX,
+   EFX_PHY_CAP_DDM,
+   EFX_PHY_CAP_10FDX,
+   EFX_PHY_CAP_25000FDX,
+   EFX_PHY_CAP_5FDX,
EFX_PHY_CAP_NTYPES
 } efx_phy_cap_type_t;
 
-- 
2.7.4



[dpdk-dev] [PATCH 25/80] net/sfc/base: add method to make checksum option descriptors

2018-02-19 Thread Andrew Rybchenko
From: Mark Spender 

Signed-off-by: Mark Spender 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/ef10_impl.h |  5 +
 drivers/net/sfc/base/ef10_tx.c   | 40 +++-
 drivers/net/sfc/base/efx.h   |  6 ++
 drivers/net/sfc/base/efx_impl.h  |  2 ++
 drivers/net/sfc/base/efx_tx.c| 19 +++
 5 files changed, 59 insertions(+), 13 deletions(-)

diff --git a/drivers/net/sfc/base/ef10_impl.h b/drivers/net/sfc/base/ef10_impl.h
index 08e2f9f..e598a9a 100644
--- a/drivers/net/sfc/base/ef10_impl.h
+++ b/drivers/net/sfc/base/ef10_impl.h
@@ -767,6 +767,11 @@ ef10_tx_qdesc_vlantci_create(
__inuint16_t vlan_tci,
__out   efx_desc_t *edp);
 
+extern void
+ef10_tx_qdesc_checksum_create(
+   __inefx_txq_t *etp,
+   __inuint16_t flags,
+   __out   efx_desc_t *edp);
 
 #if EFSYS_OPT_QSTATS
 
diff --git a/drivers/net/sfc/base/ef10_tx.c b/drivers/net/sfc/base/ef10_tx.c
index 18877d4..3087306 100644
--- a/drivers/net/sfc/base/ef10_tx.c
+++ b/drivers/net/sfc/base/ef10_tx.c
@@ -176,7 +176,7 @@ ef10_tx_qcreate(
 {
efx_nic_cfg_t *encp = &enp->en_nic_cfg;
uint16_t inner_csum;
-   efx_qword_t desc;
+   efx_desc_t desc;
efx_rc_t rc;
 
_NOTE(ARGUNUSED(id))
@@ -201,19 +201,9 @@ ef10_tx_qcreate(
 * a no-op TX option descriptor. See bug29981 for details.
 */
*addedp = 1;
-   EFX_POPULATE_QWORD_6(desc,
-   ESF_DZ_TX_DESC_IS_OPT, 1,
-   ESF_DZ_TX_OPTION_TYPE, ESE_DZ_TX_OPTION_DESC_CRC_CSUM,
-   ESF_DZ_TX_OPTION_UDP_TCP_CSUM,
-   (flags & EFX_TXQ_CKSUM_TCPUDP) ? 1 : 0,
-   ESF_DZ_TX_OPTION_IP_CSUM,
-   (flags & EFX_TXQ_CKSUM_IPV4) ? 1 : 0,
-   ESF_DZ_TX_OPTION_INNER_UDP_TCP_CSUM,
-   (flags & EFX_TXQ_CKSUM_INNER_TCPUDP) ? 1 : 0,
-   ESF_DZ_TX_OPTION_INNER_IP_CSUM,
-   (flags & EFX_TXQ_CKSUM_INNER_IPV4) ? 1 : 0);
+   ef10_tx_qdesc_checksum_create(etp, flags, &desc);
 
-   EFSYS_MEM_WRITEQ(etp->et_esmp, 0, &desc);
+   EFSYS_MEM_WRITEQ(etp->et_esmp, 0, &desc.ed_eq);
ef10_tx_qpush(etp, *addedp, 0);
 
return (0);
@@ -675,6 +665,30 @@ ef10_tx_qdesc_vlantci_create(
ESF_DZ_TX_VLAN_TAG1, tci);
 }
 
+   void
+ef10_tx_qdesc_checksum_create(
+   __inefx_txq_t *etp,
+   __inuint16_t flags,
+   __out   efx_desc_t *edp)
+{
+   _NOTE(ARGUNUSED(etp));
+
+   EFSYS_PROBE2(tx_desc_checksum_create, unsigned int, etp->et_index,
+   uint32_t, flags);
+
+   EFX_POPULATE_QWORD_6(edp->ed_eq,
+   ESF_DZ_TX_DESC_IS_OPT, 1,
+   ESF_DZ_TX_OPTION_TYPE, ESE_DZ_TX_OPTION_DESC_CRC_CSUM,
+   ESF_DZ_TX_OPTION_UDP_TCP_CSUM,
+   (flags & EFX_TXQ_CKSUM_TCPUDP) ? 1 : 0,
+   ESF_DZ_TX_OPTION_IP_CSUM,
+   (flags & EFX_TXQ_CKSUM_IPV4) ? 1 : 0,
+   ESF_DZ_TX_OPTION_INNER_UDP_TCP_CSUM,
+   (flags & EFX_TXQ_CKSUM_INNER_TCPUDP) ? 1 : 0,
+   ESF_DZ_TX_OPTION_INNER_IP_CSUM,
+   (flags & EFX_TXQ_CKSUM_INNER_IPV4) ? 1 : 0);
+}
+
 
__checkReturn   efx_rc_t
 ef10_tx_qpace(
diff --git a/drivers/net/sfc/base/efx.h b/drivers/net/sfc/base/efx.h
index c0ba5e9..b038029 100644
--- a/drivers/net/sfc/base/efx.h
+++ b/drivers/net/sfc/base/efx.h
@@ -2252,6 +2252,12 @@ efx_tx_qdesc_vlantci_create(
__inuint16_t tci,
__out   efx_desc_t *edp);
 
+extern void
+efx_tx_qdesc_checksum_create(
+   __inefx_txq_t *etp,
+   __inuint16_t flags,
+   __out   efx_desc_t *edp);
+
 #if EFSYS_OPT_QSTATS
 
 #if EFSYS_OPT_NAMES
diff --git a/drivers/net/sfc/base/efx_impl.h b/drivers/net/sfc/base/efx_impl.h
index e202b10..ca22e0b 100644
--- a/drivers/net/sfc/base/efx_impl.h
+++ b/drivers/net/sfc/base/efx_impl.h
@@ -121,6 +121,8 @@ typedef struct efx_tx_ops_s {
efx_desc_t *, int);
void(*etxo_qdesc_vlantci_create)(efx_txq_t *, uint16_t,
efx_desc_t *);
+   void(*etxo_qdesc_checksum_create)(efx_txq_t *, uint16_t,
+   efx_desc_t *);
 #if EFSYS_OPT_QSTATS
void(*etxo_qstats_update)(efx_txq_t *,
  efsys_stat_t *);
diff --git a/drivers/net/sfc/base/efx_tx.c b/drivers/net/sfc/base/efx_tx.c
index 41c6736..f8b9801 100644
--- a/drivers/net/sfc/base/efx_tx.c
+++ b/drivers/net/sfc/base/efx_tx.c
@@ -117,6 +117,7 @@ static const efx_tx_ops_t   __efx_tx_siena_ops = {
NULL,   /* etxo_qdesc_tso_create */
NULL,   /* etxo_qdesc_tso2_create */
NULL,   /* etxo_qdesc_vlantci_create */
+   NULL,   /* etxo_qdesc_checksum_create */
 #if EFSYS_OPT_QSTATS
siena_tx_qstats_update

[dpdk-dev] [PATCH 26/80] net/sfc/base: update hardware headers for Medford2

2018-02-19 Thread Andrew Rybchenko
From: Andy Moreton 

The changes to efx_regs_ef10.h are auto-generated and include:

 - Updated event RX_L4_CLASS which is now 2 bits (was 3).
   The encoding of TCP, UDP and UNKNOWN are unchanged so
   the narrower Medford2 field definition is compatible with
   all controllers.

 - Fix definition of FATSOv2 option descriptors. These were
   added manually and differ from the auto-generated values
   in some fields (not yet used in common code). The field
   definitions have been corrected to agree with the Linux net
   driver headers and SF-108452-SW.

The remaining changes adapt the common code to use the updated
headers.

Signed-off-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/ef10_ev.c   |  47 +++-
 drivers/net/sfc/base/efx_regs_ef10.h | 207 ++-
 drivers/net/sfc/sfc_ef10_rx.c|  18 ++-
 3 files changed, 237 insertions(+), 35 deletions(-)

diff --git a/drivers/net/sfc/base/ef10_ev.c b/drivers/net/sfc/base/ef10_ev.c
index 36ff2cb..c7173c3 100644
--- a/drivers/net/sfc/base/ef10_ev.c
+++ b/drivers/net/sfc/base/ef10_ev.c
@@ -868,12 +868,23 @@ ef10_ev_rx(
 #endif
 
size = EFX_QWORD_FIELD(*eqp, ESF_DZ_RX_BYTES);
+   cont = EFX_QWORD_FIELD(*eqp, ESF_DZ_RX_CONT);
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);
mac_class = EFX_QWORD_FIELD(*eqp, ESF_DZ_RX_MAC_CLASS);
l3_class = EFX_QWORD_FIELD(*eqp, ESF_DZ_RX_L3_CLASS);
-   l4_class = EFX_QWORD_FIELD(*eqp, ESF_DZ_RX_L4_CLASS);
-   cont = EFX_QWORD_FIELD(*eqp, ESF_DZ_RX_CONT);
+
+   /*
+* RX_L4_CLASS is 3 bits wide on Huntington and Medford, but is only
+* 2 bits wide on Medford2. Check it is safe to use the Medford2 field
+* and values for all EF10 controllers.
+*/
+   EFX_STATIC_ASSERT(ESF_FZ_RX_L4_CLASS_LBN == ESF_DE_RX_L4_CLASS_LBN);
+   EFX_STATIC_ASSERT(ESE_FZ_L4_CLASS_TCP == ESE_DE_L4_CLASS_TCP);
+   EFX_STATIC_ASSERT(ESE_FZ_L4_CLASS_UDP == ESE_DE_L4_CLASS_UDP);
+   EFX_STATIC_ASSERT(ESE_FZ_L4_CLASS_UNKNOWN == ESE_DE_L4_CLASS_UNKNOWN);
+
+   l4_class = EFX_QWORD_FIELD(*eqp, ESF_FZ_RX_L4_CLASS);
 
if (EFX_QWORD_FIELD(*eqp, ESF_DZ_RX_DROP_EVENT) != 0) {
/* Drop this event */
@@ -952,10 +963,22 @@ ef10_ev_rx(
flags |= EFX_CKSUM_IPV4;
}
 
-   if (l4_class == ESE_DZ_L4_CLASS_TCP) {
+   /*
+* RX_L4_CLASS is 3 bits wide on Huntington and Medford, but is
+* only 2 bits wide on Medford2. Check it is safe to use the
+* Medford2 field and values for all EF10 controllers.
+*/
+   EFX_STATIC_ASSERT(ESF_FZ_RX_L4_CLASS_LBN ==
+   ESF_DE_RX_L4_CLASS_LBN);
+   EFX_STATIC_ASSERT(ESE_FZ_L4_CLASS_TCP == ESE_DE_L4_CLASS_TCP);
+   EFX_STATIC_ASSERT(ESE_FZ_L4_CLASS_UDP == ESE_DE_L4_CLASS_UDP);
+   EFX_STATIC_ASSERT(ESE_FZ_L4_CLASS_UNKNOWN ==
+   ESE_DE_L4_CLASS_UNKNOWN);
+
+   if (l4_class == ESE_FZ_L4_CLASS_TCP) {
EFX_EV_QSTAT_INCR(eep, EV_RX_TCP_IPV4);
flags |= EFX_PKT_TCP;
-   } else if (l4_class == ESE_DZ_L4_CLASS_UDP) {
+   } else if (l4_class == ESE_FZ_L4_CLASS_UDP) {
EFX_EV_QSTAT_INCR(eep, EV_RX_UDP_IPV4);
flags |= EFX_PKT_UDP;
} else {
@@ -967,10 +990,22 @@ ef10_ev_rx(
case ESE_DZ_L3_CLASS_IP6_FRAG:
flags |= EFX_PKT_IPV6;
 
-   if (l4_class == ESE_DZ_L4_CLASS_TCP) {
+   /*
+* RX_L4_CLASS is 3 bits wide on Huntington and Medford, but is
+* only 2 bits wide on Medford2. Check it is safe to use the
+* Medford2 field and values for all EF10 controllers.
+*/
+   EFX_STATIC_ASSERT(ESF_FZ_RX_L4_CLASS_LBN ==
+   ESF_DE_RX_L4_CLASS_LBN);
+   EFX_STATIC_ASSERT(ESE_FZ_L4_CLASS_TCP == ESE_DE_L4_CLASS_TCP);
+   EFX_STATIC_ASSERT(ESE_FZ_L4_CLASS_UDP == ESE_DE_L4_CLASS_UDP);
+   EFX_STATIC_ASSERT(ESE_FZ_L4_CLASS_UNKNOWN ==
+   ESE_DE_L4_CLASS_UNKNOWN);
+
+   if (l4_class == ESE_FZ_L4_CLASS_TCP) {
EFX_EV_QSTAT_INCR(eep, EV_RX_TCP_IPV6);
flags |= EFX_PKT_TCP;
-   } else if (l4_class == ESE_DZ_L4_CLASS_UDP) {
+   } else if (l4_class == ESE_FZ_L4_CLASS_UDP) {
EFX_EV_QSTAT_INCR(eep, EV_RX_UDP_IPV6);
flags |= EFX_PKT_UDP;
} else {
diff --git a/drivers/net/sfc/base/efx_regs_ef10.h 
b/drivers/net/sfc/base/efx_regs_ef10.h
index 5f97830..025dc08 100644
--- a/drivers/net/sfc/base/efx_regs_ef10.h
+++ b/drivers/net/sfc/base/efx_

[dpdk-dev] [PATCH 34/80] net/sfc/base: add efsys macro to get memory region size

2018-02-19 Thread Andrew Rybchenko
From: Andy Moreton 

EFSYS_MEM_SIZE() reports the DMA mapped size of an efsys_mem_t
allocated region (the allocation size may be different due to
memory allocator and DMA alignment restrictions).

This ensures that common code internals have explicit knowledge
of the usable size of DMA mapped memory regions.

Signed-off-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/ef10_rx.c   |  9 -
 drivers/net/sfc/base/ef10_tx.c   | 11 +--
 drivers/net/sfc/base/efx_intr.c  | 11 +++
 drivers/net/sfc/base/efx_mcdi.c  |  4 +++-
 drivers/net/sfc/base/siena_phy.c |  9 -
 drivers/net/sfc/efsys.h  |  3 +++
 6 files changed, 42 insertions(+), 5 deletions(-)

diff --git a/drivers/net/sfc/base/ef10_rx.c b/drivers/net/sfc/base/ef10_rx.c
index 79f2587..86a6ac7 100644
--- a/drivers/net/sfc/base/ef10_rx.c
+++ b/drivers/net/sfc/base/ef10_rx.c
@@ -37,6 +37,11 @@ efx_mcdi_init_rxq(
 
EFSYS_ASSERT3U(ndescs, <=, EFX_RXQ_MAXNDESCS);
 
+   if ((esmp == NULL) || (EFSYS_MEM_SIZE(esmp) < EFX_RXQ_SIZE(ndescs))) {
+   rc = EINVAL;
+   goto fail1;
+   }
+
if (ps_bufsize > 0)
dma_mode = MC_CMD_INIT_RXQ_EXT_IN_PACKED_STREAM;
else
@@ -103,11 +108,13 @@ efx_mcdi_init_rxq(
 
if (req.emr_rc != 0) {
rc = req.emr_rc;
-   goto fail1;
+   goto fail2;
}
 
return (0);
 
+fail2:
+   EFSYS_PROBE(fail2);
 fail1:
EFSYS_PROBE1(fail1, efx_rc_t, rc);
 
diff --git a/drivers/net/sfc/base/ef10_tx.c b/drivers/net/sfc/base/ef10_tx.c
index 3087306..8ca0b55 100644
--- a/drivers/net/sfc/base/ef10_tx.c
+++ b/drivers/net/sfc/base/ef10_tx.c
@@ -42,10 +42,15 @@ efx_mcdi_init_txq(
EFSYS_ASSERT(EFX_TXQ_MAX_BUFS >=
EFX_TXQ_NBUFS(enp->en_nic_cfg.enc_txq_max_ndescs));
 
+   if ((esmp == NULL) || (EFSYS_MEM_SIZE(esmp) < EFX_TXQ_SIZE(ndescs))) {
+   rc = EINVAL;
+   goto fail1;
+   }
+
npages = EFX_TXQ_NBUFS(ndescs);
if (MC_CMD_INIT_TXQ_IN_LEN(npages) > sizeof (payload)) {
rc = EINVAL;
-   goto fail1;
+   goto fail2;
}
 
(void) memset(payload, 0, sizeof (payload));
@@ -94,11 +99,13 @@ efx_mcdi_init_txq(
 
if (req.emr_rc != 0) {
rc = req.emr_rc;
-   goto fail2;
+   goto fail3;
}
 
return (0);
 
+fail3:
+   EFSYS_PROBE(fail3);
 fail2:
EFSYS_PROBE(fail2);
 fail1:
diff --git a/drivers/net/sfc/base/efx_intr.c b/drivers/net/sfc/base/efx_intr.c
index 49cfaf7..b518916 100644
--- a/drivers/net/sfc/base/efx_intr.c
+++ b/drivers/net/sfc/base/efx_intr.c
@@ -289,6 +289,12 @@ siena_intr_init(
 {
efx_intr_t *eip = &(enp->en_intr);
efx_oword_t oword;
+   efx_rc_t rc;
+
+   if ((esmp == NULL) || (EFSYS_MEM_SIZE(esmp) < EFX_INTR_SIZE)) {
+   rc = EINVAL;
+   goto fail1;
+   }
 
/*
 * bug17213 workaround.
@@ -320,6 +326,11 @@ siena_intr_init(
EFX_BAR_WRITEO(enp, FR_AZ_INT_ADR_REG_KER, &oword);
 
return (0);
+
+fail1:
+   EFSYS_PROBE1(fail1, efx_rc_t, rc);
+
+   return (rc);
 }
 
 static void
diff --git a/drivers/net/sfc/base/efx_mcdi.c b/drivers/net/sfc/base/efx_mcdi.c
index 9d7b741..3352b08 100644
--- a/drivers/net/sfc/base/efx_mcdi.c
+++ b/drivers/net/sfc/base/efx_mcdi.c
@@ -1815,11 +1815,13 @@ efx_mcdi_mac_stats(
MAC_STATS_IN_PERIOD_MS, (enable | events) ? period_ms : 0);
 
if (esmp != NULL) {
-   int bytes = MC_CMD_MAC_NSTATS * sizeof (uint64_t);
+   uint32_t bytes = MC_CMD_MAC_NSTATS * sizeof (uint64_t);
 
EFX_STATIC_ASSERT(MC_CMD_MAC_NSTATS * sizeof (uint64_t) <=
EFX_MAC_STATS_SIZE);
 
+   EFSYS_ASSERT3U(bytes, <=, (uint32_t)EFSYS_MEM_SIZE(esmp));
+
MCDI_IN_SET_DWORD(req, MAC_STATS_IN_DMA_ADDR_LO,
EFSYS_MEM_ADDR(esmp) & 0x);
MCDI_IN_SET_DWORD(req, MAC_STATS_IN_DMA_ADDR_HI,
diff --git a/drivers/net/sfc/base/siena_phy.c b/drivers/net/sfc/base/siena_phy.c
index d638646..4b2190d 100644
--- a/drivers/net/sfc/base/siena_phy.c
+++ b/drivers/net/sfc/base/siena_phy.c
@@ -534,6 +534,11 @@ siena_phy_stats_update(
MC_CMD_PHY_STATS_OUT_DMA_LEN)];
efx_rc_t rc;
 
+   if ((esmp == NULL) || (EFSYS_MEM_SIZE(esmp) < EFX_PHY_STATS_SIZE)) {
+   rc = EINVAL;
+   goto fail1;
+   }
+
(void) memset(payload, 0, sizeof (payload));
req.emr_cmd = MC_CMD_PHY_STATS;
req.emr_in_buf = payload;
@@ -550,7 +555,7 @@ siena_phy_stats_update(
 
if (req.emr_rc != 0) {
rc = req.emr_rc;
-   goto fail1;
+   goto fail2;
}
EFSYS_ASSERT3U(req.emr_out_length, ==, MC_CMD_PHY_STATS_OUT_DMA_LEN);
 
@@ -559,6 +564,8 @@ 

[dpdk-dev] [PATCH 36/80] net/sfc/base: refactor EF10 get datapath capabilities

2018-02-19 Thread Andrew Rybchenko
From: Andy Moreton 

Inline efx_mcdi_get_capabilities() to prepare for reading
newer capabilities response versions.

Signed-off-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/ef10_nic.c | 149 ++--
 1 file changed, 99 insertions(+), 50 deletions(-)

diff --git a/drivers/net/sfc/base/ef10_nic.c b/drivers/net/sfc/base/ef10_nic.c
index 62d41d2..66ea353 100644
--- a/drivers/net/sfc/base/ef10_nic.c
+++ b/drivers/net/sfc/base/ef10_nic.c
@@ -994,57 +994,86 @@ ef10_get_datapath_caps(
__inefx_nic_t *enp)
 {
efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
-   uint32_t flags;
-   uint32_t flags2;
-   uint32_t tso2nc;
+   efx_mcdi_req_t req;
+   uint8_t payload[MAX(MC_CMD_GET_CAPABILITIES_IN_LEN,
+   MC_CMD_GET_CAPABILITIES_V2_OUT_LEN)];
efx_rc_t rc;
 
-   if ((rc = efx_mcdi_get_capabilities(enp, &flags, NULL, NULL,
-   &flags2, &tso2nc)) != 0)
-   goto fail1;
-
if ((rc = ef10_mcdi_get_pf_count(enp, &encp->enc_hw_pf_count)) != 0)
goto fail1;
 
-#defineCAP_FLAG(flags1, field) \
-   ((flags1) & (1 << (MC_CMD_GET_CAPABILITIES_V2_OUT_ ## field ## _LBN)))
 
-#defineCAP_FLAG2(flags2, field)\
-   ((flags2) & (1 << (MC_CMD_GET_CAPABILITIES_V2_OUT_ ## field ## _LBN)))
+   (void) memset(payload, 0, sizeof (payload));
+   req.emr_cmd = MC_CMD_GET_CAPABILITIES;
+   req.emr_in_buf = payload;
+   req.emr_in_length = MC_CMD_GET_CAPABILITIES_IN_LEN;
+   req.emr_out_buf = payload;
+   req.emr_out_length = MC_CMD_GET_CAPABILITIES_V2_OUT_LEN;
+
+   efx_mcdi_execute_quiet(enp, &req);
+
+   if (req.emr_rc != 0) {
+   rc = req.emr_rc;
+   goto fail2;
+   }
+
+   if (req.emr_out_length_used < MC_CMD_GET_CAPABILITIES_OUT_LEN) {
+   rc = EMSGSIZE;
+   goto fail3;
+   }
+
+#defineCAP_FLAGS1(_req, _flag) 
\
+   (MCDI_OUT_DWORD((_req), GET_CAPABILITIES_OUT_FLAGS1) &  \
+   (1u << (MC_CMD_GET_CAPABILITIES_V2_OUT_ ## _flag ## _LBN)))
+
+#defineCAP_FLAGS2(_req, _flag) 
\
+   (((_req).emr_out_length_used >= MC_CMD_GET_CAPABILITIES_V2_OUT_LEN) && \
+   (MCDI_OUT_DWORD((_req), GET_CAPABILITIES_V2_OUT_FLAGS2) &   \
+   (1u << (MC_CMD_GET_CAPABILITIES_V2_OUT_ ## _flag ## _LBN
 
/*
 * Huntington RXDP firmware inserts a 0 or 14 byte prefix.
 * We only support the 14 byte prefix here.
 */
-   if (CAP_FLAG(flags, RX_PREFIX_LEN_14) == 0) {
+   if (CAP_FLAGS1(req, RX_PREFIX_LEN_14) == 0) {
rc = ENOTSUP;
-   goto fail2;
+   goto fail4;
}
encp->enc_rx_prefix_size = 14;
 
/* Check if the firmware supports TSO */
-   encp->enc_fw_assisted_tso_enabled =
-   CAP_FLAG(flags, TX_TSO) ? B_TRUE : B_FALSE;
+   if (CAP_FLAGS1(req, TX_TSO))
+   encp->enc_fw_assisted_tso_enabled = B_TRUE;
+   else
+   encp->enc_fw_assisted_tso_enabled = B_FALSE;
 
/* Check if the firmware supports FATSOv2 */
-   encp->enc_fw_assisted_tso_v2_enabled =
-   CAP_FLAG2(flags2, TX_TSO_V2) ? B_TRUE : B_FALSE;
-
-   /* Get the number of TSO contexts (FATSOv2) */
-   encp->enc_fw_assisted_tso_v2_n_contexts =
-   CAP_FLAG2(flags2, TX_TSO_V2) ? tso2nc : 0;
+   if (CAP_FLAGS2(req, TX_TSO_V2)) {
+   encp->enc_fw_assisted_tso_v2_enabled = B_TRUE;
+   encp->enc_fw_assisted_tso_v2_n_contexts = MCDI_OUT_WORD(req,
+   GET_CAPABILITIES_V2_OUT_TX_TSO_V2_N_CONTEXTS);
+   } else {
+   encp->enc_fw_assisted_tso_v2_enabled = B_FALSE;
+   encp->enc_fw_assisted_tso_v2_n_contexts = 0;
+   }
 
/* Check if the firmware has vadapter/vport/vswitch support */
-   encp->enc_datapath_cap_evb =
-   CAP_FLAG(flags, EVB) ? B_TRUE : B_FALSE;
+   if (CAP_FLAGS1(req, EVB))
+   encp->enc_datapath_cap_evb = B_TRUE;
+   else
+   encp->enc_datapath_cap_evb = B_FALSE;
 
/* Check if the firmware supports VLAN insertion */
-   encp->enc_hw_tx_insert_vlan_enabled =
-   CAP_FLAG(flags, TX_VLAN_INSERTION) ? B_TRUE : B_FALSE;
+   if (CAP_FLAGS1(req, TX_VLAN_INSERTION))
+   encp->enc_hw_tx_insert_vlan_enabled = B_TRUE;
+   else
+   encp->enc_hw_tx_insert_vlan_enabled = B_FALSE;
 
/* Check if the firmware supports RX event batching */
-   encp->enc_rx_batching_enabled =
-   CAP_FLAG(flags, RX_BATCHING) ? B_TRUE : B_FALSE;
+   if (CAP_FLAGS1(req, RX_BATCHING))
+   encp->enc_rx_batching_enabled = B_TRUE;
+   else
+   encp->enc_rx_batching_enabled = B_FA

[dpdk-dev] [PATCH 38/80] net/sfc/base: improve robustness of MAC stats get via MCDI

2018-02-19 Thread Andrew Rybchenko
From: Andy Moreton 

Previously the code relied on the callers of efx_mcdi_mac_stats
to provide a DMA buffer or NULL depnding on the action. Fix
this so that the DMA buffer is only passed in the request when
needed, and that an error is reported for a missing DMA buffer.

Signed-off-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/efx_mcdi.c | 14 ++
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/net/sfc/base/efx_mcdi.c b/drivers/net/sfc/base/efx_mcdi.c
index 3352b08..a593b3f 100644
--- a/drivers/net/sfc/base/efx_mcdi.c
+++ b/drivers/net/sfc/base/efx_mcdi.c
@@ -1814,9 +1814,15 @@ efx_mcdi_mac_stats(
MAC_STATS_IN_PERIODIC_NOEVENT, !events,
MAC_STATS_IN_PERIOD_MS, (enable | events) ? period_ms : 0);
 
-   if (esmp != NULL) {
+   if (enable || events || upload) {
uint32_t bytes = MC_CMD_MAC_NSTATS * sizeof (uint64_t);
 
+   /* Periodic stats or stats upload require a DMA buffer */
+   if (esmp == NULL) {
+   rc = EINVAL;
+   goto fail1;
+   }
+
EFX_STATIC_ASSERT(MC_CMD_MAC_NSTATS * sizeof (uint64_t) <=
EFX_MAC_STATS_SIZE);
 
@@ -1827,8 +1833,6 @@ efx_mcdi_mac_stats(
MCDI_IN_SET_DWORD(req, MAC_STATS_IN_DMA_ADDR_HI,
EFSYS_MEM_ADDR(esmp) >> 32);
MCDI_IN_SET_DWORD(req, MAC_STATS_IN_DMA_LEN, bytes);
-   } else {
-   EFSYS_ASSERT(!upload && !enable && !events);
}
 
/*
@@ -1846,12 +1850,14 @@ efx_mcdi_mac_stats(
if ((req.emr_rc != ENOENT) ||
(enp->en_rx_qcount + enp->en_tx_qcount != 0)) {
rc = req.emr_rc;
-   goto fail1;
+   goto fail2;
}
}
 
return (0);
 
+fail2:
+   EFSYS_PROBE(fail2);
 fail1:
EFSYS_PROBE1(fail1, efx_rc_t, rc);
 
-- 
2.7.4



[dpdk-dev] [PATCH 37/80] net/sfc/base: retrieve number of MAC stats from NIC

2018-02-19 Thread Andrew Rybchenko
From: Andy Moreton 

This reports the number of stats (and hence the DMA buffer size)
for MAC stats. If MC_GET_CAPABABILITIES_V4 is not supported then
use the legacy Siena-compatible MC_CMD_MAC_NSTATS value.

Signed-off-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/ef10_nic.c  | 14 --
 drivers/net/sfc/base/efx.h   |  2 ++
 drivers/net/sfc/base/siena_nic.c |  2 ++
 3 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/drivers/net/sfc/base/ef10_nic.c b/drivers/net/sfc/base/ef10_nic.c
index 66ea353..a23cf63 100644
--- a/drivers/net/sfc/base/ef10_nic.c
+++ b/drivers/net/sfc/base/ef10_nic.c
@@ -996,7 +996,7 @@ ef10_get_datapath_caps(
efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
efx_mcdi_req_t req;
uint8_t payload[MAX(MC_CMD_GET_CAPABILITIES_IN_LEN,
-   MC_CMD_GET_CAPABILITIES_V2_OUT_LEN)];
+   MC_CMD_GET_CAPABILITIES_V4_OUT_LEN)];
efx_rc_t rc;
 
if ((rc = ef10_mcdi_get_pf_count(enp, &encp->enc_hw_pf_count)) != 0)
@@ -1008,7 +1008,7 @@ ef10_get_datapath_caps(
req.emr_in_buf = payload;
req.emr_in_length = MC_CMD_GET_CAPABILITIES_IN_LEN;
req.emr_out_buf = payload;
-   req.emr_out_length = MC_CMD_GET_CAPABILITIES_V2_OUT_LEN;
+   req.emr_out_length = MC_CMD_GET_CAPABILITIES_V4_OUT_LEN;
 
efx_mcdi_execute_quiet(enp, &req);
 
@@ -1175,6 +1175,16 @@ ef10_get_datapath_caps(
encp->enc_tunnel_config_udp_entries_max = 0;
}
 
+   /* Check if firmware supports extended MAC stats. */
+   if (req.emr_out_length_used >= MC_CMD_GET_CAPABILITIES_V4_OUT_LEN) {
+   /* Extended stats buffer supported */
+   encp->enc_mac_stats_nstats = MCDI_OUT_WORD(req,
+   GET_CAPABILITIES_V4_OUT_MAC_STATS_NUM_STATS);
+   } else {
+   /* Use Siena-compatible legacy MAC stats */
+   encp->enc_mac_stats_nstats = MC_CMD_MAC_NSTATS;
+   }
+
 #undef CAP_FLAGS1
 #undef CAP_FLAGS2
 
diff --git a/drivers/net/sfc/base/efx.h b/drivers/net/sfc/base/efx.h
index 2c7e932..fd02af1 100644
--- a/drivers/net/sfc/base/efx.h
+++ b/drivers/net/sfc/base/efx.h
@@ -1232,6 +1232,8 @@ typedef struct efx_nic_cfg_s {
uint32_tenc_max_pcie_link_gen;
/* Firmware verifies integrity of NVRAM updates */
uint32_tenc_nvram_update_verify_result_supported;
+   /* Firmware support for extended MAC_STATS buffer */
+   uint32_tenc_mac_stats_nstats;
 } efx_nic_cfg_t;
 
 #defineEFX_PCI_FUNCTION_IS_PF(_encp)   ((_encp)->enc_vf == 0x)
diff --git a/drivers/net/sfc/base/siena_nic.c b/drivers/net/sfc/base/siena_nic.c
index c051c59..f518a54 100644
--- a/drivers/net/sfc/base/siena_nic.c
+++ b/drivers/net/sfc/base/siena_nic.c
@@ -156,6 +156,8 @@ siena_board_cfg(
 
encp->enc_nvram_update_verify_result_supported = B_FALSE;
 
+   encp->enc_mac_stats_nstats = MC_CMD_MAC_NSTATS;
+
return (0);
 
 fail2:
-- 
2.7.4



[dpdk-dev] [PATCH 46/80] net/sfc/base: use correct name for frame truncation event

2018-02-19 Thread Andrew Rybchenko
From: Andy Moreton 

The RX_ECC_ERR flag in RX events was misnamed, as it
reported frame truncation. Use the new RX_TRUNC_ERR
name for this flag.

Signed-off-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/ef10_ev.c   | 8 
 drivers/net/sfc/base/efx_regs_ef10.h | 2 ++
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/net/sfc/base/ef10_ev.c b/drivers/net/sfc/base/ef10_ev.c
index c7173c3..256156b 100644
--- a/drivers/net/sfc/base/ef10_ev.c
+++ b/drivers/net/sfc/base/ef10_ev.c
@@ -788,8 +788,8 @@ ef10_ev_rx_packed_stream(
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) */
+   if (EFX_QWORD_FIELD(*eqp, ESF_DZ_RX_TRUNC_ERR) != 0) {
+   /* RX frame truncated */
EFX_EV_QSTAT_INCR(eep, EV_RX_FRM_TRUNC);
flags |= EFX_DISCARD;
goto deliver;
@@ -926,8 +926,8 @@ ef10_ev_rx(
last_used_id = (eersp->eers_rx_read_ptr - 1) & 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) */
+   if (EFX_QWORD_FIELD(*eqp, ESF_DZ_RX_TRUNC_ERR) != 0) {
+   /* RX frame truncated */
EFX_EV_QSTAT_INCR(eep, EV_RX_FRM_TRUNC);
flags |= EFX_DISCARD;
goto deliver;
diff --git a/drivers/net/sfc/base/efx_regs_ef10.h 
b/drivers/net/sfc/base/efx_regs_ef10.h
index 025dc08..a832ce7 100644
--- a/drivers/net/sfc/base/efx_regs_ef10.h
+++ b/drivers/net/sfc/base/efx_regs_ef10.h
@@ -446,6 +446,8 @@ extern "C" {
 #defineESF_EZ_RX_ABORT_WIDTH 1
 #defineESF_DZ_RX_ECC_ERR_LBN 29
 #defineESF_DZ_RX_ECC_ERR_WIDTH 1
+#defineESF_DZ_RX_TRUNC_ERR_LBN 29
+#defineESF_DZ_RX_TRUNC_ERR_WIDTH 1
 #defineESF_DZ_RX_CRC1_ERR_LBN 28
 #defineESF_DZ_RX_CRC1_ERR_WIDTH 1
 #defineESF_DZ_RX_CRC0_ERR_LBN 27
-- 
2.7.4



[dpdk-dev] [PATCH 41/80] net/sfc/base: run mkconfig.py to add FEC MAC stats

2018-02-19 Thread Andrew Rybchenko
From: Andy Moreton 

Signed-off-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/efx.h | 8 +++-
 drivers/net/sfc/base/efx_mac.c | 8 +++-
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/net/sfc/base/efx.h b/drivers/net/sfc/base/efx.h
index fd02af1..ba1f76d 100644
--- a/drivers/net/sfc/base/efx.h
+++ b/drivers/net/sfc/base/efx.h
@@ -323,7 +323,7 @@ efx_intr_fini(
 
 #if EFSYS_OPT_MAC_STATS
 
-/* START MKCONFIG GENERATED EfxHeaderMacBlock e323546097fd7c65 */
+/* START MKCONFIG GENERATED EfxHeaderMacBlock 7b5f45054a3b45bc */
 typedef enum efx_mac_stat_e {
EFX_MAC_RX_OCTETS,
EFX_MAC_RX_PKTS,
@@ -406,6 +406,12 @@ typedef enum efx_mac_stat_e {
EFX_MAC_VADAPTER_TX_BAD_PACKETS,
EFX_MAC_VADAPTER_TX_BAD_BYTES,
EFX_MAC_VADAPTER_TX_OVERFLOW,
+   EFX_MAC_FEC_UNCORRECTED_ERRORS,
+   EFX_MAC_FEC_CORRECTED_ERRORS,
+   EFX_MAC_FEC_CORRECTED_SYMBOLS_LANE0,
+   EFX_MAC_FEC_CORRECTED_SYMBOLS_LANE1,
+   EFX_MAC_FEC_CORRECTED_SYMBOLS_LANE2,
+   EFX_MAC_FEC_CORRECTED_SYMBOLS_LANE3,
EFX_MAC_NSTATS
 } efx_mac_stat_t;
 
diff --git a/drivers/net/sfc/base/efx_mac.c b/drivers/net/sfc/base/efx_mac.c
index 117d6d5..4196280 100644
--- a/drivers/net/sfc/base/efx_mac.c
+++ b/drivers/net/sfc/base/efx_mac.c
@@ -492,7 +492,7 @@ efx_mac_filter_default_rxq_clear(
 
 #if EFSYS_OPT_NAMES
 
-/* START MKCONFIG GENERATED EfxMacStatNamesBlock c11b91b42f922516 */
+/* START MKCONFIG GENERATED EfxMacStatNamesBlock 8726fc355b6e7c1a */
 static const char * const __efx_mac_stat_name[] = {
"rx_octets",
"rx_pkts",
@@ -575,6 +575,12 @@ static const char * const __efx_mac_stat_name[] = {
"vadapter_tx_bad_packets",
"vadapter_tx_bad_bytes",
"vadapter_tx_overflow",
+   "fec_uncorrected_errors",
+   "fec_corrected_errors",
+   "fec_corrected_symbols_lane0",
+   "fec_corrected_symbols_lane1",
+   "fec_corrected_symbols_lane2",
+   "fec_corrected_symbols_lane3",
 };
 /* END MKCONFIG GENERATED EfxMacStatNamesBlock */
 
-- 
2.7.4



[dpdk-dev] [PATCH 47/80] net/sfc/base: add ef10 NIC board config method

2018-02-19 Thread Andrew Rybchenko
From: Andy Moreton 

Signed-off-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/ef10_nic.c | 24 
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/drivers/net/sfc/base/ef10_nic.c b/drivers/net/sfc/base/ef10_nic.c
index b06c73e..b315e9f 100644
--- a/drivers/net/sfc/base/ef10_nic.c
+++ b/drivers/net/sfc/base/ef10_nic.c
@@ -1541,12 +1541,29 @@ ef10_external_port_mapping(
return (rc);
 }
 
+static __checkReturn   efx_rc_t
+ef10_nic_board_cfg(
+   __inefx_nic_t *enp)
+{
+   const efx_nic_ops_t *enop = enp->en_enop;
+   efx_rc_t rc;
+
+   if ((rc = enop->eno_board_cfg(enp)) != 0)
+   if (rc != EACCES)
+   goto fail1;
+
+   return (0);
+
+fail1:
+   EFSYS_PROBE1(fail1, efx_rc_t, rc);
+
+   return (rc);
+}
 
__checkReturn   efx_rc_t
 ef10_nic_probe(
__inefx_nic_t *enp)
 {
-   const efx_nic_ops_t *enop = enp->en_enop;
efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
efx_drv_cfg_t *edcp = &(enp->en_drv_cfg);
efx_rc_t rc;
@@ -1567,9 +1584,8 @@ ef10_nic_probe(
if ((rc = efx_mcdi_drv_attach(enp, B_TRUE)) != 0)
goto fail3;
 
-   if ((rc = enop->eno_board_cfg(enp)) != 0)
-   if (rc != EACCES)
-   goto fail4;
+   if ((rc = ef10_nic_board_cfg(enp)) != 0)
+   goto fail4;
 
/*
 * Set default driver config limits (based on board config).
-- 
2.7.4



[dpdk-dev] [PATCH 02/80] net/sfc/base: regenerate files with genfwdef after ID update

2018-02-19 Thread Andrew Rybchenko
From: Andrew Jackson 

Add security level to image boot header.

Signed-off-by: Andrew Jackson 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/siena_flash.h | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/net/sfc/base/siena_flash.h 
b/drivers/net/sfc/base/siena_flash.h
index 91a9fe0..74bb949 100644
--- a/drivers/net/sfc/base/siena_flash.h
+++ b/drivers/net/sfc/base/siena_flash.h
@@ -103,7 +103,14 @@ typedef struct siena_mc_boot_hdr_s {   /* 
GENERATED BY scripts/genfwdef */
/* the key, or 0x if 
unsigned. (Otherwise set to 0) */
efx_byte_t  mumfw_subtype;  /* MUM & SUC images: subtype. 
(Otherwise set to 0) */
efx_byte_t  reserved_b[3];  /* (set to 0) */
-   efx_dword_t reserved_c[6];  /* (set to 0) */
+   efx_dword_t security_level; /* This number increases every 
time a serious security flaw */
+   /* is fixed. A secure NIC may 
not downgrade to any image */
+   /* with a lower security level 
than the current image. */
+   /* Note: The number in this 
header should only be used for */
+   /* determining the level of new 
images, not to determine */
+   /* the level of the current 
image as this header is not */
+   /* protected by a CMAC. */
+   efx_dword_t reserved_c[5];  /* (set to 0) */
 } siena_mc_boot_hdr_t;
 
 #defineSIENA_MC_BOOT_HDR_PADDING \
-- 
2.7.4



[dpdk-dev] [PATCH 40/80] net/sfc/base: use MAC stats DMA buffer size when decoding

2018-02-19 Thread Andrew Rybchenko
From: Andy Moreton 

On Medford2 and later the MAC stats buffer has been enlarged.
Use the MAC stats DMA buffer size to ensure that the stats END
generation count is read from the correct location, and that
over-reading of the DMA buffer is prevented.

Signed-off-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/ef10_mac.c  | 50 ++--
 drivers/net/sfc/base/siena_mac.c | 29 +++
 2 files changed, 67 insertions(+), 12 deletions(-)

diff --git a/drivers/net/sfc/base/ef10_mac.c b/drivers/net/sfc/base/ef10_mac.c
index ed778f7..b1534a8 100644
--- a/drivers/net/sfc/base/ef10_mac.c
+++ b/drivers/net/sfc/base/ef10_mac.c
@@ -552,16 +552,45 @@ ef10_mac_stats_update(
__inout_ecount(EFX_MAC_NSTATS)  efsys_stat_t *stat,
__inout_opt uint32_t *generationp)
 {
-   efx_qword_t value;
+   const efx_nic_cfg_t *encp = &enp->en_nic_cfg;
efx_qword_t generation_start;
efx_qword_t generation_end;
+   efx_qword_t value;
+   efx_rc_t rc;
 
-   _NOTE(ARGUNUSED(enp))
+   /*
+* The MAC_STATS contain start and end generation counters used to
+* detect when the DMA buffer has been updated during stats decode.
+* All stats counters are 64bit unsigned values.
+*
+* Siena-compatible MAC stats contain MC_CMD_MAC_NSTATS 64bit counters.
+* The generation end counter is at index MC_CMD_MAC_GENERATION_END
+* (same as MC_CMD_MAC_NSTATS-1).
+*
+* Medford2 and later use a larger DMA buffer: MAC_STATS_NUM_STATS from
+* MC_CMD_GET_CAPABILITIES_V4_OUT reports the number of 64bit counters.
+*
+* Firmware writes the generation end counter as the last counter in the
+* DMA buffer. Do not use MC_CMD_MAC_GENERATION_END, as that is only
+* correct for legacy Siena-compatible MAC stats.
+*/
+
+   if (encp->enc_mac_stats_nstats < MC_CMD_MAC_NSTATS) {
+   /* MAC stats count too small for legacy MAC stats */
+   rc = ENOSPC;
+   goto fail1;
+   }
+   if (EFSYS_MEM_SIZE(esmp) <
+   (encp->enc_mac_stats_nstats * sizeof (efx_qword_t))) {
+   /* DMA buffer too small */
+   rc = ENOSPC;
+   goto fail2;
+   }
 
/* Read END first so we don't race with the MC */
-   EFSYS_DMA_SYNC_FOR_KERNEL(esmp, 0, EFX_MAC_STATS_SIZE);
-   EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_GENERATION_END,
-   &generation_end);
+   EFSYS_DMA_SYNC_FOR_KERNEL(esmp, 0, EFSYS_MEM_SIZE(esmp));
+   EF10_MAC_STAT_READ(esmp, (encp->enc_mac_stats_nstats - 1),
+   &generation_end);
EFSYS_MEM_READ_BARRIER();
 
/* TX */
@@ -851,8 +880,8 @@ ef10_mac_stats_update(
EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_VADAPTER_TX_OVERFLOW, &value);
EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_VADAPTER_TX_OVERFLOW]), &value);
 
-
-   EFSYS_DMA_SYNC_FOR_KERNEL(esmp, 0, EFX_MAC_STATS_SIZE);
+   /* Read START generation counter */
+   EFSYS_DMA_SYNC_FOR_KERNEL(esmp, 0, EFSYS_MEM_SIZE(esmp));
EFSYS_MEM_READ_BARRIER();
EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_GENERATION_START,
&generation_start);
@@ -867,6 +896,13 @@ ef10_mac_stats_update(
*generationp = EFX_QWORD_FIELD(generation_start, EFX_DWORD_0);
 
return (0);
+
+fail2:
+   EFSYS_PROBE(fail2);
+fail1:
+   EFSYS_PROBE1(fail1, efx_rc_t, rc);
+
+   return (rc);
 }
 
 #endif /* EFSYS_OPT_MAC_STATS */
diff --git a/drivers/net/sfc/base/siena_mac.c b/drivers/net/sfc/base/siena_mac.c
index 904e03e..f395355 100644
--- a/drivers/net/sfc/base/siena_mac.c
+++ b/drivers/net/sfc/base/siena_mac.c
@@ -245,16 +245,28 @@ siena_mac_stats_update(
__inout_ecount(EFX_MAC_NSTATS)  efsys_stat_t *stat,
__inout_opt uint32_t *generationp)
 {
-   efx_qword_t value;
+   const efx_nic_cfg_t *encp = &enp->en_nic_cfg;
efx_qword_t generation_start;
efx_qword_t generation_end;
+   efx_qword_t value;
+   efx_rc_t rc;
 
-   _NOTE(ARGUNUSED(enp))
+   if (encp->enc_mac_stats_nstats < MC_CMD_MAC_NSTATS) {
+   /* MAC stats count too small */
+   rc = ENOSPC;
+   goto fail1;
+   }
+   if (EFSYS_MEM_SIZE(esmp) <
+   (encp->enc_mac_stats_nstats * sizeof (efx_qword_t))) {
+   /* DMA buffer too small */
+   rc = ENOSPC;
+   goto fail2;
+   }
 
/* Read END first so we don't race with the MC */
-   EFSYS_DMA_SYNC_FOR_KERNEL(esmp, 0, EFX_MAC_STATS_SIZE);
-   SIENA_MAC_STAT_READ(esmp, MC_CMD_MAC_GENERATION_END,
-   &generation_end);
+   EFSYS_DMA_SYNC_FOR_KERNEL(esmp, 0, EFSYS_MEM_SIZE(esmp));
+   SIENA_MAC_STAT_READ(esmp, (encp->enc_mac_stats_nstats - 1),
+   &generation_end);

[dpdk-dev] [PATCH 50/80] net/sfc/base: move MAC address config to ef10 NIC board cfg

2018-02-19 Thread Andrew Rybchenko
From: Andy Moreton 

Signed-off-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/ef10_nic.c | 33 +++-
 drivers/net/sfc/base/hunt_nic.c | 45 
 drivers/net/sfc/base/medford2_nic.c | 51 -
 drivers/net/sfc/base/medford_nic.c  | 51 -
 4 files changed, 63 insertions(+), 117 deletions(-)

diff --git a/drivers/net/sfc/base/ef10_nic.c b/drivers/net/sfc/base/ef10_nic.c
index c9ba41d..ce99d09 100644
--- a/drivers/net/sfc/base/ef10_nic.c
+++ b/drivers/net/sfc/base/ef10_nic.c
@@ -1551,6 +1551,7 @@ ef10_nic_board_cfg(
uint32_t port;
uint32_t pf;
uint32_t vf;
+   uint8_t mac_addr[6] = { 0 };
efx_rc_t rc;
 
/* Get the (zero-based) MCDI port number */
@@ -1576,13 +1577,43 @@ ef10_nic_board_cfg(
encp->enc_pf = pf;
encp->enc_vf = vf;
 
+   /* MAC address for this function */
+   if (EFX_PCI_FUNCTION_IS_PF(encp)) {
+   rc = efx_mcdi_get_mac_address_pf(enp, mac_addr);
+#if EFSYS_OPT_ALLOW_UNCONFIGURED_NIC
+   /*
+* Disable static config checking, ONLY for manufacturing test
+* and setup at the factory, to allow the static config to be
+* installed.
+*/
+#else /* EFSYS_OPT_ALLOW_UNCONFIGURED_NIC */
+   if ((rc == 0) && (mac_addr[0] & 0x02)) {
+   /*
+* If the static config does not include a global MAC
+* address pool then the board may return a locally
+* administered MAC address (this should only happen on
+* incorrectly programmed boards).
+*/
+   rc = EINVAL;
+   }
+#endif /* EFSYS_OPT_ALLOW_UNCONFIGURED_NIC */
+   } else {
+   rc = efx_mcdi_get_mac_address_vf(enp, mac_addr);
+   }
+   if (rc != 0)
+   goto fail4;
+
+   EFX_MAC_ADDR_COPY(encp->enc_mac_addr, mac_addr);
+
/* Get remaining controller-specific board config */
if ((rc = enop->eno_board_cfg(enp)) != 0)
if (rc != EACCES)
-   goto fail4;
+   goto fail5;
 
return (0);
 
+fail5:
+   EFSYS_PROBE(fail5);
 fail4:
EFSYS_PROBE(fail4);
 fail3:
diff --git a/drivers/net/sfc/base/hunt_nic.c b/drivers/net/sfc/base/hunt_nic.c
index 84fd198..13f769c 100644
--- a/drivers/net/sfc/base/hunt_nic.c
+++ b/drivers/net/sfc/base/hunt_nic.c
@@ -77,7 +77,6 @@ hunt_board_cfg(
__inefx_nic_t *enp)
 {
efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
-   uint8_t mac_addr[6] = { 0 };
uint32_t board_type = 0;
ef10_link_state_t els;
efx_port_t *epp = &(enp->en_port);
@@ -98,26 +97,6 @@ hunt_board_cfg(
EFX_STATIC_ASSERT(1U << EFX_VI_WINDOW_SHIFT_8K  == 8192);
encp->enc_vi_window_shift = EFX_VI_WINDOW_SHIFT_8K;
 
-   /* MAC address for this function */
-   if (EFX_PCI_FUNCTION_IS_PF(encp)) {
-   rc = efx_mcdi_get_mac_address_pf(enp, mac_addr);
-   if ((rc == 0) && (mac_addr[0] & 0x02)) {
-   /*
-* If the static config does not include a global MAC
-* address pool then the board may return a locally
-* administered MAC address (this should only happen on
-* incorrectly programmed boards).
-*/
-   rc = EINVAL;
-   }
-   } else {
-   rc = efx_mcdi_get_mac_address_vf(enp, mac_addr);
-   }
-   if (rc != 0)
-   goto fail1;
-
-   EFX_MAC_ADDR_COPY(encp->enc_mac_addr, mac_addr);
-
/* Board configuration */
rc = efx_mcdi_get_board_cfg(enp, &board_type, NULL, NULL);
if (rc != 0) {
@@ -125,7 +104,7 @@ hunt_board_cfg(
if (rc == EACCES)
board_type = 0;
else
-   goto fail2;
+   goto fail1;
}
 
encp->enc_board_type = board_type;
@@ -133,11 +112,11 @@ hunt_board_cfg(
 
/* Fill out fields in enp->en_port and enp->en_nic_cfg from MCDI */
if ((rc = efx_mcdi_get_phy_cfg(enp)) != 0)
-   goto fail3;
+   goto fail2;
 
/* Obtain the default PHY advertised capabilities */
if ((rc = ef10_phy_get_link(enp, &els)) != 0)
-   goto fail4;
+   goto fail3;
epp->ep_default_adv_cap_mask = els.els_adv_cap_mask;
epp->ep_adv_cap_mask = els.els_adv_cap_mask;
 
@@ -168,7 +147,7 @@ hunt_board_cfg(
else if ((rc == ENOTSUP) || (rc == ENOENT))
encp->enc_bug35388_workaround = B_FALSE;
else
-   goto fail5;
+   goto fail4;
 
/*

[dpdk-dev] [PATCH 49/80] net/sfc/base: move PF/VF config to ef10 NIC board config

2018-02-19 Thread Andrew Rybchenko
From: Andy Moreton 

Signed-off-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/ef10_nic.c | 18 -
 drivers/net/sfc/base/hunt_nic.c | 40 +++--
 drivers/net/sfc/base/medford2_nic.c | 38 ++-
 drivers/net/sfc/base/medford_nic.c  | 38 ++-
 4 files changed, 51 insertions(+), 83 deletions(-)

diff --git a/drivers/net/sfc/base/ef10_nic.c b/drivers/net/sfc/base/ef10_nic.c
index c63aad8..c9ba41d 100644
--- a/drivers/net/sfc/base/ef10_nic.c
+++ b/drivers/net/sfc/base/ef10_nic.c
@@ -1549,6 +1549,8 @@ ef10_nic_board_cfg(
efx_mcdi_iface_t *emip = &(enp->en_mcdi.em_emip);
efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
uint32_t port;
+   uint32_t pf;
+   uint32_t vf;
efx_rc_t rc;
 
/* Get the (zero-based) MCDI port number */
@@ -1562,13 +1564,27 @@ ef10_nic_board_cfg(
&encp->enc_external_port)) != 0)
goto fail2;
 
+   /*
+* Get PCIe function number from firmware (used for
+* per-function privilege and dynamic config info).
+*  - PCIe PF: pf = PF number, vf = 0x.
+*  - PCIe VF: pf = parent PF, vf = VF number.
+*/
+   if ((rc = efx_mcdi_get_function_info(enp, &pf, &vf)) != 0)
+   goto fail3;
+
+   encp->enc_pf = pf;
+   encp->enc_vf = vf;
+
/* Get remaining controller-specific board config */
if ((rc = enop->eno_board_cfg(enp)) != 0)
if (rc != EACCES)
-   goto fail3;
+   goto fail4;
 
return (0);
 
+fail4:
+   EFSYS_PROBE(fail4);
 fail3:
EFSYS_PROBE(fail3);
 fail2:
diff --git a/drivers/net/sfc/base/hunt_nic.c b/drivers/net/sfc/base/hunt_nic.c
index 0b311b6..84fd198 100644
--- a/drivers/net/sfc/base/hunt_nic.c
+++ b/drivers/net/sfc/base/hunt_nic.c
@@ -81,8 +81,6 @@ hunt_board_cfg(
uint32_t board_type = 0;
ef10_link_state_t els;
efx_port_t *epp = &(enp->en_port);
-   uint32_t pf;
-   uint32_t vf;
uint32_t mask;
uint32_t flags;
uint32_t sysclk, dpcpu_clk;
@@ -100,18 +98,6 @@ hunt_board_cfg(
EFX_STATIC_ASSERT(1U << EFX_VI_WINDOW_SHIFT_8K  == 8192);
encp->enc_vi_window_shift = EFX_VI_WINDOW_SHIFT_8K;
 
-   /*
-* Get PCIe function number from firmware (used for
-* per-function privilege and dynamic config info).
-*  - PCIe PF: pf = PF number, vf = 0x.
-*  - PCIe VF: pf = parent PF, vf = VF number.
-*/
-   if ((rc = efx_mcdi_get_function_info(enp, &pf, &vf)) != 0)
-   goto fail1;
-
-   encp->enc_pf = pf;
-   encp->enc_vf = vf;
-
/* MAC address for this function */
if (EFX_PCI_FUNCTION_IS_PF(encp)) {
rc = efx_mcdi_get_mac_address_pf(enp, mac_addr);
@@ -128,7 +114,7 @@ hunt_board_cfg(
rc = efx_mcdi_get_mac_address_vf(enp, mac_addr);
}
if (rc != 0)
-   goto fail2;
+   goto fail1;
 
EFX_MAC_ADDR_COPY(encp->enc_mac_addr, mac_addr);
 
@@ -139,7 +125,7 @@ hunt_board_cfg(
if (rc == EACCES)
board_type = 0;
else
-   goto fail3;
+   goto fail2;
}
 
encp->enc_board_type = board_type;
@@ -147,11 +133,11 @@ hunt_board_cfg(
 
/* Fill out fields in enp->en_port and enp->en_nic_cfg from MCDI */
if ((rc = efx_mcdi_get_phy_cfg(enp)) != 0)
-   goto fail4;
+   goto fail3;
 
/* Obtain the default PHY advertised capabilities */
if ((rc = ef10_phy_get_link(enp, &els)) != 0)
-   goto fail5;
+   goto fail4;
epp->ep_default_adv_cap_mask = els.els_adv_cap_mask;
epp->ep_adv_cap_mask = els.els_adv_cap_mask;
 
@@ -182,7 +168,7 @@ hunt_board_cfg(
else if ((rc == ENOTSUP) || (rc == ENOENT))
encp->enc_bug35388_workaround = B_FALSE;
else
-   goto fail6;
+   goto fail5;
 
/*
 * If the bug41750 workaround is enabled, then do not test interrupts,
@@ -201,7 +187,7 @@ hunt_board_cfg(
} else if ((rc == ENOTSUP) || (rc == ENOENT)) {
encp->enc_bug41750_workaround = B_FALSE;
} else {
-   goto fail7;
+   goto fail6;
}
if (EFX_PCI_FUNCTION_IS_VF(encp)) {
/* Interrupt testing does not work for VFs. See bug50084. */
@@ -239,12 +225,12 @@ hunt_board_cfg(
} else if ((rc == ENOTSUP) || (rc == ENOENT)) {
encp->enc_bug26807_workaround = B_FALSE;
} else {
-   goto fail8;
+   goto fail7;
}
 
/* Get clock frequencies (in MHz). */
if ((rc = efx_mcdi_get_clock(enp, &sysclk, &dpcpu_clk)) != 0)
-   goto fail9;
+   

[dpdk-dev] [PATCH 54/80] net/sfc/base: move Rx config to ef10 NIC board config

2018-02-19 Thread Andrew Rybchenko
From: Andy Moreton 

Signed-off-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/ef10_nic.c | 11 +++
 drivers/net/sfc/base/hunt_nic.c | 10 --
 drivers/net/sfc/base/medford2_nic.c | 10 --
 drivers/net/sfc/base/medford_nic.c  | 10 --
 4 files changed, 11 insertions(+), 30 deletions(-)

diff --git a/drivers/net/sfc/base/ef10_nic.c b/drivers/net/sfc/base/ef10_nic.c
index e7fa7b8..7223b21 100644
--- a/drivers/net/sfc/base/ef10_nic.c
+++ b/drivers/net/sfc/base/ef10_nic.c
@@ -1635,6 +1635,17 @@ ef10_nic_board_cfg(
if ((rc = ef10_get_datapath_caps(enp)) != 0)
goto fail8;
 
+   /* Alignment for WPTR updates */
+   encp->enc_rx_push_align = EF10_RX_WPTR_ALIGN;
+
+   /*
+* Maximum number of exclusive RSS contexts. EF10 hardware supports 64
+* in total, but 6 are reserved for shared contexts. They are a global
+* resource so not all may be available.
+*/
+   encp->enc_rx_scale_max_exclusive_contexts = 64 - 6;
+
+
/* Get remaining controller-specific board config */
if ((rc = enop->eno_board_cfg(enp)) != 0)
if (rc != EACCES)
diff --git a/drivers/net/sfc/base/hunt_nic.c b/drivers/net/sfc/base/hunt_nic.c
index 95b48a7..ef660f7 100644
--- a/drivers/net/sfc/base/hunt_nic.c
+++ b/drivers/net/sfc/base/hunt_nic.c
@@ -205,16 +205,6 @@ hunt_board_cfg(
encp->enc_rx_buf_align_start = 1;
encp->enc_rx_buf_align_end = 64; /* RX DMA end padding */
 
-   /* Alignment for WPTR updates */
-   encp->enc_rx_push_align = EF10_RX_WPTR_ALIGN;
-
-   /*
-* Maximum number of exclusive RSS contexts which can be allocated. The
-* hardware supports 64, but 6 are reserved for shared contexts. They
-* are a global resource so not all may be available.
-*/
-   encp->enc_rx_scale_max_exclusive_contexts = 58;
-
encp->enc_tx_dma_desc_size_max = EFX_MASK32(ESF_DZ_RX_KER_BYTE_CNT);
/* No boundary crossing limits */
encp->enc_tx_dma_desc_boundary = 0;
diff --git a/drivers/net/sfc/base/medford2_nic.c 
b/drivers/net/sfc/base/medford2_nic.c
index f383b31..ee9cf68 100644
--- a/drivers/net/sfc/base/medford2_nic.c
+++ b/drivers/net/sfc/base/medford2_nic.c
@@ -137,16 +137,6 @@ medford2_board_cfg(
}
encp->enc_rx_buf_align_end = end_padding;
 
-   /* Alignment for WPTR updates */
-   encp->enc_rx_push_align = EF10_RX_WPTR_ALIGN;
-
-   /*
-* Maximum number of exclusive RSS contexts which can be allocated. The
-* hardware supports 64, but 6 are reserved for shared contexts. They
-* are a global resource so not all may be available.
-*/
-   encp->enc_rx_scale_max_exclusive_contexts = 58;
-
encp->enc_tx_dma_desc_size_max = EFX_MASK32(ESF_DZ_RX_KER_BYTE_CNT);
/* No boundary crossing limits */
encp->enc_tx_dma_desc_boundary = 0;
diff --git a/drivers/net/sfc/base/medford_nic.c 
b/drivers/net/sfc/base/medford_nic.c
index 5e9d391..add0af0 100644
--- a/drivers/net/sfc/base/medford_nic.c
+++ b/drivers/net/sfc/base/medford_nic.c
@@ -136,16 +136,6 @@ medford_board_cfg(
}
encp->enc_rx_buf_align_end = end_padding;
 
-   /* Alignment for WPTR updates */
-   encp->enc_rx_push_align = EF10_RX_WPTR_ALIGN;
-
-   /*
-* Maximum number of exclusive RSS contexts which can be allocated. The
-* hardware supports 64, but 6 are reserved for shared contexts. They
-* are a global resource so not all may be available.
-*/
-   encp->enc_rx_scale_max_exclusive_contexts = 58;
-
encp->enc_tx_dma_desc_size_max = EFX_MASK32(ESF_DZ_RX_KER_BYTE_CNT);
/* No boundary crossing limits */
encp->enc_tx_dma_desc_boundary = 0;
-- 
2.7.4



[dpdk-dev] [PATCH 59/80] net/sfc/base: move VI window size config to ef10 NIC board

2018-02-19 Thread Andrew Rybchenko
From: Andy Moreton 

Signed-off-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/ef10_impl.h|  5 --
 drivers/net/sfc/base/ef10_nic.c | 96 -
 drivers/net/sfc/base/hunt_nic.c | 10 
 drivers/net/sfc/base/medford2_nic.c | 19 ++--
 drivers/net/sfc/base/medford_nic.c  | 10 
 5 files changed, 35 insertions(+), 105 deletions(-)

diff --git a/drivers/net/sfc/base/ef10_impl.h b/drivers/net/sfc/base/ef10_impl.h
index e1708ab..20155f8 100644
--- a/drivers/net/sfc/base/ef10_impl.h
+++ b/drivers/net/sfc/base/ef10_impl.h
@@ -1161,11 +1161,6 @@ efx_mcdi_get_vector_cfg(
__out_opt   uint32_t *pf_nvecp,
__out_opt   uint32_t *vf_nvecp);
 
-extern __checkReturn   efx_rc_t
-ef10_get_vi_window_shift(
-   __inefx_nic_t *enp,
-   __out   uint32_t *vi_window_shiftp);
-
 extern __checkReturn   efx_rc_t
 ef10_get_privilege_mask(
__inefx_nic_t *enp,
diff --git a/drivers/net/sfc/base/ef10_nic.c b/drivers/net/sfc/base/ef10_nic.c
index 02f1c19..cd871c4 100644
--- a/drivers/net/sfc/base/ef10_nic.c
+++ b/drivers/net/sfc/base/ef10_nic.c
@@ -1175,6 +1175,37 @@ ef10_get_datapath_caps(
encp->enc_tunnel_config_udp_entries_max = 0;
}
 
+   /*
+* Check if firmware reports the VI window mode.
+* Medford2 has a variable VI window size (8K, 16K or 64K).
+* Medford and Huntington have a fixed 8K VI window size.
+*/
+   if (req.emr_out_length_used >= MC_CMD_GET_CAPABILITIES_V3_OUT_LEN) {
+   uint8_t mode =
+   MCDI_OUT_BYTE(req, GET_CAPABILITIES_V3_OUT_VI_WINDOW_MODE);
+
+   switch (mode) {
+   case MC_CMD_GET_CAPABILITIES_V3_OUT_VI_WINDOW_MODE_8K:
+   encp->enc_vi_window_shift = EFX_VI_WINDOW_SHIFT_8K;
+   break;
+   case MC_CMD_GET_CAPABILITIES_V3_OUT_VI_WINDOW_MODE_16K:
+   encp->enc_vi_window_shift = EFX_VI_WINDOW_SHIFT_16K;
+   break;
+   case MC_CMD_GET_CAPABILITIES_V3_OUT_VI_WINDOW_MODE_64K:
+   encp->enc_vi_window_shift = EFX_VI_WINDOW_SHIFT_64K;
+   break;
+   default:
+   encp->enc_vi_window_shift = EFX_VI_WINDOW_SHIFT_INVALID;
+   break;
+   }
+   } else if ((enp->en_family == EFX_FAMILY_HUNTINGTON) ||
+   (enp->en_family == EFX_FAMILY_MEDFORD)) {
+   /* Huntington and Medford have fixed 8K window size */
+   encp->enc_vi_window_shift = EFX_VI_WINDOW_SHIFT_8K;
+   } else {
+   encp->enc_vi_window_shift = EFX_VI_WINDOW_SHIFT_INVALID;
+   }
+
/* Check if firmware supports extended MAC stats. */
if (req.emr_out_length_used >= MC_CMD_GET_CAPABILITIES_V4_OUT_LEN) {
/* Extended stats buffer supported */
@@ -1207,71 +1238,6 @@ ef10_get_datapath_caps(
return (rc);
 }
 
-   __checkReturn   efx_rc_t
-ef10_get_vi_window_shift(
-   __inefx_nic_t *enp,
-   __out   uint32_t *vi_window_shiftp)
-{
-   efx_mcdi_req_t req;
-   uint8_t payload[MAX(MC_CMD_GET_CAPABILITIES_IN_LEN,
-   MC_CMD_GET_CAPABILITIES_V3_OUT_LEN)];
-   uint32_t mode;
-   efx_rc_t rc;
-
-   (void) memset(payload, 0, sizeof (payload));
-   req.emr_cmd = MC_CMD_GET_CAPABILITIES;
-   req.emr_in_buf = payload;
-   req.emr_in_length = MC_CMD_GET_CAPABILITIES_IN_LEN;
-   req.emr_out_buf = payload;
-   req.emr_out_length = MC_CMD_GET_CAPABILITIES_V3_OUT_LEN;
-
-   efx_mcdi_execute_quiet(enp, &req);
-
-   if (req.emr_rc != 0) {
-   rc = req.emr_rc;
-   goto fail1;
-   }
-
-   if (req.emr_out_length_used < MC_CMD_GET_CAPABILITIES_V3_OUT_LEN) {
-   rc = EMSGSIZE;
-   goto fail2;
-   }
-   mode = MCDI_OUT_BYTE(req, GET_CAPABILITIES_V3_OUT_VI_WINDOW_MODE);
-
-   switch (mode) {
-   case MC_CMD_GET_CAPABILITIES_V3_OUT_VI_WINDOW_MODE_8K:
-   EFX_STATIC_ASSERT(1U << EFX_VI_WINDOW_SHIFT_8K == 8 * 1024);
-   *vi_window_shiftp = EFX_VI_WINDOW_SHIFT_8K;
-   break;
-
-   case MC_CMD_GET_CAPABILITIES_V3_OUT_VI_WINDOW_MODE_16K:
-   EFX_STATIC_ASSERT(1U << EFX_VI_WINDOW_SHIFT_16K == 16 * 1024);
-   *vi_window_shiftp = EFX_VI_WINDOW_SHIFT_16K;
-   break;
-
-   case MC_CMD_GET_CAPABILITIES_V3_OUT_VI_WINDOW_MODE_64K:
-   EFX_STATIC_ASSERT(1U << EFX_VI_WINDOW_SHIFT_64K == 64 * 1024);
-   *vi_window_shiftp = EFX_VI_WINDOW_SHIFT_64K;
-   break;
-
-   default:
-   *vi_window_shiftp = EFX_VI_WINDOW_SHIFT_INVALID;
-   rc = EINVAL;
-   goto fail3;
-   }
-
-   return (0);
-
-fail3:
-   EFSYS_

[dpdk-dev] [PATCH 68/80] net/sfc/base: provide a flag for controlling CTPIO mode

2018-02-19 Thread Andrew Rybchenko
From: Guido Barzini 

Either cut-through or store-and-forward mode.

Signed-off-by: Guido Barzini 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/efx_regs_mcdi.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/sfc/base/efx_regs_mcdi.h 
b/drivers/net/sfc/base/efx_regs_mcdi.h
index 984c5c9..2cc750e 100644
--- a/drivers/net/sfc/base/efx_regs_mcdi.h
+++ b/drivers/net/sfc/base/efx_regs_mcdi.h
@@ -7283,6 +7283,8 @@
 #defineMC_CMD_INIT_TXQ_EXT_IN_FLAG_TSOV2_EN_WIDTH 1
 #defineMC_CMD_INIT_TXQ_EXT_IN_FLAG_CTPIO_LBN 13
 #defineMC_CMD_INIT_TXQ_EXT_IN_FLAG_CTPIO_WIDTH 1
+#defineMC_CMD_INIT_TXQ_EXT_IN_FLAG_CTPIO_UTHRESH_LBN 14
+#defineMC_CMD_INIT_TXQ_EXT_IN_FLAG_CTPIO_UTHRESH_WIDTH 1
 /* Owner ID to use if in buffer mode (zero if physical) */
 #defineMC_CMD_INIT_TXQ_EXT_IN_OWNER_ID_OFST 20
 #defineMC_CMD_INIT_TXQ_EXT_IN_OWNER_ID_LEN 4
-- 
2.7.4



[dpdk-dev] [PATCH 55/80] net/sfc/base: move Tx config to ef10 NIC board config

2018-02-19 Thread Andrew Rybchenko
From: Andy Moreton 

Signed-off-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/ef10_nic.c | 10 ++
 drivers/net/sfc/base/hunt_nic.c | 10 --
 drivers/net/sfc/base/medford2_nic.c | 10 --
 drivers/net/sfc/base/medford_nic.c  | 10 --
 4 files changed, 10 insertions(+), 30 deletions(-)

diff --git a/drivers/net/sfc/base/ef10_nic.c b/drivers/net/sfc/base/ef10_nic.c
index 7223b21..e5dd375 100644
--- a/drivers/net/sfc/base/ef10_nic.c
+++ b/drivers/net/sfc/base/ef10_nic.c
@@ -1645,6 +1645,16 @@ ef10_nic_board_cfg(
 */
encp->enc_rx_scale_max_exclusive_contexts = 64 - 6;
 
+   encp->enc_tx_dma_desc_size_max = EFX_MASK32(ESF_DZ_RX_KER_BYTE_CNT);
+   /* No boundary crossing limits */
+   encp->enc_tx_dma_desc_boundary = 0;
+
+   /*
+* Maximum number of bytes into the frame the TCP header can start for
+* firmware assisted TSO to work.
+*/
+   encp->enc_tx_tso_tcp_header_offset_limit = EF10_TCP_HEADER_OFFSET_LIMIT;
+
 
/* Get remaining controller-specific board config */
if ((rc = enop->eno_board_cfg(enp)) != 0)
diff --git a/drivers/net/sfc/base/hunt_nic.c b/drivers/net/sfc/base/hunt_nic.c
index ef660f7..d767068 100644
--- a/drivers/net/sfc/base/hunt_nic.c
+++ b/drivers/net/sfc/base/hunt_nic.c
@@ -205,10 +205,6 @@ hunt_board_cfg(
encp->enc_rx_buf_align_start = 1;
encp->enc_rx_buf_align_end = 64; /* RX DMA end padding */
 
-   encp->enc_tx_dma_desc_size_max = EFX_MASK32(ESF_DZ_RX_KER_BYTE_CNT);
-   /* No boundary crossing limits */
-   encp->enc_tx_dma_desc_boundary = 0;
-
/*
 * Set resource limits for MC_CMD_ALLOC_VIS. Note that we cannot use
 * MC_CMD_GET_RESOURCE_LIMITS here as that reports the available
@@ -254,12 +250,6 @@ hunt_board_cfg(
encp->enc_intr_vec_base = base;
encp->enc_intr_limit = nvec;
 
-   /*
-* Maximum number of bytes into the frame the TCP header can start for
-* firmware assisted TSO to work.
-*/
-   encp->enc_tx_tso_tcp_header_offset_limit = EF10_TCP_HEADER_OFFSET_LIMIT;
-
if ((rc = hunt_nic_get_required_pcie_bandwidth(enp, &bandwidth)) != 0)
goto fail7;
encp->enc_required_pcie_bandwidth_mbps = bandwidth;
diff --git a/drivers/net/sfc/base/medford2_nic.c 
b/drivers/net/sfc/base/medford2_nic.c
index ee9cf68..1b5690b 100644
--- a/drivers/net/sfc/base/medford2_nic.c
+++ b/drivers/net/sfc/base/medford2_nic.c
@@ -137,10 +137,6 @@ medford2_board_cfg(
}
encp->enc_rx_buf_align_end = end_padding;
 
-   encp->enc_tx_dma_desc_size_max = EFX_MASK32(ESF_DZ_RX_KER_BYTE_CNT);
-   /* No boundary crossing limits */
-   encp->enc_tx_dma_desc_boundary = 0;
-
/*
 * Set resource limits for MC_CMD_ALLOC_VIS. Note that we cannot use
 * MC_CMD_GET_RESOURCE_LIMITS here as that reports the available
@@ -188,12 +184,6 @@ medford2_board_cfg(
encp->enc_intr_limit = nvec;
 
/*
-* Maximum number of bytes into the frame the TCP header can start for
-* firmware assisted TSO to work.
-*/
-   encp->enc_tx_tso_tcp_header_offset_limit = EF10_TCP_HEADER_OFFSET_LIMIT;
-
-   /*
 * Medford2 stores a single global copy of VPD, not per-PF as on
 * Huntington.
 */
diff --git a/drivers/net/sfc/base/medford_nic.c 
b/drivers/net/sfc/base/medford_nic.c
index add0af0..8a96cc6 100644
--- a/drivers/net/sfc/base/medford_nic.c
+++ b/drivers/net/sfc/base/medford_nic.c
@@ -136,10 +136,6 @@ medford_board_cfg(
}
encp->enc_rx_buf_align_end = end_padding;
 
-   encp->enc_tx_dma_desc_size_max = EFX_MASK32(ESF_DZ_RX_KER_BYTE_CNT);
-   /* No boundary crossing limits */
-   encp->enc_tx_dma_desc_boundary = 0;
-
/*
 * Set resource limits for MC_CMD_ALLOC_VIS. Note that we cannot use
 * MC_CMD_GET_RESOURCE_LIMITS here as that reports the available
@@ -187,12 +183,6 @@ medford_board_cfg(
encp->enc_intr_limit = nvec;
 
/*
-* Maximum number of bytes into the frame the TCP header can start for
-* firmware assisted TSO to work.
-*/
-   encp->enc_tx_tso_tcp_header_offset_limit = EF10_TCP_HEADER_OFFSET_LIMIT;
-
-   /*
 * Medford stores a single global copy of VPD, not per-PF as on
 * Huntington.
 */
-- 
2.7.4



[dpdk-dev] [PATCH 61/80] net/sfc/base: support FEC mode settings

2018-02-19 Thread Andrew Rybchenko
From: Andy Moreton 

Medford2 controllers support control and reporting of
FEC modes for 25G and higher links. See SF-109306-TC
for suggested usage in client code.

Signed-off-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/ef10_phy.c | 41 +
 drivers/net/sfc/base/efx.h  |  6 ++
 2 files changed, 47 insertions(+)

diff --git a/drivers/net/sfc/base/ef10_phy.c b/drivers/net/sfc/base/ef10_phy.c
index 035099f..84acb70 100644
--- a/drivers/net/sfc/base/ef10_phy.c
+++ b/drivers/net/sfc/base/ef10_phy.c
@@ -34,6 +34,12 @@ mcdi_phy_decode_cap(
CHECK_CAP(ASYM);
CHECK_CAP(AN);
CHECK_CAP(DDM);
+   CHECK_CAP(BASER_FEC);
+   CHECK_CAP(BASER_FEC_REQUESTED);
+   CHECK_CAP(RS_FEC);
+   CHECK_CAP(RS_FEC_REQUESTED);
+   CHECK_CAP(25G_BASER_FEC);
+   CHECK_CAP(25G_BASER_FEC_REQUESTED);
 #undef CHECK_CAP
 
mask = 0;
@@ -67,6 +73,22 @@ mcdi_phy_decode_cap(
if (mcdi_cap & (1 << MC_CMD_PHY_CAP_AN_LBN))
mask |= (1 << EFX_PHY_CAP_AN);
 
+   /* FEC caps (supported on Medford2 and later) */
+   if (mcdi_cap & (1 << MC_CMD_PHY_CAP_BASER_FEC_LBN))
+   mask |= (1 << EFX_PHY_CAP_BASER_FEC);
+   if (mcdi_cap & (1 << MC_CMD_PHY_CAP_BASER_FEC_REQUESTED_LBN))
+   mask |= (1 << EFX_PHY_CAP_BASER_FEC_REQUESTED);
+
+   if (mcdi_cap & (1 << MC_CMD_PHY_CAP_RS_FEC_LBN))
+   mask |= (1 << EFX_PHY_CAP_RS_FEC);
+   if (mcdi_cap & (1 << MC_CMD_PHY_CAP_RS_FEC_REQUESTED_LBN))
+   mask |= (1 << EFX_PHY_CAP_RS_FEC_REQUESTED);
+
+   if (mcdi_cap & (1 << MC_CMD_PHY_CAP_25G_BASER_FEC_LBN))
+   mask |= (1 << EFX_PHY_CAP_25G_BASER_FEC);
+   if (mcdi_cap & (1 << MC_CMD_PHY_CAP_25G_BASER_FEC_REQUESTED_LBN))
+   mask |= (1 << EFX_PHY_CAP_25G_BASER_FEC_REQUESTED);
+
*maskp = mask;
 }
 
@@ -323,6 +345,25 @@ ef10_phy_reconfigure(
MCDI_IN_SET_DWORD_FIELD(req, SET_LINK_IN_CAP,
PHY_CAP_10FDX, (cap_mask >> EFX_PHY_CAP_10FDX) & 0x1);
 
+   MCDI_IN_SET_DWORD_FIELD(req, SET_LINK_IN_CAP,
+   PHY_CAP_BASER_FEC, (cap_mask >> EFX_PHY_CAP_BASER_FEC) & 0x1);
+   MCDI_IN_SET_DWORD_FIELD(req, SET_LINK_IN_CAP,
+   PHY_CAP_BASER_FEC_REQUESTED,
+   (cap_mask >> EFX_PHY_CAP_BASER_FEC_REQUESTED) & 0x1);
+
+   MCDI_IN_SET_DWORD_FIELD(req, SET_LINK_IN_CAP,
+   PHY_CAP_RS_FEC, (cap_mask >> EFX_PHY_CAP_RS_FEC) & 0x1);
+   MCDI_IN_SET_DWORD_FIELD(req, SET_LINK_IN_CAP,
+   PHY_CAP_RS_FEC_REQUESTED,
+   (cap_mask >> EFX_PHY_CAP_RS_FEC_REQUESTED) & 0x1);
+
+   MCDI_IN_SET_DWORD_FIELD(req, SET_LINK_IN_CAP,
+   PHY_CAP_25G_BASER_FEC,
+   (cap_mask >> EFX_PHY_CAP_25G_BASER_FEC) & 0x1);
+   MCDI_IN_SET_DWORD_FIELD(req, SET_LINK_IN_CAP,
+   PHY_CAP_25G_BASER_FEC_REQUESTED,
+   (cap_mask >> EFX_PHY_CAP_25G_BASER_FEC_REQUESTED) & 0x1);
+
 #if EFSYS_OPT_LOOPBACK
MCDI_IN_SET_DWORD(req, SET_LINK_IN_LOOPBACK_MODE,
epp->ep_loopback_type);
diff --git a/drivers/net/sfc/base/efx.h b/drivers/net/sfc/base/efx.h
index 5cb3fd0..33e7875 100644
--- a/drivers/net/sfc/base/efx.h
+++ b/drivers/net/sfc/base/efx.h
@@ -876,6 +876,12 @@ typedef enum efx_phy_cap_type_e {
EFX_PHY_CAP_10FDX,
EFX_PHY_CAP_25000FDX,
EFX_PHY_CAP_5FDX,
+   EFX_PHY_CAP_BASER_FEC,
+   EFX_PHY_CAP_BASER_FEC_REQUESTED,
+   EFX_PHY_CAP_RS_FEC,
+   EFX_PHY_CAP_RS_FEC_REQUESTED,
+   EFX_PHY_CAP_25G_BASER_FEC,
+   EFX_PHY_CAP_25G_BASER_FEC_REQUESTED,
EFX_PHY_CAP_NTYPES
 } efx_phy_cap_type_t;
 
-- 
2.7.4



[dpdk-dev] [PATCH 64/80] net/sfc/base: group Medford external port mapping entries

2018-02-19 Thread Andrew Rybchenko
From: Andy Moreton 

Signed-off-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/ef10_nic.c | 30 +++---
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/net/sfc/base/ef10_nic.c b/drivers/net/sfc/base/ef10_nic.c
index 2b8b043..cb06535 100644
--- a/drivers/net/sfc/base/ef10_nic.c
+++ b/drivers/net/sfc/base/ef10_nic.c
@@ -1352,21 +1352,6 @@ static struct ef10_external_port_map_s {
1   /* first cage */
},
/*
-* Modes that on Medford allocate each port number to a separate
-* cage.
-*  port 0 -> cage 1
-*  port 1 -> cage 2
-*  port 2 -> cage 3
-*  port 3 -> cage 4
-*/
-   {
-   EFX_FAMILY_MEDFORD,
-   (1U << TLV_PORT_MODE_10G) | /* mode 0 */
-   (1U << TLV_PORT_MODE_10G_10G),  /* mode 2 */
-   1,  /* ports per cage */
-   1   /* first cage */
-   },
-   /*
 * Modes which for Huntington identify a chip variant where 2
 * adjacent port numbers map to each cage.
 * SFN7x42Q (Monza):
@@ -1385,6 +1370,21 @@ static struct ef10_external_port_map_s {
1   /* first cage */
},
/*
+* Modes that on Medford allocate each port number to a separate
+* cage.
+*  port 0 -> cage 1
+*  port 1 -> cage 2
+*  port 2 -> cage 3
+*  port 3 -> cage 4
+*/
+   {
+   EFX_FAMILY_MEDFORD,
+   (1U << TLV_PORT_MODE_10G) | /* mode 0 */
+   (1U << TLV_PORT_MODE_10G_10G),  /* mode 2 */
+   1,  /* ports per cage */
+   1   /* first cage */
+   },
+   /*
 * Modes that on Medford allocate 2 adjacent port numbers to each
 * cage.
 *  port 0 -> cage 1
-- 
2.7.4



[dpdk-dev] [PATCH 71/80] net/sfc/base: run genfwdef to update headers

2018-02-19 Thread Andrew Rybchenko
From: Andy Moreton 

Signed-off-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/ef10_tlv_layout.h | 19 +++
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/net/sfc/base/ef10_tlv_layout.h 
b/drivers/net/sfc/base/ef10_tlv_layout.h
index b649008..e94bc3e 100644
--- a/drivers/net/sfc/base/ef10_tlv_layout.h
+++ b/drivers/net/sfc/base/ef10_tlv_layout.h
@@ -32,6 +32,7 @@
  *1: dynamic configuration
  *2: firmware internal use
  *3: license partition
+ *4: tsa configuration
  *
  *   -  TTT is a type, which is just a unique value.  The same type value
  *  might appear in both locations, indicating a relationship between
@@ -565,6 +566,7 @@ struct tlv_global_port_mode {
 #define TLV_PORT_MODE_1x2_1x4(16) /* Single 50G on mdi0, 
single 40G on mdi1 */
 #define TLV_PORT_MODE_1x2_2x1(17) /* Single 50G on mdi0, 
dual 10G/25G on mdi1 */
 #define TLV_PORT_MODE_2x1_1x2(18) /* Dual 10G/25G on mdi0, 
single 50G on mdi1 */
+/* Below modes are eftest only, to allow snapper explicit selection between 
multi-channel and LLPCS. In production, this selection is automatic and outside 
world should not care about LLPCS */
 #define TLV_PORT_MODE_2x1_2x1_LL (19) /* Dual 10G/25G on mdi0, 
dual 10G/25G on mdi1, low-latency PCS */
 #define TLV_PORT_MODE_4x1_NA_LL  (20) /* Quad 10G/25G on mdi0, 
low-latency PCS */
 #define TLV_PORT_MODE_NA_4x1_LL  (21) /* Quad 10G/25G on mdi1, 
low-latency PCS */
@@ -603,6 +605,7 @@ struct tlv_global_port_mode {
 #define TLV_PORT_MODE_50G_40GTLV_PORT_MODE_1x2_1x4/* 
Single 50G on mdi0, single 40G on mdi1 */
 #define TLV_PORT_MODE_50G_25G_25GTLV_PORT_MODE_1x2_2x1/* 
Single 50G on mdi0, dual 25G on mdi1 */
 #define TLV_PORT_MODE_25G_25G_50GTLV_PORT_MODE_2x1_1x2/* 
Dual 25G on mdi0, single 50G on mdi1 */
+/* eftest only, see comments for _LL modes above */
 #define TLV_PORT_MODE_25G_25G_25G_25G_Q1_Q2_LL   TLV_PORT_MODE_2x1_2x1_LL /* 
Dual 25G on mdi0, dual 25G on mdi1, low-latency PCS */
 #define TLV_PORT_MODE_25G_25G_25G_25G_Q1_LL  TLV_PORT_MODE_4x1_NA_LL  /* 
Quad 25G on mdi0, low-latency PCS */
 #define TLV_PORT_MODE_25G_25G_25G_25G_Q2_LL  TLV_PORT_MODE_NA_4x1_LL  /* 
Quad 25G on mdi1, low-latency PCS */
@@ -852,7 +855,7 @@ typedef struct tlv_license {
   uint8_t   data[];
 } tlv_license_t;
 
-/* TSA NIC IP address configuration
+/* TSA NIC IP address configuration (DEPRECATED)
  *
  * Sets the TSA NIC IP address statically via configuration tool or dynamically
  * via DHCP via snooping based on the mode selection (0=Static, 1=DHCP, 
2=Snoop)
@@ -862,7 +865,7 @@ typedef struct tlv_license {
  * released code yet.
  */
 
-#define TLV_TAG_TMP_TSAN_CONFIG (0x1022)
+#define TLV_TAG_TMP_TSAN_CONFIG (0x1022) /* DEPRECATED */
 
 #define TLV_TSAN_IP_MODE_STATIC (0)
 #define TLV_TSAN_IP_MODE_DHCP   (1)
@@ -879,7 +882,7 @@ typedef struct tlv_tsan_config {
   uint32_t bind_bkout;  /* DEPRECATED */
 } tlv_tsan_config_t;
 
-/* TSA Controller IP address configuration
+/* TSA Controller IP address configuration (DEPRECATED)
  *
  * Sets the TSA Controller IP address statically via configuration tool
  *
@@ -888,7 +891,7 @@ typedef struct tlv_tsan_config {
  * released code yet.
  */
 
-#define TLV_TAG_TMP_TSAC_CONFIG (0x1023)
+#define TLV_TAG_TMP_TSAC_CONFIG (0x1023) /* DEPRECATED */
 
 #define TLV_MAX_TSACS (4)
 typedef struct tlv_tsac_config {
@@ -899,7 +902,7 @@ typedef struct tlv_tsac_config {
   uint32_t port[TLV_MAX_TSACS];
 } tlv_tsac_config_t;
 
-/* Binding ticket
+/* Binding ticket (DEPRECATED)
  *
  * Sets the TSA NIC binding ticket used for binding process between the TSA NIC
  * and the TSA Controller
@@ -909,7 +912,7 @@ typedef struct tlv_tsac_config {
  * released code yet.
  */
 
-#define TLV_TAG_TMP_BINDING_TICKET  (0x1024)
+#define TLV_TAG_TMP_BINDING_TICKET  (0x1024) /* DEPRECATED */
 
 typedef struct tlv_binding_ticket {
   uint32_t tag;
@@ -934,7 +937,7 @@ typedef struct tlv_pik_sf {
   uint8_t  bytes[];
 } tlv_pik_sf_t;
 
-/* CA root certificate
+/* CA root certificate (DEPRECATED)
  *
  * Sets the CA root certificate used for TSA Controller verfication during
  * TLS connection setup between the TSA NIC and the TSA Controller
@@ -944,7 +947,7 @@ typedef struct tlv_pik_sf {
  * released code yet.
  */
 
-#define TLV_TAG_TMP_CA_ROOT_CERT(0x1026)
+#define TLV_TAG_TMP_CA_ROOT_CERT(0x1026) /* DEPRECATED */
 
 typedef struct tlv_ca_root_cert {
   uint32_t tag;
-- 
2.7.4



[dpdk-dev] [PATCH 65/80] net/sfc/base: add Medford2 support for external port numbers

2018-02-19 Thread Andrew Rybchenko
From: Andy Moreton 

Signed-off-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/ef10_nic.c | 87 +
 1 file changed, 87 insertions(+)

diff --git a/drivers/net/sfc/base/ef10_nic.c b/drivers/net/sfc/base/ef10_nic.c
index cb06535..bab4412 100644
--- a/drivers/net/sfc/base/ef10_nic.c
+++ b/drivers/net/sfc/base/ef10_nic.c
@@ -1433,6 +1433,93 @@ static struct ef10_external_port_map_s {
4,  /* ports per cage */
2   /* first cage */
},
+   /*
+* Modes that on Medford2 allocate each port number to a separate
+* cage.
+*  port 0 -> cage 1
+*  port 1 -> cage 2
+*  port 2 -> cage 3
+*  port 3 -> cage 4
+*/
+   {
+   EFX_FAMILY_MEDFORD2,
+   (1U << TLV_PORT_MODE_1x1_NA) |  /* mode 0 */
+   (1U << TLV_PORT_MODE_1x4_NA) |  /* mode 1 */
+   (1U << TLV_PORT_MODE_1x1_1x1) | /* mode 2 */
+   (1U << TLV_PORT_MODE_1x2_NA) |  /* mode 10 */
+   (1U << TLV_PORT_MODE_1x2_1x2) | /* mode 12 */
+   (1U << TLV_PORT_MODE_1x4_1x2) | /* mode 15 */
+   (1U << TLV_PORT_MODE_1x2_1x4),  /* mode 16 */
+   1,  /* ports per cage */
+   1   /* first cage */
+   },
+   /*
+* FIXME: Some port modes are not representable in this mapping:
+*  - TLV_PORT_MODE_1x2_2x1 (mode 17):
+*  port 0 -> cage 1
+*  port 1 -> cage 2
+*  port 2 -> cage 2
+*/
+   /*
+* Modes that on Medford2 allocate 2 adjacent port numbers to each
+* cage, starting on cage 1.
+*  port 0 -> cage 1
+*  port 1 -> cage 1
+*  port 2 -> cage 2
+*  port 3 -> cage 2
+*/
+   {
+   EFX_FAMILY_MEDFORD2,
+   (1U << TLV_PORT_MODE_1x4_1x4) | /* mode 3 */
+   (1U << TLV_PORT_MODE_2x1_2x1) | /* mode 4 */
+   (1U << TLV_PORT_MODE_1x4_2x1) | /* mode 6 */
+   (1U << TLV_PORT_MODE_2x1_1x4) | /* mode 7 */
+   (1U << TLV_PORT_MODE_2x2_NA) |  /* mode 13 */
+   (1U << TLV_PORT_MODE_2x1_1x2),  /* mode 18 */
+   2,  /* ports per cage */
+   1   /* first cage */
+   },
+   /*
+* Modes that on Medford2 allocate 2 adjacent port numbers to each
+* cage, starting on cage 2.
+*  port 0 -> cage 2
+*  port 1 -> cage 2
+*/
+   {
+   EFX_FAMILY_MEDFORD2,
+   (1U << TLV_PORT_MODE_NA_2x2),   /* mode 14 */
+   2,  /* ports per cage */
+   2   /* first cage */
+   },
+   /*
+* Modes that on Medford2 allocate 4 adjacent port numbers to each
+* connector, starting on cage 1.
+*  port 0 -> cage 1
+*  port 1 -> cage 1
+*  port 2 -> cage 1
+*  port 3 -> cage 1
+*/
+   {
+   EFX_FAMILY_MEDFORD2,
+   (1U << TLV_PORT_MODE_4x1_NA),   /* mode 5 */
+   4,  /* ports per cage */
+   1   /* first cage */
+   },
+   /*
+* Modes that on Medford2 allocate 4 adjacent port numbers to each
+* connector, starting on cage 2.
+*  port 0 -> cage 2
+*  port 1 -> cage 2
+*  port 2 -> cage 2
+*  port 3 -> cage 2
+*/
+   {
+   EFX_FAMILY_MEDFORD2,
+   (1U << TLV_PORT_MODE_NA_4x1) |  /* mode 8 */
+   (1U << TLV_PORT_MODE_NA_1x2),   /* mode 11 */
+   4,  /* ports per cage */
+   2   /* first cage */
+   },
 };
 
 static __checkReturn   efx_rc_t
-- 
2.7.4



[dpdk-dev] [PATCH 70/80] net/sfc/base: document the event type for CTPIO sends

2018-02-19 Thread Andrew Rybchenko
From: Guido Barzini 

Document the TX_EV_TYPE used for TX completion events corresponding
to CTPIO sends.

Signed-off-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/efx_regs_mcdi.h | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/sfc/base/efx_regs_mcdi.h 
b/drivers/net/sfc/base/efx_regs_mcdi.h
index 2cc750e..37f9f25 100644
--- a/drivers/net/sfc/base/efx_regs_mcdi.h
+++ b/drivers/net/sfc/base/efx_regs_mcdi.h
@@ -6730,6 +6730,10 @@
 #defineTX_TIMESTAMP_EVENT_TX_EV_TYPE_LEN 1
 /* enum: This is a TX completion event, not a timestamp */
 #defineTX_TIMESTAMP_EVENT_TX_EV_COMPLETION  0x0
+/* enum: This is a TX completion event for a CTPIO transmit. The event format
+ * is the same as for TX_EV_COMPLETION.
+ */
+#defineTX_TIMESTAMP_EVENT_TX_EV_CTPIO_COMPLETION  0x11
 /* enum: This is the low part of a TX timestamp event */
 #defineTX_TIMESTAMP_EVENT_TX_EV_TSTAMP_LO  0x51
 /* enum: This is the high part of a TX timestamp event */
-- 
2.7.4



[dpdk-dev] [PATCH 77/80] net/sfc/base: add outer IP ID parameter to TSOv2 descriptor

2018-02-19 Thread Andrew Rybchenko
From: Vijay Srivastava 

Set outer_ip_id in the TX option descriptor for encapsulated packets.

Signed-off-by: Vijay Srivastava 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/ef10_impl.h | 1 +
 drivers/net/sfc/base/ef10_tx.c   | 4 +++-
 drivers/net/sfc/base/efx.h   | 1 +
 drivers/net/sfc/base/efx_impl.h  | 2 +-
 drivers/net/sfc/base/efx_tx.c| 4 +++-
 drivers/net/sfc/sfc_tso.c| 3 ++-
 6 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/net/sfc/base/ef10_impl.h b/drivers/net/sfc/base/ef10_impl.h
index 20155f8..7089a60 100644
--- a/drivers/net/sfc/base/ef10_impl.h
+++ b/drivers/net/sfc/base/ef10_impl.h
@@ -756,6 +756,7 @@ extern  void
 ef10_tx_qdesc_tso2_create(
__inefx_txq_t *etp,
__inuint16_t ipv4_id,
+   __inuint16_t outer_ipv4_id,
__inuint32_t tcp_seq,
__inuint16_t tcp_mss,
__out_ecount(count) efx_desc_t *edp,
diff --git a/drivers/net/sfc/base/ef10_tx.c b/drivers/net/sfc/base/ef10_tx.c
index 8ca0b55..7d27f71 100644
--- a/drivers/net/sfc/base/ef10_tx.c
+++ b/drivers/net/sfc/base/ef10_tx.c
@@ -623,6 +623,7 @@ ef10_tx_qdesc_tso_create(
 ef10_tx_qdesc_tso2_create(
__inefx_txq_t *etp,
__inuint16_t ipv4_id,
+   __inuint16_t outer_ipv4_id,
__inuint32_t tcp_seq,
__inuint16_t tcp_mss,
__out_ecount(count) efx_desc_t *edp,
@@ -636,13 +637,14 @@ ef10_tx_qdesc_tso2_create(
 
EFSYS_ASSERT(count >= EFX_TX_FATSOV2_OPT_NDESCS);
 
-   EFX_POPULATE_QWORD_5(edp[0].ed_eq,
+   EFX_POPULATE_QWORD_6(edp[0].ed_eq,
ESF_DZ_TX_DESC_IS_OPT, 1,
ESF_DZ_TX_OPTION_TYPE,
ESE_DZ_TX_OPTION_DESC_TSO,
ESF_DZ_TX_TSO_OPTION_TYPE,
ESE_DZ_TX_TSO_OPTION_DESC_FATSO2A,
ESF_DZ_TX_TSO_IP_ID, ipv4_id,
+   ESF_DZ_TX_TSO_OUTER_IPID, outer_ipv4_id,
ESF_DZ_TX_TSO_TCP_SEQNO, tcp_seq);
EFX_POPULATE_QWORD_4(edp[1].ed_eq,
ESF_DZ_TX_DESC_IS_OPT, 1,
diff --git a/drivers/net/sfc/base/efx.h b/drivers/net/sfc/base/efx.h
index 4af1591..0d84108 100644
--- a/drivers/net/sfc/base/efx.h
+++ b/drivers/net/sfc/base/efx.h
@@ -2295,6 +2295,7 @@ externvoid
 efx_tx_qdesc_tso2_create(
__inefx_txq_t *etp,
__inuint16_t ipv4_id,
+   __inuint16_t outer_ipv4_id,
__inuint32_t tcp_seq,
__inuint16_t tcp_mss,
__out_ecount(count) efx_desc_t *edp,
diff --git a/drivers/net/sfc/base/efx_impl.h b/drivers/net/sfc/base/efx_impl.h
index ca22e0b..a1bd03d 100644
--- a/drivers/net/sfc/base/efx_impl.h
+++ b/drivers/net/sfc/base/efx_impl.h
@@ -117,7 +117,7 @@ typedef struct efx_tx_ops_s {
uint32_t, uint8_t,
efx_desc_t *);
void(*etxo_qdesc_tso2_create)(efx_txq_t *, uint16_t,
-   uint32_t, uint16_t,
+   uint16_t, uint32_t, uint16_t,
efx_desc_t *, int);
void(*etxo_qdesc_vlantci_create)(efx_txq_t *, uint16_t,
efx_desc_t *);
diff --git a/drivers/net/sfc/base/efx_tx.c b/drivers/net/sfc/base/efx_tx.c
index f8b9801..da37580 100644
--- a/drivers/net/sfc/base/efx_tx.c
+++ b/drivers/net/sfc/base/efx_tx.c
@@ -625,6 +625,7 @@ efx_tx_qdesc_tso_create(
 efx_tx_qdesc_tso2_create(
__inefx_txq_t *etp,
__inuint16_t ipv4_id,
+   __inuint16_t outer_ipv4_id,
__inuint32_t tcp_seq,
__inuint16_t mss,
__out_ecount(count) efx_desc_t *edp,
@@ -636,7 +637,8 @@ efx_tx_qdesc_tso2_create(
EFSYS_ASSERT3U(etp->et_magic, ==, EFX_TXQ_MAGIC);
EFSYS_ASSERT(etxop->etxo_qdesc_tso2_create != NULL);
 
-   etxop->etxo_qdesc_tso2_create(etp, ipv4_id, tcp_seq, mss, edp, count);
+   etxop->etxo_qdesc_tso2_create(etp, ipv4_id, outer_ipv4_id,
+   tcp_seq, mss, edp, count);
 }
 
void
diff --git a/drivers/net/sfc/sfc_tso.c b/drivers/net/sfc/sfc_tso.c
index ba8496d..effe985 100644
--- a/drivers/net/sfc/sfc_tso.c
+++ b/drivers/net/sfc/sfc_tso.c
@@ -164,7 +164,8 @@ sfc_efx_tso_do(struct sfc_efx_txq *txq, unsigned int idx,
rte_memcpy(&sent_seq, &th->sent_seq, sizeof(uint32_t));
sent_seq = rte_be_to_cpu_32(sent_seq);
 
-   efx_tx_qdesc_tso2_create(txq->common, packet_id, sent_

[dpdk-dev] [PATCH 63/80] net/sfc/base: clarify port mode names and masks

2018-02-19 Thread Andrew Rybchenko
From: Andy Moreton 

New port mode names are defined for Medford2 and later, and
the existing names are aliased to them. Add comments with the
numeric port mode to clarify the external port modes table.

Signed-off-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/ef10_nic.c | 60 +
 drivers/net/sfc/base/hunt_nic.c |  6 ++---
 2 files changed, 34 insertions(+), 32 deletions(-)

diff --git a/drivers/net/sfc/base/ef10_nic.c b/drivers/net/sfc/base/ef10_nic.c
index cd871c4..2b8b043 100644
--- a/drivers/net/sfc/base/ef10_nic.c
+++ b/drivers/net/sfc/base/ef10_nic.c
@@ -1345,11 +1345,11 @@ static struct ef10_external_port_map_s {
 */
{
EFX_FAMILY_HUNTINGTON,
-   (1 << TLV_PORT_MODE_10G) |
-   (1 << TLV_PORT_MODE_10G_10G) |
-   (1 << TLV_PORT_MODE_10G_10G_10G_10G),
-   1,
-   1
+   (1U << TLV_PORT_MODE_10G) | /* mode 0 */
+   (1U << TLV_PORT_MODE_10G_10G) | /* mode 2 */
+   (1U << TLV_PORT_MODE_10G_10G_10G_10G),  /* mode 4 */
+   1,  /* ports per cage */
+   1   /* first cage */
},
/*
 * Modes that on Medford allocate each port number to a separate
@@ -1361,10 +1361,10 @@ static struct ef10_external_port_map_s {
 */
{
EFX_FAMILY_MEDFORD,
-   (1 << TLV_PORT_MODE_10G) |
-   (1 << TLV_PORT_MODE_10G_10G),
-   1,
-   1
+   (1U << TLV_PORT_MODE_10G) | /* mode 0 */
+   (1U << TLV_PORT_MODE_10G_10G),  /* mode 2 */
+   1,  /* ports per cage */
+   1   /* first cage */
},
/*
 * Modes which for Huntington identify a chip variant where 2
@@ -1377,12 +1377,12 @@ static struct ef10_external_port_map_s {
 */
{
EFX_FAMILY_HUNTINGTON,
-   (1 << TLV_PORT_MODE_40G) |
-   (1 << TLV_PORT_MODE_40G_40G) |
-   (1 << TLV_PORT_MODE_40G_10G_10G) |
-   (1 << TLV_PORT_MODE_10G_10G_40G),
-   2,
-   1
+   (1U << TLV_PORT_MODE_40G) | /* mode 1 */
+   (1U << TLV_PORT_MODE_40G_40G) | /* mode 3 */
+   (1U << TLV_PORT_MODE_40G_10G_10G) | /* mode 6 */
+   (1U << TLV_PORT_MODE_10G_10G_40G),  /* mode 7 */
+   2,  /* ports per cage */
+   1   /* first cage */
},
/*
 * Modes that on Medford allocate 2 adjacent port numbers to each
@@ -1394,13 +1394,14 @@ static struct ef10_external_port_map_s {
 */
{
EFX_FAMILY_MEDFORD,
-   (1 << TLV_PORT_MODE_40G) |
-   (1 << TLV_PORT_MODE_40G_40G) |
-   (1 << TLV_PORT_MODE_40G_10G_10G) |
-   (1 << TLV_PORT_MODE_10G_10G_40G) |
-   (1 << TLV_PORT_MODE_10G_10G_10G_10G_Q1_Q2),
-   2,
-   1
+   (1U << TLV_PORT_MODE_40G) | /* mode 1 */
+   (1U << TLV_PORT_MODE_40G_40G) | /* mode 3 */
+   (1U << TLV_PORT_MODE_40G_10G_10G) | /* mode 6 */
+   (1U << TLV_PORT_MODE_10G_10G_40G) | /* mode 7 */
+   /* Do not use 10G_10G_10G_10G_Q1_Q2 (see bug63270) */
+   (1U << TLV_PORT_MODE_10G_10G_10G_10G_Q1_Q2),/* mode 9 */
+   2,  /* ports per cage */
+   1   /* first cage */
},
/*
 * Modes that on Medford allocate 4 adjacent port numbers to each
@@ -1412,10 +1413,11 @@ static struct ef10_external_port_map_s {
 */
{
EFX_FAMILY_MEDFORD,
-   (1 << TLV_PORT_MODE_10G_10G_10G_10G_Q) |
-   (1 << TLV_PORT_MODE_10G_10G_10G_10G_Q1),
-   4,
-   1,
+   (1U << TLV_PORT_MODE_10G_10G_10G_10G_Q) |   /* mode 5 */
+   /* Do not use 10G_10G_10G_10G_Q1 (see bug63270) */
+   (1U << TLV_PORT_MODE_10G_10G_10G_10G_Q1),   /* mode 4 */
+   4,  /* ports per cage */
+   1   /* first cage */
},
/*
 * Modes that on Medford allocate 4 adjacent port numbers to each
@@ -1427,9 +1429,9 @@ static struct ef10_external_port_map_s {
 */
{
EFX_FAMILY_MEDFORD,
-   (1 << TLV_PORT_MODE_10G_10G_10G_10G_Q2),
-   4,
-   2
+   (1U << TLV_PORT_MODE_10G_10G_10G_10G_Q2),   /* mode 8 */
+   4,  /* ports per cage */
+   2   /* first cage */
},
 };
 
diff --git a/drivers/net/sfc/base/hunt_nic.c b/drivers/net/sfc/base/hunt_nic.c
index e39f817..16ea81d

[dpdk-dev] [PATCH 80/80] net/sfc/base: sync MCDI headers and TLV layout

2018-02-19 Thread Andrew Rybchenko
Regenerate MCDI and TLV layout headers from firmwaresrc to
pick up DPDK firmware variant and related Rx queue and filtering
extensions.

Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/ef10_tlv_layout.h |  67 ++--
 drivers/net/sfc/base/efx_regs_mcdi.h   | 699 -
 2 files changed, 709 insertions(+), 57 deletions(-)

diff --git a/drivers/net/sfc/base/ef10_tlv_layout.h 
b/drivers/net/sfc/base/ef10_tlv_layout.h
index e94bc3e..b19dc2a 100644
--- a/drivers/net/sfc/base/ef10_tlv_layout.h
+++ b/drivers/net/sfc/base/ef10_tlv_layout.h
@@ -408,6 +408,7 @@ struct tlv_firmware_options {
 #define TLV_FIRMWARE_VARIANT_PACKED_STREAM_HASH_MODE_1 \
  
MC_CMD_FW_PACKED_STREAM_HASH_MODE_1
 #define TLV_FIRMWARE_VARIANT_RULES_ENGINEMC_CMD_FW_RULES_ENGINE
+#define TLV_FIRMWARE_VARIANT_DPDKMC_CMD_FW_DPDK
 };
 
 /* Voltage settings
@@ -547,6 +548,17 @@ struct tlv_global_port_mode {
   uint32_t length;
   uint32_t port_mode;
 #define TLV_PORT_MODE_DEFAULT   (0x) /* Default for given 
platform */
+
+/* Huntington port modes */
+#define TLV_PORT_MODE_10G(0)
+#define TLV_PORT_MODE_40G(1)
+#define TLV_PORT_MODE_10G_10G(2)
+#define TLV_PORT_MODE_40G_40G(3)
+#define TLV_PORT_MODE_10G_10G_10G_10G(4)
+#define TLV_PORT_MODE_40G_10G_10G(6)
+#define TLV_PORT_MODE_10G_10G_40G(7)
+
+/* Medford (and later) port modes */
 #define TLV_PORT_MODE_1x1_NA (0) /* Single 10G/25G on mdi0 
*/
 #define TLV_PORT_MODE_1x4_NA (1) /* Single 100G/40G on 
mdi0 */
 #define TLV_PORT_MODE_NA_1x4 (22) /* Single 100G/40G on 
mdi1 */
@@ -554,8 +566,8 @@ struct tlv_global_port_mode {
 #define TLV_PORT_MODE_NA_1x2 (11) /* Single 50G on mdi1 */
 #define TLV_PORT_MODE_1x1_1x1(2) /* Single 10G/25G on 
mdi0, single 10G/25G on mdi1 */
 #define TLV_PORT_MODE_1x4_1x4(3) /* Single 40G on mdi0, 
single 40G on mdi1 */
-#define TLV_PORT_MODE_2x1_2x1(4) /* Dual 10G/25G on mdi0, 
dual 10G/25G on mdi1 - WARNING: bug3720: On Newport only, this is actually Quad 
10G on mdi0 */
-#define TLV_PORT_MODE_4x1_NA (5) /* Quad 10G/25G on mdi0 */
+#define TLV_PORT_MODE_2x1_2x1(5) /* Dual 10G/25G on mdi0, 
dual 10G/25G on mdi1 */
+#define TLV_PORT_MODE_4x1_NA (4) /* Quad 10G/25G on mdi0 */
 #define TLV_PORT_MODE_NA_4x1 (8) /* Quad 10G/25G on mdi1 */
 #define TLV_PORT_MODE_1x4_2x1(6) /* Single 40G on mdi0, 
dual 10G/25G on mdi1 */
 #define TLV_PORT_MODE_2x1_1x4(7) /* Dual 10G/25G on mdi0, 
single 40G on mdi1 */
@@ -566,7 +578,13 @@ struct tlv_global_port_mode {
 #define TLV_PORT_MODE_1x2_1x4(16) /* Single 50G on mdi0, 
single 40G on mdi1 */
 #define TLV_PORT_MODE_1x2_2x1(17) /* Single 50G on mdi0, 
dual 10G/25G on mdi1 */
 #define TLV_PORT_MODE_2x1_1x2(18) /* Dual 10G/25G on mdi0, 
single 50G on mdi1 */
-/* Below modes are eftest only, to allow snapper explicit selection between 
multi-channel and LLPCS. In production, this selection is automatic and outside 
world should not care about LLPCS */
+
+/* Snapper-only Medford2 port modes.
+ * These modes are eftest only, to allow snapper explicit
+ * selection between multi-channel and LLPCS. In production,
+ * this selection is automatic and outside world should not
+ * care about LLPCS.
+ */
 #define TLV_PORT_MODE_2x1_2x1_LL (19) /* Dual 10G/25G on mdi0, 
dual 10G/25G on mdi1, low-latency PCS */
 #define TLV_PORT_MODE_4x1_NA_LL  (20) /* Quad 10G/25G on mdi0, 
low-latency PCS */
 #define TLV_PORT_MODE_NA_4x1_LL  (21) /* Quad 10G/25G on mdi1, 
low-latency PCS */
@@ -575,42 +593,13 @@ struct tlv_global_port_mode {
 #define TLV_PORT_MODE_BUG63720_DO_NOT_USE(9) /* bug63720: Do not use */
 #define TLV_PORT_MODE_MAX TLV_PORT_MODE_1x1_1x1_LL
 
-/* Deprecated aliases */
-#define TLV_PORT_MODE_10GTLV_PORT_MODE_1x1_NA
-#define TLV_PORT_MODE_40GTLV_PORT_MODE_1x4_NA
-#define TLV_PORT_MODE_10G_10GTLV_PORT_MODE_1x1_1x1
-#define TLV_PORT_MODE_40G_40GTLV_PORT_MODE_1x4_1x4
-#define TLV_PORT_MODE_10G_10G_10G_10GTLV_PORT_MODE_2x1_2x1
-#define TLV_PORT_MODE_10G_10G_10G_10G_Q1 TLV_PORT_MODE_2x1_2x1 /* 
bug63720: Do not use */
-#define TLV_PORT_MODE_10G_10G_10G_10G_Q  TLV_PORT_MODE_4x1_NA
-#define TLV_PORT_MODE_40G_10G_10GTLV_PORT_MODE_1x4_2x1
-#define TLV_PORT_MODE_10G_10G_40GTLV_PORT_MODE_2x1_1x4
-#define TLV_PORT_MODE_10G_10G_10G_10G_Q2 TLV_PORT_MODE_NA_4x1
-#define TLV_PORT_MODE_10G_10G_10G_10G_Q1_Q2 

[dpdk-dev] [PATCH 04/80] net/sfc/base: add 3.3V and 12.0V current sensors

2018-02-19 Thread Andrew Rybchenko
From: Andy Moreton 

Automatically generated using mkconfig.py.

Signed-off-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/efx.h | 4 +++-
 drivers/net/sfc/base/efx_mon.c | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/sfc/base/efx.h b/drivers/net/sfc/base/efx.h
index fe996e7..5158434 100644
--- a/drivers/net/sfc/base/efx.h
+++ b/drivers/net/sfc/base/efx.h
@@ -603,7 +603,7 @@ efx_mon_init(
 #defineEFX_MON_STATS_PAGE_SIZE 0x100
 #defineEFX_MON_MASK_ELEMENT_SIZE 32
 
-/* START MKCONFIG GENERATED MonitorHeaderStatsBlock aa0233c80156308e */
+/* START MKCONFIG GENERATED MonitorHeaderStatsBlock fcc1b6748432e1ac */
 typedef enum efx_mon_stat_e {
EFX_MON_STAT_2_5V,
EFX_MON_STAT_VCCP1,
@@ -684,6 +684,8 @@ typedef enum efx_mon_stat_e {
EFX_MON_STAT_BOARD_BACK_TEMP,
EFX_MON_STAT_I1V8,
EFX_MON_STAT_I2V5,
+   EFX_MON_STAT_I3V3,
+   EFX_MON_STAT_I12V0,
EFX_MON_NSTATS
 } efx_mon_stat_t;
 
diff --git a/drivers/net/sfc/base/efx_mon.c b/drivers/net/sfc/base/efx_mon.c
index 234a420..ac8d7e9 100644
--- a/drivers/net/sfc/base/efx_mon.c
+++ b/drivers/net/sfc/base/efx_mon.c
@@ -99,7 +99,7 @@ efx_mon_init(
 
 #if EFSYS_OPT_NAMES
 
-/* START MKCONFIG GENERATED MonitorStatNamesBlock d92af1538001301f */
+/* START MKCONFIG GENERATED MonitorStatNamesBlock a808884b01444549 */
 static const char * const __mon_stat_name[] = {
"value_2_5v",
"value_vccp1",
@@ -180,6 +180,8 @@ static const char * const __mon_stat_name[] = {
"board_back_temp",
"i1v8",
"i2v5",
+   "i3v3",
+   "i12v0",
 };
 
 /* END MKCONFIG GENERATED MonitorStatNamesBlock */
-- 
2.7.4



[dpdk-dev] [PATCH 13/80] net/sfc/base: add Medford2 support to MAC module

2018-02-19 Thread Andrew Rybchenko
From: Andy Moreton 

Signed-off-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/ef10_mac.c |  7 ---
 drivers/net/sfc/base/efx_impl.h |  1 +
 drivers/net/sfc/base/efx_mac.c  | 11 +--
 3 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/drivers/net/sfc/base/ef10_mac.c b/drivers/net/sfc/base/ef10_mac.c
index db7692e..ed778f7 100644
--- a/drivers/net/sfc/base/ef10_mac.c
+++ b/drivers/net/sfc/base/ef10_mac.c
@@ -8,7 +8,7 @@
 #include "efx_impl.h"
 
 
-#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD
+#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2
 
__checkReturn   efx_rc_t
 ef10_mac_poll(
@@ -356,7 +356,8 @@ ef10_mac_multicast_list_set(
efx_rc_t rc;
 
EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
-   enp->en_family == EFX_FAMILY_MEDFORD);
+   enp->en_family == EFX_FAMILY_MEDFORD ||
+   enp->en_family == EFX_FAMILY_MEDFORD2);
 
if ((rc = emop->emo_reconfigure(enp)) != 0)
goto fail1;
@@ -870,4 +871,4 @@ ef10_mac_stats_update(
 
 #endif /* EFSYS_OPT_MAC_STATS */
 
-#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */
+#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2 */
diff --git a/drivers/net/sfc/base/efx_impl.h b/drivers/net/sfc/base/efx_impl.h
index fadcbb4..76214fb 100644
--- a/drivers/net/sfc/base/efx_impl.h
+++ b/drivers/net/sfc/base/efx_impl.h
@@ -65,6 +65,7 @@ typedef enum efx_mac_type_e {
EFX_MAC_SIENA,
EFX_MAC_HUNTINGTON,
EFX_MAC_MEDFORD,
+   EFX_MAC_MEDFORD2,
EFX_MAC_NTYPES
 } efx_mac_type_t;
 
diff --git a/drivers/net/sfc/base/efx_mac.c b/drivers/net/sfc/base/efx_mac.c
index 511f3eb..117d6d5 100644
--- a/drivers/net/sfc/base/efx_mac.c
+++ b/drivers/net/sfc/base/efx_mac.c
@@ -39,7 +39,7 @@ static const efx_mac_ops_t__efx_mac_siena_ops = {
 };
 #endif /* EFSYS_OPT_SIENA */
 
-#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD
+#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2
 static const efx_mac_ops_t __efx_mac_ef10_ops = {
ef10_mac_poll,  /* emo_poll */
ef10_mac_up,/* emo_up */
@@ -62,7 +62,7 @@ static const efx_mac_ops_t__efx_mac_ef10_ops = {
ef10_mac_stats_update   /* emo_stats_update */
 #endif /* EFSYS_OPT_MAC_STATS */
 };
-#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */
+#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2 */
 
__checkReturn   efx_rc_t
 efx_mac_pdu_set(
@@ -826,6 +826,13 @@ efx_mac_select(
break;
 #endif /* EFSYS_OPT_MEDFORD */
 
+#if EFSYS_OPT_MEDFORD2
+   case EFX_FAMILY_MEDFORD2:
+   emop = &__efx_mac_ef10_ops;
+   type = EFX_MAC_MEDFORD2;
+   break;
+#endif /* EFSYS_OPT_MEDFORD2 */
+
default:
rc = EINVAL;
goto fail1;
-- 
2.7.4



[dpdk-dev] [PATCH 09/80] net/sfc/base: move RxDP config get to EF10 NIC code

2018-02-19 Thread Andrew Rybchenko
From: Andy Moreton 

Signed-off-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/ef10_impl.h|  5 
 drivers/net/sfc/base/ef10_nic.c | 58 +
 drivers/net/sfc/base/medford2_nic.c | 58 -
 drivers/net/sfc/base/medford_nic.c  | 58 -
 4 files changed, 63 insertions(+), 116 deletions(-)

diff --git a/drivers/net/sfc/base/ef10_impl.h b/drivers/net/sfc/base/ef10_impl.h
index 164e9cc..e004d15 100644
--- a/drivers/net/sfc/base/ef10_impl.h
+++ b/drivers/net/sfc/base/ef10_impl.h
@@ -1145,6 +1145,11 @@ efx_mcdi_get_clock(
 
 
 extern __checkReturn   efx_rc_t
+efx_mcdi_get_rxdp_config(
+   __inefx_nic_t *enp,
+   __out   uint32_t *end_paddingp);
+
+extern __checkReturn   efx_rc_t
 efx_mcdi_get_vector_cfg(
__inefx_nic_t *enp,
__out_opt   uint32_t *vec_basep,
diff --git a/drivers/net/sfc/base/ef10_nic.c b/drivers/net/sfc/base/ef10_nic.c
index 311132d..8b9ef15 100644
--- a/drivers/net/sfc/base/ef10_nic.c
+++ b/drivers/net/sfc/base/ef10_nic.c
@@ -424,6 +424,64 @@ efx_mcdi_get_clock(
 }
 
__checkReturn   efx_rc_t
+efx_mcdi_get_rxdp_config(
+   __inefx_nic_t *enp,
+   __out   uint32_t *end_paddingp)
+{
+   efx_mcdi_req_t req;
+   uint8_t payload[MAX(MC_CMD_GET_RXDP_CONFIG_IN_LEN,
+   MC_CMD_GET_RXDP_CONFIG_OUT_LEN)];
+   uint32_t end_padding;
+   efx_rc_t rc;
+
+   memset(payload, 0, sizeof (payload));
+   req.emr_cmd = MC_CMD_GET_RXDP_CONFIG;
+   req.emr_in_buf = payload;
+   req.emr_in_length = MC_CMD_GET_RXDP_CONFIG_IN_LEN;
+   req.emr_out_buf = payload;
+   req.emr_out_length = MC_CMD_GET_RXDP_CONFIG_OUT_LEN;
+
+   efx_mcdi_execute(enp, &req);
+   if (req.emr_rc != 0) {
+   rc = req.emr_rc;
+   goto fail1;
+   }
+
+   if (MCDI_OUT_DWORD_FIELD(req, GET_RXDP_CONFIG_OUT_DATA,
+   GET_RXDP_CONFIG_OUT_PAD_HOST_DMA) == 0) {
+   /* RX DMA end padding is disabled */
+   end_padding = 0;
+   } else {
+   switch (MCDI_OUT_DWORD_FIELD(req, GET_RXDP_CONFIG_OUT_DATA,
+   GET_RXDP_CONFIG_OUT_PAD_HOST_LEN)) {
+   case MC_CMD_SET_RXDP_CONFIG_IN_PAD_HOST_64:
+   end_padding = 64;
+   break;
+   case MC_CMD_SET_RXDP_CONFIG_IN_PAD_HOST_128:
+   end_padding = 128;
+   break;
+   case MC_CMD_SET_RXDP_CONFIG_IN_PAD_HOST_256:
+   end_padding = 256;
+   break;
+   default:
+   rc = ENOTSUP;
+   goto fail2;
+   }
+   }
+
+   *end_paddingp = end_padding;
+
+   return (0);
+
+fail2:
+   EFSYS_PROBE(fail2);
+fail1:
+   EFSYS_PROBE1(fail1, efx_rc_t, rc);
+
+   return (rc);
+}
+
+   __checkReturn   efx_rc_t
 efx_mcdi_get_vector_cfg(
__inefx_nic_t *enp,
__out_opt   uint32_t *vec_basep,
diff --git a/drivers/net/sfc/base/medford2_nic.c 
b/drivers/net/sfc/base/medford2_nic.c
index 8873211..4faf786 100644
--- a/drivers/net/sfc/base/medford2_nic.c
+++ b/drivers/net/sfc/base/medford2_nic.c
@@ -11,64 +11,6 @@
 #if EFSYS_OPT_MEDFORD2
 
 static __checkReturn   efx_rc_t
-efx_mcdi_get_rxdp_config(
-   __inefx_nic_t *enp,
-   __out   uint32_t *end_paddingp)
-{
-   efx_mcdi_req_t req;
-   uint8_t payload[MAX(MC_CMD_GET_RXDP_CONFIG_IN_LEN,
-   MC_CMD_GET_RXDP_CONFIG_OUT_LEN)];
-   uint32_t end_padding;
-   efx_rc_t rc;
-
-   memset(payload, 0, sizeof (payload));
-   req.emr_cmd = MC_CMD_GET_RXDP_CONFIG;
-   req.emr_in_buf = payload;
-   req.emr_in_length = MC_CMD_GET_RXDP_CONFIG_IN_LEN;
-   req.emr_out_buf = payload;
-   req.emr_out_length = MC_CMD_GET_RXDP_CONFIG_OUT_LEN;
-
-   efx_mcdi_execute(enp, &req);
-   if (req.emr_rc != 0) {
-   rc = req.emr_rc;
-   goto fail1;
-   }
-
-   if (MCDI_OUT_DWORD_FIELD(req, GET_RXDP_CONFIG_OUT_DATA,
-   GET_RXDP_CONFIG_OUT_PAD_HOST_DMA) == 0) {
-   /* RX DMA end padding is disabled */
-   end_padding = 0;
-   } else {
-   switch (MCDI_OUT_DWORD_FIELD(req, GET_RXDP_CONFIG_OUT_DATA,
-   GET_RXDP_CONFIG_OUT_PAD_HOST_LEN)) {
-   case MC_CMD_SET_RXDP_CONFIG_IN_PAD_HOST_64:
-   end_padding = 64;
-   break;
-   case MC_CMD_SET_RXDP_CONFIG_IN_PAD_HOST_128:
-   end_padding = 128;
-   break;
-   case MC_CMD_SET_RXDP_CONFIG_IN_PAD_HOST_256:
-  

[dpdk-dev] [PATCH 79/80] net/sfc/base: add signed image layout support

2018-02-19 Thread Andrew Rybchenko
From: Andy Moreton 

Signed-off-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/ef10_image.c | 867 +-
 drivers/net/sfc/base/efx.h|  86 
 2 files changed, 952 insertions(+), 1 deletion(-)

diff --git a/drivers/net/sfc/base/ef10_image.c 
b/drivers/net/sfc/base/ef10_image.c
index e076f40..6fb7e47 100644
--- a/drivers/net/sfc/base/ef10_image.c
+++ b/drivers/net/sfc/base/ef10_image.c
@@ -11,7 +11,872 @@
 
 #if EFSYS_OPT_IMAGE_LAYOUT
 
-#include "ef10_signed_image_layout.h"
+/*
+ * Utility routines to support limited parsing of ASN.1 tags. This is not a
+ * general purpose ASN.1 parser, but is sufficient to locate the required
+ * objects in a signed image with CMS headers.
+ */
+
+/* DER encodings for ASN.1 tags (see ITU-T X.690) */
+#defineASN1_TAG_INTEGER(0x02)
+#defineASN1_TAG_OCTET_STRING   (0x04)
+#defineASN1_TAG_OBJ_ID (0x06)
+#defineASN1_TAG_SEQUENCE   (0x30)
+#defineASN1_TAG_SET(0x31)
+
+#defineASN1_TAG_IS_PRIM(tag)   ((tag & 0x20) == 0)
+
+#defineASN1_TAG_PRIM_CONTEXT(n)(0x80 + (n))
+#defineASN1_TAG_CONS_CONTEXT(n)(0xA0 + (n))
+
+typedef struct efx_asn1_cursor_s {
+   uint8_t *buffer;
+   uint32_tlength;
+
+   uint8_t tag;
+   uint32_thdr_size;
+   uint32_tval_size;
+} efx_asn1_cursor_t;
+
+
+/* Parse header of DER encoded ASN.1 TLV and match tag */
+static __checkReturn   efx_rc_t
+efx_asn1_parse_header_match_tag(
+   __inout efx_asn1_cursor_t   *cursor,
+   __inuint8_t tag)
+{
+   efx_rc_t rc;
+
+   if (cursor == NULL || cursor->buffer == NULL || cursor->length < 2) {
+   rc = EINVAL;
+   goto fail1;
+   }
+
+   cursor->tag = cursor->buffer[0];
+   if (cursor->tag != tag) {
+   /* Tag not matched */
+   rc = ENOENT;
+   goto fail2;
+   }
+
+   if ((cursor->tag & 0x1F) == 0x1F) {
+   /* Long tag format not used in CMS syntax */
+   rc = EINVAL;
+   goto fail3;
+   }
+
+   if ((cursor->buffer[1] & 0x80) == 0) {
+   /* Short form: length is 0..127 */
+   cursor->hdr_size = 2;
+   cursor->val_size = cursor->buffer[1];
+   } else {
+   /* Long form: length encoded as [0x80+nbytes][length bytes] */
+   uint32_t nbytes = cursor->buffer[1] & 0x7F;
+   uint32_t offset;
+
+   if (nbytes == 0) {
+   /* Indefinite length not allowed in DER encoding */
+   rc = EINVAL;
+   goto fail4;
+   }
+   if (2 + nbytes > cursor->length) {
+   /* Header length overflows image buffer */
+   rc = EINVAL;
+   goto fail6;
+   }
+   if (nbytes > sizeof (uint32_t)) {
+   /* Length encoding too big */
+   rc = E2BIG;
+   goto fail5;
+   }
+   cursor->hdr_size = 2 + nbytes;
+   cursor->val_size = 0;
+   for (offset = 2; offset < cursor->hdr_size; offset++) {
+   cursor->val_size =
+   (cursor->val_size << 8) | cursor->buffer[offset];
+   }
+   }
+
+   if ((cursor->hdr_size + cursor->val_size) > cursor->length) {
+   /* Length overflows image buffer */
+   rc = E2BIG;
+   goto fail7;
+   }
+
+   return (0);
+
+fail7:
+   EFSYS_PROBE(fail7);
+fail6:
+   EFSYS_PROBE(fail6);
+fail5:
+   EFSYS_PROBE(fail5);
+fail4:
+   EFSYS_PROBE(fail4);
+fail3:
+   EFSYS_PROBE(fail3);
+fail2:
+   EFSYS_PROBE(fail2);
+fail1:
+   EFSYS_PROBE1(fail1, efx_rc_t, rc);
+
+   return (rc);
+}
+
+/* Enter nested ASN.1 TLV (contained in value of current TLV) */
+static __checkReturn   efx_rc_t
+efx_asn1_enter_tag(
+   __inout efx_asn1_cursor_t   *cursor,
+   __inuint8_t tag)
+{
+   efx_rc_t rc;
+
+   if (cursor == NULL) {
+   rc = EINVAL;
+   goto fail1;
+   }
+
+   if (ASN1_TAG_IS_PRIM(tag)) {
+   /* Cannot enter a primitive tag */
+   rc = ENOTSUP;
+   goto fail2;
+   }
+   rc = efx_asn1_parse_header_match_tag(cursor, tag);
+   if (rc != 0) {
+   /* Invalid TLV or wrong tag */
+   goto fail3;
+   }
+
+   /* Limit cursor range to nested TLV */
+   cursor->buffer += cursor->hdr_size;
+   cursor->length = cursor->val_size;
+
+   return (0);
+
+fail3:
+   EFSYS_PROBE(fail3);
+fail2:
+   EFSYS_PROBE(fail2);
+fail1:
+   EFSYS_PROBE1(fail1, efx_rc_

[dpdk-dev] [PATCH 19/80] net/sfc/base: add Medford2 support to SRAM module

2018-02-19 Thread Andrew Rybchenko
From: Andy Moreton 

Signed-off-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/efx_sram.c | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/net/sfc/base/efx_sram.c b/drivers/net/sfc/base/efx_sram.c
index 1f0ba0a..7851ff1 100644
--- a/drivers/net/sfc/base/efx_sram.c
+++ b/drivers/net/sfc/base/efx_sram.c
@@ -25,9 +25,10 @@ efx_sram_buf_tbl_set(
EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_NIC);
 
-#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD
+#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2
if (enp->en_family == EFX_FAMILY_HUNTINGTON ||
-   enp->en_family == EFX_FAMILY_MEDFORD) {
+   enp->en_family == EFX_FAMILY_MEDFORD ||
+   enp->en_family == EFX_FAMILY_MEDFORD2) {
/*
 * FIXME: the efx_sram_buf_tbl_*() functionality needs to be
 * pulled inside the Falcon/Siena queue create/destroy code,
@@ -39,7 +40,7 @@ efx_sram_buf_tbl_set(
 
return (0);
}
-#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */
+#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2 */
 
if (stop >= EFX_BUF_TBL_SIZE) {
rc = EFBIG;
@@ -147,9 +148,10 @@ efx_sram_buf_tbl_clear(
EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_NIC);
 
-#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD
+#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2
if (enp->en_family == EFX_FAMILY_HUNTINGTON ||
-   enp->en_family == EFX_FAMILY_MEDFORD) {
+   enp->en_family == EFX_FAMILY_MEDFORD ||
+   enp->en_family == EFX_FAMILY_MEDFORD2) {
/*
 * FIXME: the efx_sram_buf_tbl_*() functionality needs to be
 * pulled inside the Falcon/Siena queue create/destroy code,
@@ -161,7 +163,7 @@ efx_sram_buf_tbl_clear(
 
return;
}
-#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */
+#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2 */
 
EFSYS_ASSERT3U(stop, <, EFX_BUF_TBL_SIZE);
 
-- 
2.7.4



[dpdk-dev] [PATCH 58/80] net/sfc/base: move privilege config to ef10 NIC board config

2018-02-19 Thread Andrew Rybchenko
From: Andy Moreton 

Signed-off-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/ef10_nic.c | 15 ++-
 drivers/net/sfc/base/hunt_nic.c | 15 +--
 drivers/net/sfc/base/medford2_nic.c | 15 +--
 drivers/net/sfc/base/medford_nic.c  | 15 +--
 4 files changed, 17 insertions(+), 43 deletions(-)

diff --git a/drivers/net/sfc/base/ef10_nic.c b/drivers/net/sfc/base/ef10_nic.c
index e37a2ac..02f1c19 100644
--- a/drivers/net/sfc/base/ef10_nic.c
+++ b/drivers/net/sfc/base/ef10_nic.c
@@ -1553,6 +1553,7 @@ ef10_nic_board_cfg(
uint32_t board_type = 0;
uint32_t base, nvec;
uint32_t port;
+   uint32_t mask;
uint32_t pf;
uint32_t vf;
uint8_t mac_addr[6] = { 0 };
@@ -1680,13 +1681,25 @@ ef10_nic_board_cfg(
encp->enc_intr_vec_base = base;
encp->enc_intr_limit = nvec;
 
+   /*
+* Get the current privilege mask. Note that this may be modified
+* dynamically, so this value is informational only. DO NOT use
+* the privilege mask to check for sufficient privileges, as that
+* can result in time-of-check/time-of-use bugs.
+*/
+   if ((rc = ef10_get_privilege_mask(enp, &mask)) != 0)
+   goto fail10;
+   encp->enc_privilege_mask = mask;
+
/* Get remaining controller-specific board config */
if ((rc = enop->eno_board_cfg(enp)) != 0)
if (rc != EACCES)
-   goto fail10;
+   goto fail11;
 
return (0);
 
+fail11:
+   EFSYS_PROBE(fail11);
 fail10:
EFSYS_PROBE(fail10);
 fail9:
diff --git a/drivers/net/sfc/base/hunt_nic.c b/drivers/net/sfc/base/hunt_nic.c
index b19b41e..14803c5 100644
--- a/drivers/net/sfc/base/hunt_nic.c
+++ b/drivers/net/sfc/base/hunt_nic.c
@@ -78,7 +78,6 @@ hunt_board_cfg(
 {
efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
efx_port_t *epp = &(enp->en_port);
-   uint32_t mask;
uint32_t flags;
uint32_t sysclk, dpcpu_clk;
uint32_t bandwidth;
@@ -215,18 +214,8 @@ hunt_board_cfg(
encp->enc_piobuf_size = HUNT_PIOBUF_SIZE;
encp->enc_piobuf_min_alloc_size = HUNT_MIN_PIO_ALLOC_SIZE;
 
-   /*
-* Get the current privilege mask. Note that this may be modified
-* dynamically, so this value is informational only. DO NOT use
-* the privilege mask to check for sufficient privileges, as that
-* can result in time-of-check/time-of-use bugs.
-*/
-   if ((rc = ef10_get_privilege_mask(enp, &mask)) != 0)
-   goto fail5;
-   encp->enc_privilege_mask = mask;
-
if ((rc = hunt_nic_get_required_pcie_bandwidth(enp, &bandwidth)) != 0)
-   goto fail6;
+   goto fail5;
encp->enc_required_pcie_bandwidth_mbps = bandwidth;
 
/* All Huntington devices have a PCIe Gen3, 8 lane connector */
@@ -234,8 +223,6 @@ hunt_board_cfg(
 
return (0);
 
-fail6:
-   EFSYS_PROBE(fail6);
 fail5:
EFSYS_PROBE(fail5);
 fail4:
diff --git a/drivers/net/sfc/base/medford2_nic.c 
b/drivers/net/sfc/base/medford2_nic.c
index 85431d2..f0353ca 100644
--- a/drivers/net/sfc/base/medford2_nic.c
+++ b/drivers/net/sfc/base/medford2_nic.c
@@ -49,7 +49,6 @@ medford2_board_cfg(
__inefx_nic_t *enp)
 {
efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
-   uint32_t mask;
uint32_t sysclk, dpcpu_clk;
uint32_t end_padding;
uint32_t bandwidth;
@@ -149,16 +148,6 @@ medford2_board_cfg(
encp->enc_piobuf_min_alloc_size = MEDFORD2_MIN_PIO_ALLOC_SIZE;
 
/*
-* Get the current privilege mask. Note that this may be modified
-* dynamically, so this value is informational only. DO NOT use
-* the privilege mask to check for sufficient privileges, as that
-* can result in time-of-check/time-of-use bugs.
-*/
-   if ((rc = ef10_get_privilege_mask(enp, &mask)) != 0)
-   goto fail5;
-   encp->enc_privilege_mask = mask;
-
-   /*
 * Medford2 stores a single global copy of VPD, not per-PF as on
 * Huntington.
 */
@@ -166,14 +155,12 @@ medford2_board_cfg(
 
rc = medford2_nic_get_required_pcie_bandwidth(enp, &bandwidth);
if (rc != 0)
-   goto fail6;
+   goto fail5;
encp->enc_required_pcie_bandwidth_mbps = bandwidth;
encp->enc_max_pcie_link_gen = EFX_PCIE_LINK_SPEED_GEN3;
 
return (0);
 
-fail6:
-   EFSYS_PROBE(fail6);
 fail5:
EFSYS_PROBE(fail5);
 fail4:
diff --git a/drivers/net/sfc/base/medford_nic.c 
b/drivers/net/sfc/base/medford_nic.c
index daa1478..080df54 100644
--- a/drivers/net/sfc/base/medford_nic.c
+++ b/drivers/net/sfc/base/medford_nic.c
@@ -47,7 +47,6 @@ medford_board_cfg(
__inefx_nic_t *enp)
 {
efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
-   uint32_t mask;
uint32_t sys

[dpdk-dev] [PATCH 08/80] net/sfc/base: correct PIO buffer dimensions for Medford2

2018-02-19 Thread Andrew Rybchenko
From: Andy Moreton 

Signed-off-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/ef10_impl.h| 28 +---
 drivers/net/sfc/base/hunt_nic.c |  1 +
 drivers/net/sfc/base/medford2_nic.c |  1 +
 drivers/net/sfc/base/medford_nic.c  |  1 +
 4 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/drivers/net/sfc/base/ef10_impl.h b/drivers/net/sfc/base/ef10_impl.h
index e79f4d5..164e9cc 100644
--- a/drivers/net/sfc/base/ef10_impl.h
+++ b/drivers/net/sfc/base/ef10_impl.h
@@ -11,13 +11,27 @@
 extern "C" {
 #endif
 
-#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
+
+/* Number of hardware PIO buffers (for compile-time resource dimensions) */
+#defineEF10_MAX_PIOBUF_NBUFS   (16)
+
+#if EFSYS_OPT_HUNTINGTON
+# if (EF10_MAX_PIOBUF_NBUFS < HUNT_PIOBUF_NBUFS)
+#  error "EF10_MAX_PIOBUF_NBUFS too small"
+# endif
+#endif /* EFSYS_OPT_HUNTINGTON */
+#if EFSYS_OPT_MEDFORD
+# if (EF10_MAX_PIOBUF_NBUFS < MEDFORD_PIOBUF_NBUFS)
+#  error "EF10_MAX_PIOBUF_NBUFS too small"
+# endif
+#endif /* EFSYS_OPT_MEDFORD */
+#if EFSYS_OPT_MEDFORD2
+# if (EF10_MAX_PIOBUF_NBUFS < MEDFORD2_PIOBUF_NBUFS)
+#  error "EF10_MAX_PIOBUF_NBUFS too small"
+# endif
+#endif /* EFSYS_OPT_MEDFORD2 */
+
+
 
 /*
  * FIXME: This is just a power of 2 which fits in an MCDI v1 message, and could
diff --git a/drivers/net/sfc/base/hunt_nic.c b/drivers/net/sfc/base/hunt_nic.c
index d03cc13..fb39850 100644
--- a/drivers/net/sfc/base/hunt_nic.c
+++ b/drivers/net/sfc/base/hunt_nic.c
@@ -306,6 +306,7 @@ hunt_board_cfg(
 
encp->enc_buftbl_limit = 0x;
 
+   EFX_STATIC_ASSERT(HUNT_PIOBUF_NBUFS <= EF10_MAX_PIOBUF_NBUFS);
encp->enc_piobuf_limit = HUNT_PIOBUF_NBUFS;
encp->enc_piobuf_size = HUNT_PIOBUF_SIZE;
encp->enc_piobuf_min_alloc_size = HUNT_MIN_PIO_ALLOC_SIZE;
diff --git a/drivers/net/sfc/base/medford2_nic.c 
b/drivers/net/sfc/base/medford2_nic.c
index 68435a0..8873211 100644
--- a/drivers/net/sfc/base/medford2_nic.c
+++ b/drivers/net/sfc/base/medford2_nic.c
@@ -307,6 +307,7 @@ medford2_board_cfg(
 
encp->enc_buftbl_limit = 0x;
 
+   EFX_STATIC_ASSERT(MEDFORD2_PIOBUF_NBUFS <= EF10_MAX_PIOBUF_NBUFS);
encp->enc_piobuf_limit = MEDFORD2_PIOBUF_NBUFS;
encp->enc_piobuf_size = MEDFORD2_PIOBUF_SIZE;
encp->enc_piobuf_min_alloc_size = MEDFORD2_MIN_PIO_ALLOC_SIZE;
diff --git a/drivers/net/sfc/base/medford_nic.c 
b/drivers/net/sfc/base/medford_nic.c
index 1365e9e..9b91a82 100644
--- a/drivers/net/sfc/base/medford_nic.c
+++ b/drivers/net/sfc/base/medford_nic.c
@@ -305,6 +305,7 @@ medford_board_cfg(
 
encp->enc_buftbl_limit = 0x;
 
+   EFX_STATIC_ASSERT(MEDFORD_PIOBUF_NBUFS <= EF10_MAX_PIOBUF_NBUFS);
encp->enc_piobuf_limit = MEDFORD_PIOBUF_NBUFS;
encp->enc_piobuf_size = MEDFORD_PIOBUF_SIZE;
encp->enc_piobuf_min_alloc_size = MEDFORD_MIN_PIO_ALLOC_SIZE;
-- 
2.7.4



[dpdk-dev] [PATCH 57/80] net/sfc/base: move vector config to ef10 NIC board config

2018-02-19 Thread Andrew Rybchenko
From: Andy Moreton 

Signed-off-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/ef10_nic.c | 17 -
 drivers/net/sfc/base/hunt_nic.c | 17 +
 drivers/net/sfc/base/medford2_nic.c | 17 +
 drivers/net/sfc/base/medford_nic.c  | 17 +
 4 files changed, 19 insertions(+), 49 deletions(-)

diff --git a/drivers/net/sfc/base/ef10_nic.c b/drivers/net/sfc/base/ef10_nic.c
index 974e7c0..e37a2ac 100644
--- a/drivers/net/sfc/base/ef10_nic.c
+++ b/drivers/net/sfc/base/ef10_nic.c
@@ -1551,6 +1551,7 @@ ef10_nic_board_cfg(
ef10_link_state_t els;
efx_port_t *epp = &(enp->en_port);
uint32_t board_type = 0;
+   uint32_t base, nvec;
uint32_t port;
uint32_t pf;
uint32_t vf;
@@ -1667,13 +1668,27 @@ ef10_nic_board_cfg(
 
encp->enc_buftbl_limit = 0x;
 
+   /* Get interrupt vector limits */
+   if ((rc = efx_mcdi_get_vector_cfg(enp, &base, &nvec, NULL)) != 0) {
+   if (EFX_PCI_FUNCTION_IS_PF(encp))
+   goto fail9;
+
+   /* Ignore error (cannot query vector limits from a VF). */
+   base = 0;
+   nvec = 1024;
+   }
+   encp->enc_intr_vec_base = base;
+   encp->enc_intr_limit = nvec;
+
/* Get remaining controller-specific board config */
if ((rc = enop->eno_board_cfg(enp)) != 0)
if (rc != EACCES)
-   goto fail9;
+   goto fail10;
 
return (0);
 
+fail10:
+   EFSYS_PROBE(fail10);
 fail9:
EFSYS_PROBE(fail9);
 fail8:
diff --git a/drivers/net/sfc/base/hunt_nic.c b/drivers/net/sfc/base/hunt_nic.c
index 3c1f44a..b19b41e 100644
--- a/drivers/net/sfc/base/hunt_nic.c
+++ b/drivers/net/sfc/base/hunt_nic.c
@@ -81,7 +81,6 @@ hunt_board_cfg(
uint32_t mask;
uint32_t flags;
uint32_t sysclk, dpcpu_clk;
-   uint32_t base, nvec;
uint32_t bandwidth;
efx_rc_t rc;
 
@@ -226,20 +225,8 @@ hunt_board_cfg(
goto fail5;
encp->enc_privilege_mask = mask;
 
-   /* Get interrupt vector limits */
-   if ((rc = efx_mcdi_get_vector_cfg(enp, &base, &nvec, NULL)) != 0) {
-   if (EFX_PCI_FUNCTION_IS_PF(encp))
-   goto fail6;
-
-   /* Ignore error (cannot query vector limits from a VF). */
-   base = 0;
-   nvec = 1024;
-   }
-   encp->enc_intr_vec_base = base;
-   encp->enc_intr_limit = nvec;
-
if ((rc = hunt_nic_get_required_pcie_bandwidth(enp, &bandwidth)) != 0)
-   goto fail7;
+   goto fail6;
encp->enc_required_pcie_bandwidth_mbps = bandwidth;
 
/* All Huntington devices have a PCIe Gen3, 8 lane connector */
@@ -247,8 +234,6 @@ hunt_board_cfg(
 
return (0);
 
-fail7:
-   EFSYS_PROBE(fail7);
 fail6:
EFSYS_PROBE(fail6);
 fail5:
diff --git a/drivers/net/sfc/base/medford2_nic.c 
b/drivers/net/sfc/base/medford2_nic.c
index cd072e4..85431d2 100644
--- a/drivers/net/sfc/base/medford2_nic.c
+++ b/drivers/net/sfc/base/medford2_nic.c
@@ -51,7 +51,6 @@ medford2_board_cfg(
efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
uint32_t mask;
uint32_t sysclk, dpcpu_clk;
-   uint32_t base, nvec;
uint32_t end_padding;
uint32_t bandwidth;
uint32_t vi_window_shift;
@@ -159,18 +158,6 @@ medford2_board_cfg(
goto fail5;
encp->enc_privilege_mask = mask;
 
-   /* Get interrupt vector limits */
-   if ((rc = efx_mcdi_get_vector_cfg(enp, &base, &nvec, NULL)) != 0) {
-   if (EFX_PCI_FUNCTION_IS_PF(encp))
-   goto fail6;
-
-   /* Ignore error (cannot query vector limits from a VF). */
-   base = 0;
-   nvec = 1024;
-   }
-   encp->enc_intr_vec_base = base;
-   encp->enc_intr_limit = nvec;
-
/*
 * Medford2 stores a single global copy of VPD, not per-PF as on
 * Huntington.
@@ -179,14 +166,12 @@ medford2_board_cfg(
 
rc = medford2_nic_get_required_pcie_bandwidth(enp, &bandwidth);
if (rc != 0)
-   goto fail7;
+   goto fail6;
encp->enc_required_pcie_bandwidth_mbps = bandwidth;
encp->enc_max_pcie_link_gen = EFX_PCIE_LINK_SPEED_GEN3;
 
return (0);
 
-fail7:
-   EFSYS_PROBE(fail7);
 fail6:
EFSYS_PROBE(fail6);
 fail5:
diff --git a/drivers/net/sfc/base/medford_nic.c 
b/drivers/net/sfc/base/medford_nic.c
index 9d6989b..daa1478 100644
--- a/drivers/net/sfc/base/medford_nic.c
+++ b/drivers/net/sfc/base/medford_nic.c
@@ -49,7 +49,6 @@ medford_board_cfg(
efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
uint32_t mask;
uint32_t sysclk, dpcpu_clk;
-   uint32_t base, nvec;
uint32_t end_padding;
uint32_t bandwidth;
efx_rc_t rc;
@@ -158,18 +157,6 @@ medford_board_cfg

[dpdk-dev] [PATCH 16/80] net/sfc/base: add Medford2 support to Rx module

2018-02-19 Thread Andrew Rybchenko
From: Andy Moreton 

Signed-off-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/ef10_rx.c |  4 ++--
 drivers/net/sfc/base/efx_rx.c  | 10 --
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/net/sfc/base/ef10_rx.c b/drivers/net/sfc/base/ef10_rx.c
index 2bb6705..ea3df21 100644
--- a/drivers/net/sfc/base/ef10_rx.c
+++ b/drivers/net/sfc/base/ef10_rx.c
@@ -8,7 +8,7 @@
 #include "efx_impl.h"
 
 
-#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD
+#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2
 
 
 static __checkReturn   efx_rc_t
@@ -1087,4 +1087,4 @@ ef10_rx_fini(
 #endif /* EFSYS_OPT_RX_SCALE */
 }
 
-#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */
+#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2 */
diff --git a/drivers/net/sfc/base/efx_rx.c b/drivers/net/sfc/base/efx_rx.c
index c0dcb75..ae79584 100644
--- a/drivers/net/sfc/base/efx_rx.c
+++ b/drivers/net/sfc/base/efx_rx.c
@@ -151,7 +151,7 @@ static const efx_rx_ops_t __efx_rx_siena_ops = {
 };
 #endif /* EFSYS_OPT_SIENA */
 
-#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD
+#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2
 static const efx_rx_ops_t __efx_rx_ef10_ops = {
ef10_rx_init,   /* erxo_init */
ef10_rx_fini,   /* erxo_fini */
@@ -178,7 +178,7 @@ static const efx_rx_ops_t __efx_rx_ef10_ops = {
ef10_rx_qcreate,/* erxo_qcreate */
ef10_rx_qdestroy,   /* erxo_qdestroy */
 };
-#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */
+#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2 */
 
 
__checkReturn   efx_rc_t
@@ -220,6 +220,12 @@ efx_rx_init(
break;
 #endif /* EFSYS_OPT_MEDFORD */
 
+#if EFSYS_OPT_MEDFORD2
+   case EFX_FAMILY_MEDFORD2:
+   erxop = &__efx_rx_ef10_ops;
+   break;
+#endif /* EFSYS_OPT_MEDFORD2 */
+
default:
EFSYS_ASSERT(0);
rc = ENOTSUP;
-- 
2.7.4



[dpdk-dev] [PATCH 17/80] net/sfc/base: add Medford2 support to Tx module

2018-02-19 Thread Andrew Rybchenko
From: Andy Moreton 

Signed-off-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/ef10_tx.c |  4 ++--
 drivers/net/sfc/base/efx_tx.c  | 33 +
 2 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/drivers/net/sfc/base/ef10_tx.c b/drivers/net/sfc/base/ef10_tx.c
index 69c7570..ab11749 100644
--- a/drivers/net/sfc/base/ef10_tx.c
+++ b/drivers/net/sfc/base/ef10_tx.c
@@ -8,7 +8,7 @@
 #include "efx_impl.h"
 
 
-#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD
+#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2
 
 #if EFSYS_OPT_QSTATS
 #defineEFX_TX_QSTAT_INCR(_etp, _stat)  
\
@@ -752,4 +752,4 @@ ef10_tx_qstats_update(
 
 #endif /* EFSYS_OPT_QSTATS */
 
-#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */
+#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2 */
diff --git a/drivers/net/sfc/base/efx_tx.c b/drivers/net/sfc/base/efx_tx.c
index 4e02c86..41c6736 100644
--- a/drivers/net/sfc/base/efx_tx.c
+++ b/drivers/net/sfc/base/efx_tx.c
@@ -175,6 +175,33 @@ static const efx_tx_ops_t  __efx_tx_medford_ops = {
 };
 #endif /* EFSYS_OPT_MEDFORD */
 
+#if EFSYS_OPT_MEDFORD2
+static const efx_tx_ops_t  __efx_tx_medford2_ops = {
+   ef10_tx_init,   /* etxo_init */
+   ef10_tx_fini,   /* etxo_fini */
+   ef10_tx_qcreate,/* etxo_qcreate */
+   ef10_tx_qdestroy,   /* etxo_qdestroy */
+   ef10_tx_qpost,  /* etxo_qpost */
+   ef10_tx_qpush,  /* etxo_qpush */
+   ef10_tx_qpace,  /* etxo_qpace */
+   ef10_tx_qflush, /* etxo_qflush */
+   ef10_tx_qenable,/* etxo_qenable */
+   ef10_tx_qpio_enable,/* etxo_qpio_enable */
+   ef10_tx_qpio_disable,   /* etxo_qpio_disable */
+   ef10_tx_qpio_write, /* etxo_qpio_write */
+   ef10_tx_qpio_post,  /* etxo_qpio_post */
+   ef10_tx_qdesc_post, /* etxo_qdesc_post */
+   ef10_tx_qdesc_dma_create,   /* etxo_qdesc_dma_create */
+   NULL,   /* etxo_qdesc_tso_create */
+   ef10_tx_qdesc_tso2_create,  /* etxo_qdesc_tso2_create */
+   ef10_tx_qdesc_vlantci_create,   /* etxo_qdesc_vlantci_create */
+#if EFSYS_OPT_QSTATS
+   ef10_tx_qstats_update,  /* etxo_qstats_update */
+#endif
+};
+#endif /* EFSYS_OPT_MEDFORD2 */
+
+
__checkReturn   efx_rc_t
 efx_tx_init(
__inefx_nic_t *enp)
@@ -214,6 +241,12 @@ efx_tx_init(
break;
 #endif /* EFSYS_OPT_MEDFORD */
 
+#if EFSYS_OPT_MEDFORD2
+   case EFX_FAMILY_MEDFORD2:
+   etxop = &__efx_tx_medford2_ops;
+   break;
+#endif /* EFSYS_OPT_MEDFORD2 */
+
default:
EFSYS_ASSERT(0);
rc = ENOTSUP;
-- 
2.7.4



[dpdk-dev] [PATCH 07/80] net/sfc/base: add Medford2 support to NIC module

2018-02-19 Thread Andrew Rybchenko
From: Andy Moreton 

Signed-off-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/Makefile |   1 +
 drivers/net/sfc/base/ef10_nic.c  |  34 +--
 drivers/net/sfc/base/efx.h   |   6 +-
 drivers/net/sfc/base/efx_impl.h  |  20 +-
 drivers/net/sfc/base/efx_nic.c   |  53 +
 drivers/net/sfc/base/medford2_impl.h |  35 
 drivers/net/sfc/base/medford2_nic.c  | 388 +++
 drivers/net/sfc/base/meson.build |   3 +-
 8 files changed, 518 insertions(+), 22 deletions(-)
 create mode 100644 drivers/net/sfc/base/medford2_impl.h
 create mode 100644 drivers/net/sfc/base/medford2_nic.c

diff --git a/drivers/net/sfc/Makefile b/drivers/net/sfc/Makefile
index 8a671dd..32b13dd 100644
--- a/drivers/net/sfc/Makefile
+++ b/drivers/net/sfc/Makefile
@@ -125,5 +125,6 @@ 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
+SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += medford2_nic.c
 
 include $(RTE_SDK)/mk/rte.lib.mk
diff --git a/drivers/net/sfc/base/ef10_nic.c b/drivers/net/sfc/base/ef10_nic.c
index eb9ec2b..311132d 100644
--- a/drivers/net/sfc/base/ef10_nic.c
+++ b/drivers/net/sfc/base/ef10_nic.c
@@ -10,7 +10,7 @@
 #include "mcdi_mon.h"
 #endif
 
-#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD
+#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2
 
 #include "ef10_tlv_layout.h"
 
@@ -25,7 +25,8 @@ efx_mcdi_get_port_assignment(
efx_rc_t rc;
 
EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
-   enp->en_family == EFX_FAMILY_MEDFORD);
+   enp->en_family == EFX_FAMILY_MEDFORD ||
+   enp->en_family == EFX_FAMILY_MEDFORD2);
 
(void) memset(payload, 0, sizeof (payload));
req.emr_cmd = MC_CMD_GET_PORT_ASSIGNMENT;
@@ -70,7 +71,8 @@ efx_mcdi_get_port_modes(
efx_rc_t rc;
 
EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
-   enp->en_family == EFX_FAMILY_MEDFORD);
+   enp->en_family == EFX_FAMILY_MEDFORD ||
+   enp->en_family == EFX_FAMILY_MEDFORD2);
 
(void) memset(payload, 0, sizeof (payload));
req.emr_cmd = MC_CMD_GET_PORT_MODES;
@@ -250,7 +252,8 @@ efx_mcdi_get_mac_address_pf(
efx_rc_t rc;
 
EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
-   enp->en_family == EFX_FAMILY_MEDFORD);
+   enp->en_family == EFX_FAMILY_MEDFORD ||
+   enp->en_family == EFX_FAMILY_MEDFORD2);
 
(void) memset(payload, 0, sizeof (payload));
req.emr_cmd = MC_CMD_GET_MAC_ADDRESSES;
@@ -308,7 +311,8 @@ efx_mcdi_get_mac_address_vf(
efx_rc_t rc;
 
EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
-   enp->en_family == EFX_FAMILY_MEDFORD);
+   enp->en_family == EFX_FAMILY_MEDFORD ||
+   enp->en_family == EFX_FAMILY_MEDFORD2);
 
(void) memset(payload, 0, sizeof (payload));
req.emr_cmd = MC_CMD_VPORT_GET_MAC_ADDRESSES;
@@ -372,7 +376,8 @@ efx_mcdi_get_clock(
efx_rc_t rc;
 
EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
-   enp->en_family == EFX_FAMILY_MEDFORD);
+   enp->en_family == EFX_FAMILY_MEDFORD ||
+   enp->en_family == EFX_FAMILY_MEDFORD2);
 
(void) memset(payload, 0, sizeof (payload));
req.emr_cmd = MC_CMD_GET_CLOCK;
@@ -783,7 +788,8 @@ ef10_nic_pio_alloc(
efx_rc_t rc;
 
EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
-   enp->en_family == EFX_FAMILY_MEDFORD);
+   enp->en_family == EFX_FAMILY_MEDFORD ||
+   enp->en_family == EFX_FAMILY_MEDFORD2);
EFSYS_ASSERT(bufnump);
EFSYS_ASSERT(handlep);
EFSYS_ASSERT(blknump);
@@ -1283,7 +1289,8 @@ ef10_nic_probe(
efx_rc_t rc;
 
EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
-   enp->en_family == EFX_FAMILY_MEDFORD);
+   enp->en_family == EFX_FAMILY_MEDFORD ||
+   enp->en_family == EFX_FAMILY_MEDFORD2);
 
/* Read and clear any assertion state */
if ((rc = efx_mcdi_read_assertion(enp)) != 0)
@@ -1497,7 +1504,8 @@ ef10_nic_init(
efx_rc_t rc;
 
EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
-   enp->en_family == EFX_FAMILY_MEDFORD);
+   enp->en_family == EFX_FAMILY_MEDFORD ||
+   enp->en_family == EFX_FAMILY_MEDFORD2);
 
/* Enable reporting of some events (e.g. link change) */
if ((rc = efx_mcdi_log_ctrl(enp)) != 0)
@@ -1653,7 +1661,8 @@ ef10_nic_get_vi_pool(
__out   uint32_t *vi_countp)
 {
EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
-   enp->en_family == EFX_FAMILY_MEDFORD);
+   enp->en_family == EFX_FAMILY_MEDFORD ||
+   enp->en_family

[dpdk-dev] [PATCH 10/80] net/sfc/base: add Medford2 support to EV module

2018-02-19 Thread Andrew Rybchenko
From: Andy Moreton 

Signed-off-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/ef10_ev.c |  7 ---
 drivers/net/sfc/base/efx_ev.c  | 10 --
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/net/sfc/base/ef10_ev.c b/drivers/net/sfc/base/ef10_ev.c
index 05700c5..a05a35a 100644
--- a/drivers/net/sfc/base/ef10_ev.c
+++ b/drivers/net/sfc/base/ef10_ev.c
@@ -10,7 +10,7 @@
 #include "mcdi_mon.h"
 #endif
 
-#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD
+#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2
 
 #if EFSYS_OPT_QSTATS
 #defineEFX_EV_QSTAT_INCR(_eep, _stat)  
\
@@ -549,7 +549,8 @@ ef10_ev_qdestroy(
efx_nic_t *enp = eep->ee_enp;
 
EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
-   enp->en_family == EFX_FAMILY_MEDFORD);
+   enp->en_family == EFX_FAMILY_MEDFORD ||
+   enp->en_family == EFX_FAMILY_MEDFORD2);
 
(void) efx_mcdi_fini_evq(enp, eep->ee_index);
 }
@@ -1388,4 +1389,4 @@ ef10_ev_rxlabel_fini(
 #endif
 }
 
-#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */
+#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2 */
diff --git a/drivers/net/sfc/base/efx_ev.c b/drivers/net/sfc/base/efx_ev.c
index 949d352..1139cc2 100644
--- a/drivers/net/sfc/base/efx_ev.c
+++ b/drivers/net/sfc/base/efx_ev.c
@@ -91,7 +91,7 @@ static const efx_ev_ops_t __efx_ev_siena_ops = {
 };
 #endif /* EFSYS_OPT_SIENA */
 
-#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD
+#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2
 static const efx_ev_ops_t  __efx_ev_ef10_ops = {
ef10_ev_init,   /* eevo_init */
ef10_ev_fini,   /* eevo_fini */
@@ -104,7 +104,7 @@ static const efx_ev_ops_t   __efx_ev_ef10_ops = {
ef10_ev_qstats_update,  /* eevo_qstats_update */
 #endif
 };
-#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */
+#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2 */
 
 
__checkReturn   efx_rc_t
@@ -141,6 +141,12 @@ efx_ev_init(
break;
 #endif /* EFSYS_OPT_MEDFORD */
 
+#if EFSYS_OPT_MEDFORD2
+   case EFX_FAMILY_MEDFORD2:
+   eevop = &__efx_ev_ef10_ops;
+   break;
+#endif /* EFSYS_OPT_MEDFORD2 */
+
default:
EFSYS_ASSERT(0);
rc = ENOTSUP;
-- 
2.7.4



[dpdk-dev] [PATCH 18/80] net/sfc/base: add Medford2 support to NVRAM module

2018-02-19 Thread Andrew Rybchenko
From: Andy Moreton 

Signed-off-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/ef10_nvram.c | 23 +--
 drivers/net/sfc/base/efx_nvram.c  | 10 --
 2 files changed, 29 insertions(+), 4 deletions(-)

diff --git a/drivers/net/sfc/base/ef10_nvram.c 
b/drivers/net/sfc/base/ef10_nvram.c
index 1904597..6c670f2 100644
--- a/drivers/net/sfc/base/ef10_nvram.c
+++ b/drivers/net/sfc/base/ef10_nvram.c
@@ -7,7 +7,7 @@
 #include "efx.h"
 #include "efx_impl.h"
 
-#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD
+#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2
 
 #if EFSYS_OPT_VPD || EFSYS_OPT_NVRAM
 
@@ -2152,6 +2152,20 @@ static ef10_parttbl_entry_t medford_parttbl[] = {
PARTN_MAP_ENTRY(MUM_FIRMWARE,   ALL,MUM_FIRMWARE),
 };
 
+static ef10_parttbl_entry_t medford2_parttbl[] = {
+   /*  partn   ports   nvtype */
+   PARTN_MAP_ENTRY(MC_FIRMWARE,ALL,MC_FIRMWARE),
+   PARTN_MAP_ENTRY(MC_FIRMWARE_BACKUP, ALL,MC_GOLDEN),
+   PARTN_MAP_ENTRY(EXPANSION_ROM,  ALL,BOOTROM),
+   PARTN_MAP_ENTRY(EXPROM_CONFIG,  ALL,BOOTROM_CFG),
+   PARTN_MAP_ENTRY(DYNAMIC_CONFIG, ALL,DYNAMIC_CFG),
+   PARTN_MAP_ENTRY(FPGA,   ALL,FPGA),
+   PARTN_MAP_ENTRY(FPGA_BACKUP,ALL,FPGA_BACKUP),
+   PARTN_MAP_ENTRY(LICENSE,ALL,LICENSE),
+   PARTN_MAP_ENTRY(EXPANSION_UEFI, ALL,UEFIROM),
+   PARTN_MAP_ENTRY(MUM_FIRMWARE,   ALL,MUM_FIRMWARE),
+};
+
 static __checkReturn   efx_rc_t
 ef10_parttbl_get(
__inefx_nic_t *enp,
@@ -2169,6 +2183,11 @@ ef10_parttbl_get(
*parttbl_rowsp = EFX_ARRAY_SIZE(medford_parttbl);
break;
 
+   case EFX_FAMILY_MEDFORD2:
+   *parttblp = medford2_parttbl;
+   *parttbl_rowsp = EFX_ARRAY_SIZE(medford2_parttbl);
+   break;
+
default:
EFSYS_ASSERT(B_FALSE);
return (EINVAL);
@@ -2362,4 +2381,4 @@ ef10_nvram_partn_rw_finish(
 
 #endif /* EFSYS_OPT_NVRAM */
 
-#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */
+#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2 */
diff --git a/drivers/net/sfc/base/efx_nvram.c b/drivers/net/sfc/base/efx_nvram.c
index c2cc9ad..be409c3 100644
--- a/drivers/net/sfc/base/efx_nvram.c
+++ b/drivers/net/sfc/base/efx_nvram.c
@@ -30,7 +30,7 @@ static const efx_nvram_ops_t  __efx_nvram_siena_ops = {
 
 #endif /* EFSYS_OPT_SIENA */
 
-#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD
+#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2
 
 static const efx_nvram_ops_t   __efx_nvram_ef10_ops = {
 #if EFSYS_OPT_DIAG
@@ -49,7 +49,7 @@ static const efx_nvram_ops_t  __efx_nvram_ef10_ops = {
ef10_nvram_buffer_validate, /* envo_buffer_validate */
 };
 
-#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */
+#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2 */
 
__checkReturn   efx_rc_t
 efx_nvram_init(
@@ -81,6 +81,12 @@ efx_nvram_init(
break;
 #endif /* EFSYS_OPT_MEDFORD */
 
+#if EFSYS_OPT_MEDFORD2
+   case EFX_FAMILY_MEDFORD2:
+   envop = &__efx_nvram_ef10_ops;
+   break;
+#endif /* EFSYS_OPT_MEDFORD2 */
+
default:
EFSYS_ASSERT(0);
rc = ENOTSUP;
-- 
2.7.4



[dpdk-dev] [PATCH 21/80] net/sfc/base: add Medford2 support to VPD module

2018-02-19 Thread Andrew Rybchenko
From: Andy Moreton 

Signed-off-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/ef10_vpd.c | 28 ++--
 drivers/net/sfc/base/efx_vpd.c  | 10 --
 2 files changed, 26 insertions(+), 12 deletions(-)

diff --git a/drivers/net/sfc/base/ef10_vpd.c b/drivers/net/sfc/base/ef10_vpd.c
index ad522e8..f71bad3 100644
--- a/drivers/net/sfc/base/ef10_vpd.c
+++ b/drivers/net/sfc/base/ef10_vpd.c
@@ -10,7 +10,7 @@
 
 #if EFSYS_OPT_VPD
 
-#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD
+#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2
 
 #include "ef10_tlv_layout.h"
 
@@ -26,7 +26,8 @@ ef10_vpd_init(
 
EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PROBE);
EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
-   enp->en_family == EFX_FAMILY_MEDFORD);
+   enp->en_family == EFX_FAMILY_MEDFORD ||
+   enp->en_family == EFX_FAMILY_MEDFORD2);
 
if (enp->en_nic_cfg.enc_vpd_is_global) {
tag = TLV_TAG_GLOBAL_STATIC_VPD;
@@ -82,7 +83,8 @@ ef10_vpd_size(
efx_rc_t rc;
 
EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
-   enp->en_family == EFX_FAMILY_MEDFORD);
+   enp->en_family == EFX_FAMILY_MEDFORD ||
+   enp->en_family == EFX_FAMILY_MEDFORD2);
 
/*
 * This function returns the total size the user should allocate
@@ -115,7 +117,8 @@ ef10_vpd_read(
efx_rc_t rc;
 
EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
-   enp->en_family == EFX_FAMILY_MEDFORD);
+   enp->en_family == EFX_FAMILY_MEDFORD ||
+   enp->en_family == EFX_FAMILY_MEDFORD2);
 
if (enp->en_nic_cfg.enc_vpd_is_global) {
tag = TLV_TAG_GLOBAL_DYNAMIC_VPD;
@@ -167,7 +170,8 @@ ef10_vpd_verify(
efx_rc_t rc;
 
EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
-   enp->en_family == EFX_FAMILY_MEDFORD);
+   enp->en_family == EFX_FAMILY_MEDFORD ||
+   enp->en_family == EFX_FAMILY_MEDFORD2);
 
/*
 * Strictly you could take the view that dynamic vpd is optional.
@@ -288,7 +292,8 @@ ef10_vpd_get(
efx_rc_t rc;
 
EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
-   enp->en_family == EFX_FAMILY_MEDFORD);
+   enp->en_family == EFX_FAMILY_MEDFORD ||
+   enp->en_family == EFX_FAMILY_MEDFORD2);
 
/* Attempt to satisfy the request from svpd first */
if (enp->en_arch.ef10.ena_svpd_length > 0) {
@@ -334,7 +339,8 @@ ef10_vpd_set(
efx_rc_t rc;
 
EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
-   enp->en_family == EFX_FAMILY_MEDFORD);
+   enp->en_family == EFX_FAMILY_MEDFORD ||
+   enp->en_family == EFX_FAMILY_MEDFORD2);
 
/* If the provided (tag,keyword) exists in svpd, then it is readonly */
if (enp->en_arch.ef10.ena_svpd_length > 0) {
@@ -387,7 +393,8 @@ ef10_vpd_write(
efx_rc_t rc;
 
EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
-   enp->en_family == EFX_FAMILY_MEDFORD);
+   enp->en_family == EFX_FAMILY_MEDFORD ||
+   enp->en_family == EFX_FAMILY_MEDFORD2);
 
if (enp->en_nic_cfg.enc_vpd_is_global) {
tag = TLV_TAG_GLOBAL_DYNAMIC_VPD;
@@ -423,7 +430,8 @@ ef10_vpd_fini(
__inefx_nic_t *enp)
 {
EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
-   enp->en_family == EFX_FAMILY_MEDFORD);
+   enp->en_family == EFX_FAMILY_MEDFORD ||
+   enp->en_family == EFX_FAMILY_MEDFORD2);
 
if (enp->en_arch.ef10.ena_svpd_length > 0) {
EFSYS_KMEM_FREE(enp->en_esip, enp->en_arch.ef10.ena_svpd_length,
@@ -434,6 +442,6 @@ ef10_vpd_fini(
}
 }
 
-#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */
+#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2 */
 
 #endif /* EFSYS_OPT_VPD */
diff --git a/drivers/net/sfc/base/efx_vpd.c b/drivers/net/sfc/base/efx_vpd.c
index 7b8138f..6d783d7 100644
--- a/drivers/net/sfc/base/efx_vpd.c
+++ b/drivers/net/sfc/base/efx_vpd.c
@@ -44,7 +44,7 @@ static const efx_vpd_ops_t__efx_vpd_siena_ops = {
 
 #endif /* EFSYS_OPT_SIENA */
 
-#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD
+#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2
 
 static const efx_vpd_ops_t __efx_vpd_ef10_ops = {
ef10_vpd_init,  /* evpdo_init */
@@ -59,7 +59,7 @@ static const efx_vpd_ops_t__efx_vpd_ef10_ops = {
ef10_vpd_fini,  /* evpdo_fini */
 };
 
-#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */
+#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2 */
 
__checkReturn   efx_rc_t
 efx_vpd_init(
@@ -91,6 +91,12 @@ efx_vpd_init(
break;
 #endif /* EFSYS_OPT_MEDFORD */
 
+#if EFSYS_OPT_MEDFORD2
+

[dpdk-dev] [PATCH 00/80] net/sfc/base: update base driver

2018-02-19 Thread Andrew Rybchenko
Update base driver to include Medford2 support.

A number of patches have checkpatch errors/warnings because of
coding style difference.

Andrew Jackson (1):
  net/sfc/base: regenerate files with genfwdef after ID update

Andrew Rybchenko (5):
  net/sfc: add missing defines for SAL annotation
  net/sfc/base: update autogenerated headers from firmwaresrc
  net/sfc/base: fix too long line
  net/sfc: size MAC stats DMA buffer to support Medford2
  net/sfc/base: sync MCDI headers and TLV layout

Andy Moreton (64):
  net/sfc/base: add 3.3V and 12.0V current sensors
  net/sfc/base: add Medford2 PCI IDs
  net/sfc/base: add efsys option for Medford2
  net/sfc/base: add Medford2 support to NIC module
  net/sfc/base: correct PIO buffer dimensions for Medford2
  net/sfc/base: move RxDP config get to EF10 NIC code
  net/sfc/base: add Medford2 support to EV module
  net/sfc/base: add Medford2 support to FILTER module
  net/sfc/base: add Medford2 support to INTR module
  net/sfc/base: add Medford2 support to MAC module
  net/sfc/base: add Medford2 support to MCDI module
  net/sfc/base: add Medford2 support to PHY module
  net/sfc/base: add Medford2 support to Rx module
  net/sfc/base: add Medford2 support to Tx module
  net/sfc/base: add Medford2 support to NVRAM module
  net/sfc/base: add Medford2 support to SRAM module
  net/sfc/base: add Medford2 support to BOOTCFG module
  net/sfc/base: add Medford2 support to VPD module
  net/sfc/base: add Medford2 support to MON module
  net/sfc/base: support runtime VI window size
  net/sfc/base: update hardware headers for Medford2
  net/sfc/base: update notes on interrupt testing on VFs
  net/sfc/base: report memory BAR number
  net/sfc/base: simplify loopback type checking
  net/sfc/base: add support new link modes
  net/sfc/base: add new loopback modes
  net/sfc/base: add efsys macro to get memory region size
  net/sfc/base: handle new speeds in linkchange events
  net/sfc/base: refactor EF10 get datapath capabilities
  net/sfc/base: retrieve number of MAC stats from NIC
  net/sfc/base: improve robustness of MAC stats get via MCDI
  net/sfc/base: use MAC stats DMA buffer size from caps
  net/sfc/base: use MAC stats DMA buffer size when decoding
  net/sfc/base: run mkconfig.py to add FEC MAC stats
  net/sfc/base: decode Medford2 FEC stats if available
  net/sfc/base: remove MAC stats size define
  net/sfc/base: use correct name for frame truncation event
  net/sfc/base: add ef10 NIC board config method
  net/sfc/base: move port config to ef10 NIC board config
  net/sfc/base: move PF/VF config to ef10 NIC board config
  net/sfc/base: move MAC address config to ef10 NIC board cfg
  net/sfc/base: move legacy board config to ef10 NIC board cfg
  net/sfc/base: move PHY/link config to ef10 NIC board cfg
  net/sfc/base: move datapath config to ef10 NIC board cfg
  net/sfc/base: move Rx config to ef10 NIC board config
  net/sfc/base: move Tx config to ef10 NIC board config
  net/sfc/base: move limits config to ef10 NIC board config
  net/sfc/base: move vector config to ef10 NIC board config
  net/sfc/base: move privilege config to ef10 NIC board config
  net/sfc/base: move VI window size config to ef10 NIC board
  net/sfc/base: remove obsolete comments
  net/sfc/base: support FEC mode settings
  net/sfc/base: support Medford2 event timer semantics
  net/sfc/base: clarify port mode names and masks
  net/sfc/base: group Medford external port mapping entries
  net/sfc/base: add Medford2 support for external port numbers
  net/sfc/base: add Medford2 support for licencing
  net/sfc/base: add Medford2 support for tunnel encapsulations
  net/sfc/base: add 1.3V voltage and current sensors
  net/sfc/base: run genfwdef to update headers
  net/sfc/base: regenerate headers to pick up CTPIO stats
  net/sfc/base: support CTPIO stats
  net/sfc/base: add firmware image layout option
  net/sfc/base: add signed image layout support

Guido Barzini (4):
  net/sfc/base: provide a flag for controlling CTPIO mode
  net/sfc/base: document the event type for CTPIO sends
  net/sfc/base: add CTPIO statistics
  net/sfc/base: add bit to indicate CTPIO availability

Mark Spender (1):
  net/sfc/base: add method to make checksum option descriptors

Richard Houldsworth (3):
  net/sfc/base: improve comments for EF10 ext port mapping
  net/sfc/base: refactoring eliminating code analysis warnings
  net/sfc/base: resolve code analysis warnings

Vijay Srivastava (2):
  net/sfc/base: add encapsulated TSOv2 capability
  net/sfc/base: add outer IP ID parameter to TSOv2 descriptor

 drivers/net/sfc/Makefile|2 +
 drivers/net/sfc/base/ef10_ev.c  |   82 +-
 drivers/net/sfc/base/ef10_filter.c  |   19 +-
 drivers/net/sfc/base/ef10_image.c   |  885 +++
 drivers/net/sfc/base/ef10_impl.h|   48 +-
 drivers/net/sfc/base/ef10_intr.c|   13 +-
 drivers/net/sfc/base/ef10_mac.c |  154 +-
 drivers/net/sfc/base/ef10_mcdi.c  

[dpdk-dev] [PATCH 29/80] net/sfc/base: update notes on interrupt testing on VFs

2018-02-19 Thread Andrew Rybchenko
From: Andy Moreton 

Signed-off-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/medford2_nic.c | 4 ++--
 drivers/net/sfc/base/medford_nic.c  | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/sfc/base/medford2_nic.c 
b/drivers/net/sfc/base/medford2_nic.c
index 327fcaa..3bca504 100644
--- a/drivers/net/sfc/base/medford2_nic.c
+++ b/drivers/net/sfc/base/medford2_nic.c
@@ -173,8 +173,8 @@ medford2_board_cfg(
 
if (EFX_PCI_FUNCTION_IS_VF(encp)) {
/*
-* Interrupt testing does not work for VFs. See bug50084.
-* FIXME: Does this still apply to Medford2?
+* Interrupt testing does not work for VFs on Medford2.
+* See bug50084 and bug71432 comment 21.
 */
encp->enc_bug41750_workaround = B_TRUE;
}
diff --git a/drivers/net/sfc/base/medford_nic.c 
b/drivers/net/sfc/base/medford_nic.c
index 9b8da99..352ae50 100644
--- a/drivers/net/sfc/base/medford_nic.c
+++ b/drivers/net/sfc/base/medford_nic.c
@@ -173,8 +173,8 @@ medford_board_cfg(
 
if (EFX_PCI_FUNCTION_IS_VF(encp)) {
/*
-* Interrupt testing does not work for VFs. See bug50084.
-* FIXME: Does this still  apply to Medford?
+* Interrupt testing does not work for VFs. See bug50084 and
+* bug71432 comment 21.
 */
encp->enc_bug41750_workaround = B_TRUE;
}
-- 
2.7.4



[dpdk-dev] [PATCH 22/80] net/sfc/base: add Medford2 support to MON module

2018-02-19 Thread Andrew Rybchenko
From: Andy Moreton 

Signed-off-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/mcdi_mon.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/sfc/base/mcdi_mon.c b/drivers/net/sfc/base/mcdi_mon.c
index e4de0da..0e44577 100644
--- a/drivers/net/sfc/base/mcdi_mon.c
+++ b/drivers/net/sfc/base/mcdi_mon.c
@@ -477,6 +477,11 @@ mcdi_mon_cfg_build(
encp->enc_mon_type = EFX_MON_SFC92X0;
break;
 #endif
+#if EFSYS_OPT_MEDFORD2
+   case EFX_FAMILY_MEDFORD2:
+   encp->enc_mon_type = EFX_MON_SFC92X0;
+   break;
+#endif
default:
rc = EINVAL;
goto fail1;
-- 
2.7.4



[dpdk-dev] [PATCH 30/80] net/sfc/base: report memory BAR number

2018-02-19 Thread Andrew Rybchenko
From: Andy Moreton 

On Medford and earlier controllers the BAR layout is:
  PF BAR 0: (32bit I/O) I/O mapped registers
  PF BAR 2: (64bit Mem) Memory mapped registers (VI aperture)
  PF BAR 4: (64bit Mem) MSI-X tables

  VF BAR 0: (64bit Mem) Memory mapped registers (VI aperture)
  VF BAR 2: (64bit Mem) MSI-X tables

On Medford2, the layout is:
  PF/VF BAR 0: (64bit Mem) Memory mapped registers (VI aperture)
  PF/VF BAR 2: (64bit Mem) MSI-X tables

Make the VI aperture BAR number available for drivers that need it.
Remove EFX_MEM_BAR define as it it is not correct on all platforms.

Signed-off-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/efx.h | 15 +--
 drivers/net/sfc/base/efx_nic.c | 26 ++
 drivers/net/sfc/sfc.c  | 40 
 3 files changed, 39 insertions(+), 42 deletions(-)

diff --git a/drivers/net/sfc/base/efx.h b/drivers/net/sfc/base/efx.h
index b038029..6149abf 100644
--- a/drivers/net/sfc/base/efx.h
+++ b/drivers/net/sfc/base/efx.h
@@ -48,7 +48,8 @@ extern__checkReturn   efx_rc_t
 efx_family(
__inuint16_t venid,
__inuint16_t devid,
-   __out   efx_family_t *efp);
+   __out   efx_family_t *efp,
+   __out   unsigned int *membarp);
 
 
 #defineEFX_PCI_VENID_SFC   0x1924
@@ -74,7 +75,17 @@ efx_family(
 #defineEFX_PCI_DEVID_MEDFORD2  0x0B03  /* SFC9250 PF */
 #defineEFX_PCI_DEVID_MEDFORD2_VF   0x1B03  /* SFC9250 VF */
 
-#defineEFX_MEM_BAR 2
+
+#defineEFX_MEM_BAR_SIENA   2
+
+#defineEFX_MEM_BAR_HUNTINGTON_PF   2
+#defineEFX_MEM_BAR_HUNTINGTON_VF   0
+
+#defineEFX_MEM_BAR_MEDFORD_PF  2
+#defineEFX_MEM_BAR_MEDFORD_VF  0
+
+#defineEFX_MEM_BAR_MEDFORD20
+
 
 /* Error codes */
 
diff --git a/drivers/net/sfc/base/efx_nic.c b/drivers/net/sfc/base/efx_nic.c
index 7f32959..bce0def 100644
--- a/drivers/net/sfc/base/efx_nic.c
+++ b/drivers/net/sfc/base/efx_nic.c
@@ -7,11 +7,13 @@
 #include "efx.h"
 #include "efx_impl.h"
 
+
__checkReturn   efx_rc_t
 efx_family(
__inuint16_t venid,
__inuint16_t devid,
-   __out   efx_family_t *efp)
+   __out   efx_family_t *efp,
+   __out   unsigned int *membarp)
 {
if (venid == EFX_PCI_VENID_SFC) {
switch (devid) {
@@ -21,12 +23,10 @@ efx_family(
 * Hardware default for PF0 of uninitialised Siena.
 * manftest must be able to cope with this device id.
 */
-   *efp = EFX_FAMILY_SIENA;
-   return (0);
-
case EFX_PCI_DEVID_BETHPAGE:
case EFX_PCI_DEVID_SIENA:
*efp = EFX_FAMILY_SIENA;
+   *membarp = EFX_MEM_BAR_SIENA;
return (0);
 #endif /* EFSYS_OPT_SIENA */
 
@@ -36,17 +36,16 @@ efx_family(
 * Hardware default for PF0 of uninitialised Huntington.
 * manftest must be able to cope with this device id.
 */
-   *efp = EFX_FAMILY_HUNTINGTON;
-   return (0);
-
case EFX_PCI_DEVID_FARMINGDALE:
case EFX_PCI_DEVID_GREENPORT:
*efp = EFX_FAMILY_HUNTINGTON;
+   *membarp = EFX_MEM_BAR_HUNTINGTON_PF;
return (0);
 
case EFX_PCI_DEVID_FARMINGDALE_VF:
case EFX_PCI_DEVID_GREENPORT_VF:
*efp = EFX_FAMILY_HUNTINGTON;
+   *membarp = EFX_MEM_BAR_HUNTINGTON_VF;
return (0);
 #endif /* EFSYS_OPT_HUNTINGTON */
 
@@ -56,15 +55,14 @@ efx_family(
 * Hardware default for PF0 of uninitialised Medford.
 * manftest must be able to cope with this device id.
 */
-   *efp = EFX_FAMILY_MEDFORD;
-   return (0);
-
case EFX_PCI_DEVID_MEDFORD:
*efp = EFX_FAMILY_MEDFORD;
+   *membarp = EFX_MEM_BAR_MEDFORD_PF;
return (0);
 
case EFX_PCI_DEVID_MEDFORD_VF:
*efp = EFX_FAMILY_MEDFORD;
+   *membarp = EFX_MEM_BAR_MEDFORD_VF;
return (0);
 #endif /* EFSYS_OPT_MEDFORD */
 
@@ -74,15 +72,10 @@ efx_family(
 * Hardware default for PF0 of uninitialised Medford2.
 * manftest must be able to cope with this device id.
 */
-   *efp = EFX_FAM

[dpdk-dev] [PATCH 33/80] net/sfc/base: add new loopback modes

2018-02-19 Thread Andrew Rybchenko
From: Andy Moreton 

Report supported loopback modes for new Medford2 link speeds.

Signed-off-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/efx.h  |  3 +++
 drivers/net/sfc/base/efx_nic.c  | 44 +
 drivers/net/sfc/base/efx_port.c |  3 +++
 3 files changed, 46 insertions(+), 4 deletions(-)

diff --git a/drivers/net/sfc/base/efx.h b/drivers/net/sfc/base/efx.h
index 1b92027..2c7e932 100644
--- a/drivers/net/sfc/base/efx.h
+++ b/drivers/net/sfc/base/efx.h
@@ -809,6 +809,9 @@ typedef enum efx_loopback_type_e {
EFX_LOOPBACK_SD_FEP1_5_WS = 32,
EFX_LOOPBACK_SD_FEP_WS = 33,
EFX_LOOPBACK_SD_FES_WS = 34,
+   EFX_LOOPBACK_AOE_INT_NEAR = 35,
+   EFX_LOOPBACK_DATA_WS = 36,
+   EFX_LOOPBACK_FORCE_EXT_LINK = 37,
EFX_LOOPBACK_NTYPES
 } efx_loopback_type_t;
 
diff --git a/drivers/net/sfc/base/efx_nic.c b/drivers/net/sfc/base/efx_nic.c
index dc53071..35e84e3 100644
--- a/drivers/net/sfc/base/efx_nic.c
+++ b/drivers/net/sfc/base/efx_nic.c
@@ -693,6 +693,9 @@ efx_loopback_mask(
LOOPBACK_CHECK(SD_FEP1_5_WS, SD_FEP1_5_WS);
LOOPBACK_CHECK(SD_FEP_WS, SD_FEP_WS);
LOOPBACK_CHECK(SD_FES_WS, SD_FES_WS);
+   LOOPBACK_CHECK(AOE_INT_NEAR, AOE_INT_NEAR);
+   LOOPBACK_CHECK(DATA_WS, DATA_WS);
+   LOOPBACK_CHECK(FORCE_EXT_LINK, FORCE_EXT_LINK);
 #undef LOOPBACK_CHECK
 
/* Build bitmask of possible loopback types */
@@ -751,7 +754,7 @@ efx_mcdi_get_loopback_modes(
efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
efx_mcdi_req_t req;
uint8_t payload[MAX(MC_CMD_GET_LOOPBACK_MODES_IN_LEN,
-   MC_CMD_GET_LOOPBACK_MODES_OUT_LEN)];
+   MC_CMD_GET_LOOPBACK_MODES_OUT_V2_LEN)];
efx_qword_t mask;
efx_qword_t modes;
efx_rc_t rc;
@@ -761,7 +764,7 @@ efx_mcdi_get_loopback_modes(
req.emr_in_buf = payload;
req.emr_in_length = MC_CMD_GET_LOOPBACK_MODES_IN_LEN;
req.emr_out_buf = payload;
-   req.emr_out_length = MC_CMD_GET_LOOPBACK_MODES_OUT_LEN;
+   req.emr_out_length = MC_CMD_GET_LOOPBACK_MODES_OUT_V2_LEN;
 
efx_mcdi_execute(enp, &req);
 
@@ -802,18 +805,51 @@ efx_mcdi_get_loopback_modes(
MC_CMD_GET_LOOPBACK_MODES_OUT_40G_OFST +
MC_CMD_GET_LOOPBACK_MODES_OUT_40G_LEN) {
/* Response includes 40G loopback modes */
-   modes =
-   *MCDI_OUT2(req, efx_qword_t, GET_LOOPBACK_MODES_OUT_40G);
+   modes = *MCDI_OUT2(req, efx_qword_t,
+   GET_LOOPBACK_MODES_OUT_40G);
EFX_AND_QWORD(modes, mask);
encp->enc_loopback_types[EFX_LINK_4FDX] = modes;
}
 
+   if (req.emr_out_length_used >=
+   MC_CMD_GET_LOOPBACK_MODES_OUT_V2_25G_OFST +
+   MC_CMD_GET_LOOPBACK_MODES_OUT_V2_25G_LEN) {
+   /* Response includes 25G loopback modes */
+   modes = *MCDI_OUT2(req, efx_qword_t,
+   GET_LOOPBACK_MODES_OUT_V2_25G);
+   EFX_AND_QWORD(modes, mask);
+   encp->enc_loopback_types[EFX_LINK_25000FDX] = modes;
+   }
+
+   if (req.emr_out_length_used >=
+   MC_CMD_GET_LOOPBACK_MODES_OUT_V2_50G_OFST +
+   MC_CMD_GET_LOOPBACK_MODES_OUT_V2_50G_LEN) {
+   /* Response includes 50G loopback modes */
+   modes = *MCDI_OUT2(req, efx_qword_t,
+   GET_LOOPBACK_MODES_OUT_V2_50G);
+   EFX_AND_QWORD(modes, mask);
+   encp->enc_loopback_types[EFX_LINK_5FDX] = modes;
+   }
+
+   if (req.emr_out_length_used >=
+   MC_CMD_GET_LOOPBACK_MODES_OUT_V2_100G_OFST +
+   MC_CMD_GET_LOOPBACK_MODES_OUT_V2_100G_LEN) {
+   /* Response includes 100G loopback modes */
+   modes = *MCDI_OUT2(req, efx_qword_t,
+   GET_LOOPBACK_MODES_OUT_V2_100G);
+   EFX_AND_QWORD(modes, mask);
+   encp->enc_loopback_types[EFX_LINK_10FDX] = modes;
+   }
+
EFX_ZERO_QWORD(modes);
EFX_SET_QWORD_BIT(modes, EFX_LOOPBACK_OFF);
EFX_OR_QWORD(modes, encp->enc_loopback_types[EFX_LINK_100FDX]);
EFX_OR_QWORD(modes, encp->enc_loopback_types[EFX_LINK_1000FDX]);
EFX_OR_QWORD(modes, encp->enc_loopback_types[EFX_LINK_1FDX]);
EFX_OR_QWORD(modes, encp->enc_loopback_types[EFX_LINK_4FDX]);
+   EFX_OR_QWORD(modes, encp->enc_loopback_types[EFX_LINK_25000FDX]);
+   EFX_OR_QWORD(modes, encp->enc_loopback_types[EFX_LINK_5FDX]);
+   EFX_OR_QWORD(modes, encp->enc_loopback_types[EFX_LINK_10FDX]);
encp->enc_loopback_types[EFX_LINK_UNKNOWN] = modes;
 
return (0);
diff --git a/drivers/net/sfc/base/efx_port.c b/drivers/net/sfc/base/efx_port.c
index a792a9e..261ac62 100644
--- a/drivers/net/sfc/base/efx_port.c
+++ b/drivers/net/sfc/base/efx_port.c
@@ -180,6 +180,9 @@ static const char * const __ef

[dpdk-dev] [PATCH 31/80] net/sfc/base: simplify loopback type checking

2018-02-19 Thread Andrew Rybchenko
From: Andy Moreton 

Signed-off-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/ef10_phy.c | 24 ++--
 drivers/net/sfc/base/efx_nic.c  | 82 -
 2 files changed, 44 insertions(+), 62 deletions(-)

diff --git a/drivers/net/sfc/base/ef10_phy.c b/drivers/net/sfc/base/ef10_phy.c
index 4b2aa76..e47ca22 100644
--- a/drivers/net/sfc/base/ef10_phy.c
+++ b/drivers/net/sfc/base/ef10_phy.c
@@ -212,26 +212,10 @@ ef10_phy_get_link(
&elsp->els_link_mode, &elsp->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);
-   EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_XFI == EFX_LOOPBACK_XFI);
-   EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_XAUI_FAR == EFX_LOOPBACK_XAUI_FAR);
-   EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_GMII_FAR == EFX_LOOPBACK_GMII_FAR);
-   EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_SGMII_FAR == EFX_LOOPBACK_SGMII_FAR);
-   EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_XFI_FAR == EFX_LOOPBACK_XFI_FAR);
-   EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_GPHY == EFX_LOOPBACK_GPHY);
-   EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_PHYXS == EFX_LOOPBACK_PHY_XS);
-   EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_PCS == EFX_LOOPBACK_PCS);
-   EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_PMAPMD == EFX_LOOPBACK_PMA_PMD);
-
+   /*
+* MC_CMD_LOOPBACK and EFX_LOOPBACK names are equivalent, so use the
+* MCDI value directly. Agreement is checked in efx_loopback_mask().
+*/
elsp->els_loopback = MCDI_OUT_DWORD(req, GET_LINK_OUT_LOOPBACK_MODE);
 #endif /* EFSYS_OPT_LOOPBACK */
 
diff --git a/drivers/net/sfc/base/efx_nic.c b/drivers/net/sfc/base/efx_nic.c
index bce0def..dc53071 100644
--- a/drivers/net/sfc/base/efx_nic.c
+++ b/drivers/net/sfc/base/efx_nic.c
@@ -654,48 +654,46 @@ efx_loopback_mask(
EFSYS_ASSERT3U(loopback_kind, <, EFX_LOOPBACK_NKINDS);
EFSYS_ASSERT(maskp != NULL);
 
-   /* 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);
-   EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_XFI == EFX_LOOPBACK_XFI);
-   EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_XAUI_FAR == EFX_LOOPBACK_XAUI_FAR);
-   EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_GMII_FAR == EFX_LOOPBACK_GMII_FAR);
-   EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_SGMII_FAR == EFX_LOOPBACK_SGMII_FAR);
-   EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_XFI_FAR == EFX_LOOPBACK_XFI_FAR);
-   EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_GPHY == EFX_LOOPBACK_GPHY);
-   EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_PHYXS == EFX_LOOPBACK_PHY_XS);
-   EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_PCS == EFX_LOOPBACK_PCS);
-   EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_PMAPMD == EFX_LOOPBACK_PMA_PMD);
-   EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_XPORT == EFX_LOOPBACK_XPORT);
-   EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_XGMII_WS == EFX_LOOPBACK_XGMII_WS);
-   EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_XAUI_WS == EFX_LOOPBACK_XAUI_WS);
-   EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_XAUI_WS_FAR ==
-   EFX_LOOPBACK_XAUI_WS_FAR);
-   EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_XAUI_WS_NEAR ==
-   EFX_LOOPBACK_XAUI_WS_NEAR);
-   EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_GMII_WS == EFX_LOOPBACK_GMII_WS);
-   EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_XFI_WS == EFX_LOOPBACK_XFI_WS);
-   EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_XFI_WS_FAR ==
-   EFX_LOOPBACK_XFI_WS_FAR);
-   EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_PHYXS_WS == EFX_LOOPBACK_PHYXS_WS);
-   EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_PMA_INT == EFX_LOOPBACK_PMA_INT);
-   EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_SD_NEAR == EFX_LOOPBACK_SD_NEAR);
-   EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_SD_FAR == EFX_LOOPBACK_SD_FAR);
-   EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_PMA_INT_WS ==
-   EFX_LOOPB

[dpdk-dev] [PATCH 35/80] net/sfc/base: handle new speeds in linkchange events

2018-02-19 Thread Andrew Rybchenko
From: Andy Moreton 

Signed-off-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/ef10_phy.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/drivers/net/sfc/base/ef10_phy.c b/drivers/net/sfc/base/ef10_phy.c
index e05fe2b..035099f 100644
--- a/drivers/net/sfc/base/ef10_phy.c
+++ b/drivers/net/sfc/base/ef10_phy.c
@@ -149,9 +149,18 @@ ef10_phy_link_ev(
case MCDI_EVENT_LINKCHANGE_SPEED_10G:
speed = 1;
break;
+   case MCDI_EVENT_LINKCHANGE_SPEED_25G:
+   speed = 25000;
+   break;
case MCDI_EVENT_LINKCHANGE_SPEED_40G:
speed = 4;
break;
+   case MCDI_EVENT_LINKCHANGE_SPEED_50G:
+   speed = 5;
+   break;
+   case MCDI_EVENT_LINKCHANGE_SPEED_100G:
+   speed = 10;
+   break;
default:
speed = 0;
break;
-- 
2.7.4



[dpdk-dev] [PATCH 01/80] net/sfc: add missing defines for SAL annotation

2018-02-19 Thread Andrew Rybchenko
Fixes: e1b944598579 ("net/sfc: build libefx")

Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/efsys.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/sfc/efsys.h b/drivers/net/sfc/efsys.h
index c7a54c3..ecbd14f 100644
--- a/drivers/net/sfc/efsys.h
+++ b/drivers/net/sfc/efsys.h
@@ -119,6 +119,8 @@ prefetch_read_once(const volatile void *addr)
 #define __out_ecount_opt(_n)
 #define __out_bcount(_n)
 #define __out_bcount_opt(_n)
+#define __out_bcount_part(_n, _l)
+#define __out_bcount_part_opt(_n, _l)
 
 #define __deref_out
 
-- 
2.7.4



[dpdk-dev] [PATCH 45/80] net/sfc/base: remove MAC stats size define

2018-02-19 Thread Andrew Rybchenko
From: Andy Moreton 

Signed-off-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/efx.h   | 5 ++---
 drivers/net/sfc/base/siena_mac.c | 2 +-
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/net/sfc/base/efx.h b/drivers/net/sfc/base/efx.h
index 09926ba..5cb3fd0 100644
--- a/drivers/net/sfc/base/efx.h
+++ b/drivers/net/sfc/base/efx.h
@@ -561,7 +561,6 @@ efx_mac_stats_get_mask(
((_mask)[(_stat) / EFX_MAC_STATS_MASK_BITS_PER_PAGE] &  \
(1ULL << ((_stat) & (EFX_MAC_STATS_MASK_BITS_PER_PAGE - 1
 
-#defineEFX_MAC_STATS_SIZE 0x400
 
 extern __checkReturn   efx_rc_t
 efx_mac_stats_clear(
@@ -570,8 +569,8 @@ efx_mac_stats_clear(
 /*
  * Upload mac statistics supported by the hardware into the given buffer.
  *
- * The reference buffer must be at least %EFX_MAC_STATS_SIZE bytes,
- * and page aligned.
+ * The DMA buffer must be 4Kbyte aligned and sized to hold at least
+ * efx_nic_cfg_t::enc_mac_stats_nstats 64bit counters.
  *
  * The hardware will only DMA statistics that it understands (of course).
  * Drivers should not make any assumptions about which statistics are
diff --git a/drivers/net/sfc/base/siena_mac.c b/drivers/net/sfc/base/siena_mac.c
index f395355..f8857cd 100644
--- a/drivers/net/sfc/base/siena_mac.c
+++ b/drivers/net/sfc/base/siena_mac.c
@@ -434,7 +434,7 @@ siena_mac_stats_update(
SIENA_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_NODESC_DROPS, &value);
EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_NODESC_DROP_CNT]), &value);
 
-   EFSYS_DMA_SYNC_FOR_KERNEL(esmp, 0, EFX_MAC_STATS_SIZE);
+   EFSYS_DMA_SYNC_FOR_KERNEL(esmp, 0, EFSYS_MEM_SIZE(esmp));
EFSYS_MEM_READ_BARRIER();
SIENA_MAC_STAT_READ(esmp, MC_CMD_MAC_GENERATION_START,
&generation_start);
-- 
2.7.4



[dpdk-dev] [PATCH 43/80] net/sfc/base: resolve code analysis warnings

2018-02-19 Thread Andrew Rybchenko
From: Richard Houldsworth 

Minimal changes adding buffer size checks and simplifying checksum
processing.

Signed-off-by: Richard Houldsworth 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/efx_bootcfg.c | 67 +++---
 1 file changed, 48 insertions(+), 19 deletions(-)

diff --git a/drivers/net/sfc/base/efx_bootcfg.c 
b/drivers/net/sfc/base/efx_bootcfg.c
index 3a29306..715e18e 100644
--- a/drivers/net/sfc/base/efx_bootcfg.c
+++ b/drivers/net/sfc/base/efx_bootcfg.c
@@ -209,19 +209,25 @@ efx_bootcfg_copy_sector(
size_t used_bytes;
efx_rc_t rc;
 
+   /* Minimum buffer is checksum byte and DHCP_END terminator */
+   if (data_size < 2) {
+   rc = ENOSPC;
+   goto fail1;
+   }
+
/* Verify that the area is correctly formatted and checksummed */
rc = efx_bootcfg_verify(enp, sector, sector_length,
&used_bytes);
 
if (!handle_format_errors) {
if (rc != 0)
-   goto fail1;
+   goto fail2;
 
if ((used_bytes < 2) ||
(sector[used_bytes - 1] != DHCP_END)) {
/* Block too short, or DHCP_END missing */
rc = ENOENT;
-   goto fail2;
+   goto fail3;
}
}
 
@@ -255,9 +261,13 @@ efx_bootcfg_copy_sector(
 */
if (used_bytes > data_size) {
rc = ENOSPC;
-   goto fail3;
+   goto fail4;
}
-   memcpy(data, sector, used_bytes);
+
+   data[0] = 0; /* checksum, updated below */
+
+   /* Copy all after the checksum to the target buffer */
+   memcpy(data + 1, sector + 1, used_bytes - 1);
 
/* Zero out the unused portion of the target buffer */
if (used_bytes < data_size)
@@ -271,6 +281,8 @@ efx_bootcfg_copy_sector(
 
return (0);
 
+fail4:
+   EFSYS_PROBE(fail4);
 fail3:
EFSYS_PROBE(fail3);
 fail2:
@@ -295,6 +307,12 @@ efx_bootcfg_read(
efx_rc_t rc;
uint32_t sector_number;
 
+   /* Minimum buffer is checksum byte and DHCP_END terminator */
+   if (size < 2) {
+   rc = ENOSPC;
+   goto fail1;
+   }
+
 #if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2
sector_number = enp->en_nic_cfg.enc_pf;
 #else
@@ -302,13 +320,18 @@ efx_bootcfg_read(
 #endif
rc = efx_nvram_size(enp, EFX_NVRAM_BOOTROM_CFG, &partn_length);
if (rc != 0)
-   goto fail1;
+   goto fail2;
 
/* The bootcfg sector may be stored in a (larger) shared partition */
rc = efx_bootcfg_sector_info(enp, sector_number,
NULL, §or_offset, §or_length);
if (rc != 0)
-   goto fail2;
+   goto fail3;
+
+   if (sector_length < 2) {
+   rc = EINVAL;
+   goto fail4;
+   }
 
if (sector_length > BOOTCFG_MAX_SIZE)
sector_length = BOOTCFG_MAX_SIZE;
@@ -316,7 +339,7 @@ efx_bootcfg_read(
if (sector_offset + sector_length > partn_length) {
/* Partition is too small */
rc = EFBIG;
-   goto fail3;
+   goto fail5;
}
 
/*
@@ -329,28 +352,28 @@ efx_bootcfg_read(
EFSYS_KMEM_ALLOC(enp->en_esip, sector_length, payload);
if (payload == NULL) {
rc = ENOMEM;
-   goto fail4;
+   goto fail6;
}
} else
payload = (uint8_t *)data;
 
if ((rc = efx_nvram_rw_start(enp, EFX_NVRAM_BOOTROM_CFG, NULL)) != 0)
-   goto fail5;
+   goto fail7;
 
if ((rc = efx_nvram_read_chunk(enp, EFX_NVRAM_BOOTROM_CFG,
sector_offset, (caddr_t)payload, sector_length)) != 0) {
(void) efx_nvram_rw_finish(enp, EFX_NVRAM_BOOTROM_CFG, NULL);
-   goto fail6;
+   goto fail8;
}
 
if ((rc = efx_nvram_rw_finish(enp, EFX_NVRAM_BOOTROM_CFG, NULL)) != 0)
-   goto fail7;
+   goto fail9;
 
/* Verify that the area is correctly formatted and checksummed */
rc = efx_bootcfg_verify(enp, payload, sector_length,
&used_bytes);
if (rc != 0 || used_bytes == 0) {
-   payload[0] = (uint8_t)(~DHCP_END & 0xff);
+   payload[0] = 0;
payload[1] = DHCP_END;
used_bytes = 2;
}
@@ -365,10 +388,8 @@ efx_bootcfg_read(
 * so reinitialise the sector if there isn't room for the character.
 */
if (payload[used_bytes - 1] != DHCP_END) {
-   if (used_bytes + 1 > sector_length) {
-   payload[0] = 0;
+   if (used_bytes >= sector_length)
used_bytes = 1;
-   }
 
  

[dpdk-dev] [PATCH 39/80] net/sfc/base: use MAC stats DMA buffer size from caps

2018-02-19 Thread Andrew Rybchenko
From: Andy Moreton 

For Medford2 the DMA buffer used for one-shot or periodic MAC stats
has been extended. Ensure the MAC stats DMA buffer size is large
enough to hold the number of stats counters supported by firmware.

Signed-off-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/efx_mcdi.c | 28 +---
 1 file changed, 21 insertions(+), 7 deletions(-)

diff --git a/drivers/net/sfc/base/efx_mcdi.c b/drivers/net/sfc/base/efx_mcdi.c
index a593b3f..a78a226 100644
--- a/drivers/net/sfc/base/efx_mcdi.c
+++ b/drivers/net/sfc/base/efx_mcdi.c
@@ -1791,7 +1791,7 @@ efx_mcdi_mac_stats(
 {
efx_mcdi_req_t req;
uint8_t payload[MAX(MC_CMD_MAC_STATS_IN_LEN,
-   MC_CMD_MAC_STATS_OUT_DMA_LEN)];
+   MC_CMD_MAC_STATS_V2_OUT_DMA_LEN)];
int clear = (action == EFX_STATS_CLEAR);
int upload = (action == EFX_STATS_UPLOAD);
int enable = (action == EFX_STATS_ENABLE_NOEVENTS);
@@ -1804,7 +1804,7 @@ efx_mcdi_mac_stats(
req.emr_in_buf = payload;
req.emr_in_length = MC_CMD_MAC_STATS_IN_LEN;
req.emr_out_buf = payload;
-   req.emr_out_length = MC_CMD_MAC_STATS_OUT_DMA_LEN;
+   req.emr_out_length = MC_CMD_MAC_STATS_V2_OUT_DMA_LEN;
 
MCDI_IN_POPULATE_DWORD_6(req, MAC_STATS_IN_CMD,
MAC_STATS_IN_DMA, upload,
@@ -1815,7 +1815,8 @@ efx_mcdi_mac_stats(
MAC_STATS_IN_PERIOD_MS, (enable | events) ? period_ms : 0);
 
if (enable || events || upload) {
-   uint32_t bytes = MC_CMD_MAC_NSTATS * sizeof (uint64_t);
+   const efx_nic_cfg_t *encp = &enp->en_nic_cfg;
+   uint32_t bytes;
 
/* Periodic stats or stats upload require a DMA buffer */
if (esmp == NULL) {
@@ -1823,10 +1824,19 @@ efx_mcdi_mac_stats(
goto fail1;
}
 
-   EFX_STATIC_ASSERT(MC_CMD_MAC_NSTATS * sizeof (uint64_t) <=
-   EFX_MAC_STATS_SIZE);
+   if (encp->enc_mac_stats_nstats < MC_CMD_MAC_NSTATS) {
+   /* MAC stats count too small for legacy MAC stats */
+   rc = ENOSPC;
+   goto fail2;
+   }
+
+   bytes = encp->enc_mac_stats_nstats * sizeof (efx_qword_t);
 
-   EFSYS_ASSERT3U(bytes, <=, (uint32_t)EFSYS_MEM_SIZE(esmp));
+   if (EFSYS_MEM_SIZE(esmp) < bytes) {
+   /* DMA buffer too small */
+   rc = ENOSPC;
+   goto fail3;
+   }
 
MCDI_IN_SET_DWORD(req, MAC_STATS_IN_DMA_ADDR_LO,
EFSYS_MEM_ADDR(esmp) & 0x);
@@ -1850,12 +1860,16 @@ efx_mcdi_mac_stats(
if ((req.emr_rc != ENOENT) ||
(enp->en_rx_qcount + enp->en_tx_qcount != 0)) {
rc = req.emr_rc;
-   goto fail2;
+   goto fail4;
}
}
 
return (0);
 
+fail4:
+   EFSYS_PROBE(fail4);
+fail3:
+   EFSYS_PROBE(fail3);
 fail2:
EFSYS_PROBE(fail2);
 fail1:
-- 
2.7.4



[dpdk-dev] [PATCH 48/80] net/sfc/base: move port config to ef10 NIC board config

2018-02-19 Thread Andrew Rybchenko
From: Andy Moreton 

Signed-off-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/ef10_impl.h|  5 
 drivers/net/sfc/base/ef10_nic.c | 23 +--
 drivers/net/sfc/base/hunt_nic.c | 46 +++--
 drivers/net/sfc/base/medford2_nic.c | 41 ++---
 drivers/net/sfc/base/medford_nic.c  | 44 ++-
 5 files changed, 58 insertions(+), 101 deletions(-)

diff --git a/drivers/net/sfc/base/ef10_impl.h b/drivers/net/sfc/base/ef10_impl.h
index e598a9a..4a50955 100644
--- a/drivers/net/sfc/base/ef10_impl.h
+++ b/drivers/net/sfc/base/ef10_impl.h
@@ -1175,11 +1175,6 @@ ef10_get_privilege_mask(
__inefx_nic_t *enp,
__out   uint32_t *maskp);
 
-extern __checkReturn   efx_rc_t
-ef10_external_port_mapping(
-   __inefx_nic_t *enp,
-   __inuint32_t port,
-   __out   uint8_t *external_portp);
 
 #if EFSYS_OPT_RX_PACKED_STREAM
 
diff --git a/drivers/net/sfc/base/ef10_nic.c b/drivers/net/sfc/base/ef10_nic.c
index b315e9f..c63aad8 100644
--- a/drivers/net/sfc/base/ef10_nic.c
+++ b/drivers/net/sfc/base/ef10_nic.c
@@ -1467,7 +1467,7 @@ static struct ef10_external_port_map_s {
},
 };
 
-   __checkReturn   efx_rc_t
+static __checkReturn   efx_rc_t
 ef10_external_port_mapping(
__inefx_nic_t *enp,
__inuint32_t port,
@@ -1546,14 +1546,33 @@ ef10_nic_board_cfg(
__inefx_nic_t *enp)
 {
const efx_nic_ops_t *enop = enp->en_enop;
+   efx_mcdi_iface_t *emip = &(enp->en_mcdi.em_emip);
+   efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
+   uint32_t port;
efx_rc_t rc;
 
+   /* Get the (zero-based) MCDI port number */
+   if ((rc = efx_mcdi_get_port_assignment(enp, &port)) != 0)
+   goto fail1;
+
+   /* EFX MCDI interface uses one-based port numbers */
+   emip->emi_port = port + 1;
+
+   if ((rc = ef10_external_port_mapping(enp, port,
+   &encp->enc_external_port)) != 0)
+   goto fail2;
+
+   /* Get remaining controller-specific board config */
if ((rc = enop->eno_board_cfg(enp)) != 0)
if (rc != EACCES)
-   goto fail1;
+   goto fail3;
 
return (0);
 
+fail3:
+   EFSYS_PROBE(fail3);
+fail2:
+   EFSYS_PROBE(fail2);
 fail1:
EFSYS_PROBE1(fail1, efx_rc_t, rc);
 
diff --git a/drivers/net/sfc/base/hunt_nic.c b/drivers/net/sfc/base/hunt_nic.c
index 903c669..0b311b6 100644
--- a/drivers/net/sfc/base/hunt_nic.c
+++ b/drivers/net/sfc/base/hunt_nic.c
@@ -76,13 +76,11 @@ hunt_nic_get_required_pcie_bandwidth(
 hunt_board_cfg(
__inefx_nic_t *enp)
 {
-   efx_mcdi_iface_t *emip = &(enp->en_mcdi.em_emip);
efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
uint8_t mac_addr[6] = { 0 };
uint32_t board_type = 0;
ef10_link_state_t els;
efx_port_t *epp = &(enp->en_port);
-   uint32_t port;
uint32_t pf;
uint32_t vf;
uint32_t mask;
@@ -102,20 +100,6 @@ hunt_board_cfg(
EFX_STATIC_ASSERT(1U << EFX_VI_WINDOW_SHIFT_8K  == 8192);
encp->enc_vi_window_shift = EFX_VI_WINDOW_SHIFT_8K;
 
-
-   if ((rc = efx_mcdi_get_port_assignment(enp, &port)) != 0)
-   goto fail1;
-
-   /*
-* NOTE: The MCDI protocol numbers ports from zero.
-* The common code MCDI interface numbers ports from one.
-*/
-   emip->emi_port = port + 1;
-
-   if ((rc = ef10_external_port_mapping(enp, port,
-   &encp->enc_external_port)) != 0)
-   goto fail2;
-
/*
 * Get PCIe function number from firmware (used for
 * per-function privilege and dynamic config info).
@@ -123,7 +107,7 @@ hunt_board_cfg(
 *  - PCIe VF: pf = parent PF, vf = VF number.
 */
if ((rc = efx_mcdi_get_function_info(enp, &pf, &vf)) != 0)
-   goto fail3;
+   goto fail1;
 
encp->enc_pf = pf;
encp->enc_vf = vf;
@@ -144,7 +128,7 @@ hunt_board_cfg(
rc = efx_mcdi_get_mac_address_vf(enp, mac_addr);
}
if (rc != 0)
-   goto fail4;
+   goto fail2;
 
EFX_MAC_ADDR_COPY(encp->enc_mac_addr, mac_addr);
 
@@ -155,7 +139,7 @@ hunt_board_cfg(
if (rc == EACCES)
board_type = 0;
else
-   goto fail5;
+   goto fail3;
}
 
encp->enc_board_type = board_type;
@@ -163,11 +147,11 @@ hunt_board_cfg(
 
/* Fill out fields in enp->en_port and enp->en_nic_cfg from MCDI */
if ((rc = efx_mcdi_get_phy_cfg(enp)) != 0)
-   goto fail6;
+   goto fail4;
 
/* Obtain the default PHY advertised capabilities */
if ((rc = ef10_phy_get_li

[dpdk-dev] [PATCH 44/80] net/sfc: size MAC stats DMA buffer to support Medford2

2018-02-19 Thread Andrew Rybchenko
Medford2 supports more MAC stats than previous HW. So DMA
buffer must be sized properly.

Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/sfc_port.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/net/sfc/sfc_port.c b/drivers/net/sfc/sfc_port.c
index c423f52..0272b55 100644
--- a/drivers/net/sfc/sfc_port.c
+++ b/drivers/net/sfc/sfc_port.c
@@ -323,6 +323,8 @@ sfc_port_attach(struct sfc_adapter *sa)
struct sfc_port *port = &sa->port;
const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic);
const struct ether_addr *from;
+   uint32_t mac_nstats;
+   size_t mac_stats_size;
long kvarg_stats_update_period_ms;
int rc;
 
@@ -358,7 +360,9 @@ sfc_port_attach(struct sfc_adapter *sa)
if (port->mac_stats_buf == NULL)
goto fail_mac_stats_buf_alloc;
 
-   rc = sfc_dma_alloc(sa, "mac_stats", 0, EFX_MAC_STATS_SIZE,
+   mac_nstats = efx_nic_cfg_get(sa->nic)->enc_mac_stats_nstats;
+   mac_stats_size = RTE_ALIGN(mac_nstats * sizeof(uint64_t), EFX_BUF_SIZE);
+   rc = sfc_dma_alloc(sa, "mac_stats", 0, mac_stats_size,
   sa->socket_id, &port->mac_stats_dma_mem);
if (rc != 0)
goto fail_mac_stats_dma_alloc;
-- 
2.7.4



[dpdk-dev] [PATCH 52/80] net/sfc/base: move PHY/link config to ef10 NIC board cfg

2018-02-19 Thread Andrew Rybchenko
From: Andy Moreton 

Signed-off-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/ef10_nic.c | 18 +-
 drivers/net/sfc/base/hunt_nic.c | 31 ---
 drivers/net/sfc/base/medford2_nic.c | 30 +++---
 drivers/net/sfc/base/medford_nic.c  | 30 +++---
 4 files changed, 39 insertions(+), 70 deletions(-)

diff --git a/drivers/net/sfc/base/ef10_nic.c b/drivers/net/sfc/base/ef10_nic.c
index 5f4357b..8e9d7a1 100644
--- a/drivers/net/sfc/base/ef10_nic.c
+++ b/drivers/net/sfc/base/ef10_nic.c
@@ -1548,6 +1548,8 @@ ef10_nic_board_cfg(
const efx_nic_ops_t *enop = enp->en_enop;
efx_mcdi_iface_t *emip = &(enp->en_mcdi.em_emip);
efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
+   ef10_link_state_t els;
+   efx_port_t *epp = &(enp->en_port);
uint32_t board_type = 0;
uint32_t port;
uint32_t pf;
@@ -1619,13 +1621,27 @@ ef10_nic_board_cfg(
encp->enc_board_type = board_type;
encp->enc_clk_mult = 1; /* not used for EF10 */
 
+   /* Fill out fields in enp->en_port and enp->en_nic_cfg from MCDI */
+   if ((rc = efx_mcdi_get_phy_cfg(enp)) != 0)
+   goto fail6;
+
+   /* Obtain the default PHY advertised capabilities */
+   if ((rc = ef10_phy_get_link(enp, &els)) != 0)
+   goto fail7;
+   epp->ep_default_adv_cap_mask = els.els_adv_cap_mask;
+   epp->ep_adv_cap_mask = els.els_adv_cap_mask;
+
/* Get remaining controller-specific board config */
if ((rc = enop->eno_board_cfg(enp)) != 0)
if (rc != EACCES)
-   goto fail6;
+   goto fail8;
 
return (0);
 
+fail8:
+   EFSYS_PROBE(fail8);
+fail7:
+   EFSYS_PROBE(fail7);
 fail6:
EFSYS_PROBE(fail6);
 fail5:
diff --git a/drivers/net/sfc/base/hunt_nic.c b/drivers/net/sfc/base/hunt_nic.c
index 58c2d13..d33d2db 100644
--- a/drivers/net/sfc/base/hunt_nic.c
+++ b/drivers/net/sfc/base/hunt_nic.c
@@ -77,7 +77,6 @@ hunt_board_cfg(
__inefx_nic_t *enp)
 {
efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
-   ef10_link_state_t els;
efx_port_t *epp = &(enp->en_port);
uint32_t mask;
uint32_t flags;
@@ -96,16 +95,6 @@ hunt_board_cfg(
EFX_STATIC_ASSERT(1U << EFX_VI_WINDOW_SHIFT_8K  == 8192);
encp->enc_vi_window_shift = EFX_VI_WINDOW_SHIFT_8K;
 
-   /* Fill out fields in enp->en_port and enp->en_nic_cfg from MCDI */
-   if ((rc = efx_mcdi_get_phy_cfg(enp)) != 0)
-   goto fail1;
-
-   /* Obtain the default PHY advertised capabilities */
-   if ((rc = ef10_phy_get_link(enp, &els)) != 0)
-   goto fail2;
-   epp->ep_default_adv_cap_mask = els.els_adv_cap_mask;
-   epp->ep_adv_cap_mask = els.els_adv_cap_mask;
-
/*
 * Enable firmware workarounds for hardware errata.
 * Expected responses are:
@@ -133,7 +122,7 @@ hunt_board_cfg(
else if ((rc == ENOTSUP) || (rc == ENOENT))
encp->enc_bug35388_workaround = B_FALSE;
else
-   goto fail3;
+   goto fail1;
 
/*
 * If the bug41750 workaround is enabled, then do not test interrupts,
@@ -152,7 +141,7 @@ hunt_board_cfg(
} else if ((rc == ENOTSUP) || (rc == ENOENT)) {
encp->enc_bug41750_workaround = B_FALSE;
} else {
-   goto fail4;
+   goto fail2;
}
if (EFX_PCI_FUNCTION_IS_VF(encp)) {
/* Interrupt testing does not work for VFs. See bug50084. */
@@ -190,12 +179,12 @@ hunt_board_cfg(
} else if ((rc == ENOTSUP) || (rc == ENOENT)) {
encp->enc_bug26807_workaround = B_FALSE;
} else {
-   goto fail5;
+   goto fail3;
}
 
/* Get clock frequencies (in MHz). */
if ((rc = efx_mcdi_get_clock(enp, &sysclk, &dpcpu_clk)) != 0)
-   goto fail6;
+   goto fail4;
 
/*
 * The Huntington timer quantum is 1536 sysclk cycles, documented for
@@ -214,7 +203,7 @@ hunt_board_cfg(
 
/* Check capabilities of running datapath firmware */
if ((rc = ef10_get_datapath_caps(enp)) != 0)
-   goto fail7;
+   goto fail5;
 
/* Alignment for receive packet DMA buffers */
encp->enc_rx_buf_align_start = 1;
@@ -264,13 +253,13 @@ hunt_board_cfg(
 * can result in time-of-check/time-of-use bugs.
 */
if ((rc = ef10_get_privilege_mask(enp, &mask)) != 0)
-   goto fail8;
+   goto fail6;
encp->enc_privilege_mask = mask;
 
/* Get interrupt vector limits */
if ((rc = efx_mcdi_get_vector_cfg(enp, &base, &nvec, NULL)) != 0) {
if (EFX_PCI_FUNCTION_IS_PF(encp))
-   goto fail9;
+   goto fail7;
 
/* Ignore error

[dpdk-dev] [PATCH 53/80] net/sfc/base: move datapath config to ef10 NIC board cfg

2018-02-19 Thread Andrew Rybchenko
From: Andy Moreton 

Signed-off-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/ef10_impl.h|  4 
 drivers/net/sfc/base/ef10_nic.c | 10 --
 drivers/net/sfc/base/hunt_nic.c | 12 +++-
 drivers/net/sfc/base/medford2_nic.c | 14 --
 drivers/net/sfc/base/medford_nic.c  | 14 --
 5 files changed, 19 insertions(+), 35 deletions(-)

diff --git a/drivers/net/sfc/base/ef10_impl.h b/drivers/net/sfc/base/ef10_impl.h
index 4a50955..e1708ab 100644
--- a/drivers/net/sfc/base/ef10_impl.h
+++ b/drivers/net/sfc/base/ef10_impl.h
@@ -1162,10 +1162,6 @@ efx_mcdi_get_vector_cfg(
__out_opt   uint32_t *vf_nvecp);
 
 extern __checkReturn   efx_rc_t
-ef10_get_datapath_caps(
-   __inefx_nic_t *enp);
-
-extern __checkReturn   efx_rc_t
 ef10_get_vi_window_shift(
__inefx_nic_t *enp,
__out   uint32_t *vi_window_shiftp);
diff --git a/drivers/net/sfc/base/ef10_nic.c b/drivers/net/sfc/base/ef10_nic.c
index 8e9d7a1..e7fa7b8 100644
--- a/drivers/net/sfc/base/ef10_nic.c
+++ b/drivers/net/sfc/base/ef10_nic.c
@@ -989,7 +989,7 @@ ef10_mcdi_get_pf_count(
return (rc);
 }
 
-   __checkReturn   efx_rc_t
+static __checkReturn   efx_rc_t
 ef10_get_datapath_caps(
__inefx_nic_t *enp)
 {
@@ -1631,13 +1631,19 @@ ef10_nic_board_cfg(
epp->ep_default_adv_cap_mask = els.els_adv_cap_mask;
epp->ep_adv_cap_mask = els.els_adv_cap_mask;
 
+   /* Check capabilities of running datapath firmware */
+   if ((rc = ef10_get_datapath_caps(enp)) != 0)
+   goto fail8;
+
/* Get remaining controller-specific board config */
if ((rc = enop->eno_board_cfg(enp)) != 0)
if (rc != EACCES)
-   goto fail8;
+   goto fail9;
 
return (0);
 
+fail9:
+   EFSYS_PROBE(fail9);
 fail8:
EFSYS_PROBE(fail8);
 fail7:
diff --git a/drivers/net/sfc/base/hunt_nic.c b/drivers/net/sfc/base/hunt_nic.c
index d33d2db..95b48a7 100644
--- a/drivers/net/sfc/base/hunt_nic.c
+++ b/drivers/net/sfc/base/hunt_nic.c
@@ -201,10 +201,6 @@ hunt_board_cfg(
 
encp->enc_bug61265_workaround = B_FALSE; /* Medford only */
 
-   /* Check capabilities of running datapath firmware */
-   if ((rc = ef10_get_datapath_caps(enp)) != 0)
-   goto fail5;
-
/* Alignment for receive packet DMA buffers */
encp->enc_rx_buf_align_start = 1;
encp->enc_rx_buf_align_end = 64; /* RX DMA end padding */
@@ -253,13 +249,13 @@ hunt_board_cfg(
 * can result in time-of-check/time-of-use bugs.
 */
if ((rc = ef10_get_privilege_mask(enp, &mask)) != 0)
-   goto fail6;
+   goto fail5;
encp->enc_privilege_mask = mask;
 
/* Get interrupt vector limits */
if ((rc = efx_mcdi_get_vector_cfg(enp, &base, &nvec, NULL)) != 0) {
if (EFX_PCI_FUNCTION_IS_PF(encp))
-   goto fail7;
+   goto fail6;
 
/* Ignore error (cannot query vector limits from a VF). */
base = 0;
@@ -275,7 +271,7 @@ hunt_board_cfg(
encp->enc_tx_tso_tcp_header_offset_limit = EF10_TCP_HEADER_OFFSET_LIMIT;
 
if ((rc = hunt_nic_get_required_pcie_bandwidth(enp, &bandwidth)) != 0)
-   goto fail8;
+   goto fail7;
encp->enc_required_pcie_bandwidth_mbps = bandwidth;
 
/* All Huntington devices have a PCIe Gen3, 8 lane connector */
@@ -283,8 +279,6 @@ hunt_board_cfg(
 
return (0);
 
-fail8:
-   EFSYS_PROBE(fail8);
 fail7:
EFSYS_PROBE(fail7);
 fail6:
diff --git a/drivers/net/sfc/base/medford2_nic.c 
b/drivers/net/sfc/base/medford2_nic.c
index afaafb9..f383b31 100644
--- a/drivers/net/sfc/base/medford2_nic.c
+++ b/drivers/net/sfc/base/medford2_nic.c
@@ -124,17 +124,13 @@ medford2_board_cfg(
encp->enc_evq_timer_max_us = (encp->enc_evq_timer_quantum_ns <<
FRF_CZ_TC_TIMER_VAL_WIDTH) / 1000;
 
-   /* Check capabilities of running datapath firmware */
-   if ((rc = ef10_get_datapath_caps(enp)) != 0)
-   goto fail4;
-
/* Alignment for receive packet DMA buffers */
encp->enc_rx_buf_align_start = 1;
 
/* Get the RX DMA end padding alignment configuration */
if ((rc = efx_mcdi_get_rxdp_config(enp, &end_padding)) != 0) {
if (rc != EACCES)
-   goto fail5;
+   goto fail4;
 
/* Assume largest tail padding size supported by hardware */
end_padding = 256;
@@ -186,13 +182,13 @@ medford2_board_cfg(
 * can result in time-of-check/time-of-use bugs.
 */
if ((rc = ef10_get_privilege_mask(enp, &mask)) != 0)
-   goto fail6;
+   goto fail5;
encp->enc_privilege_mask = mask;
 
/* Get interrupt vector limits */
if 

[dpdk-dev] [PATCH 51/80] net/sfc/base: move legacy board config to ef10 NIC board cfg

2018-02-19 Thread Andrew Rybchenko
From: Andy Moreton 

Signed-off-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/ef10_nic.c | 18 +-
 drivers/net/sfc/base/hunt_nic.c | 36 ++--
 drivers/net/sfc/base/medford2_nic.c | 34 +-
 drivers/net/sfc/base/medford_nic.c  | 34 +-
 4 files changed, 45 insertions(+), 77 deletions(-)

diff --git a/drivers/net/sfc/base/ef10_nic.c b/drivers/net/sfc/base/ef10_nic.c
index ce99d09..5f4357b 100644
--- a/drivers/net/sfc/base/ef10_nic.c
+++ b/drivers/net/sfc/base/ef10_nic.c
@@ -1548,6 +1548,7 @@ ef10_nic_board_cfg(
const efx_nic_ops_t *enop = enp->en_enop;
efx_mcdi_iface_t *emip = &(enp->en_mcdi.em_emip);
efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
+   uint32_t board_type = 0;
uint32_t port;
uint32_t pf;
uint32_t vf;
@@ -1605,13 +1606,28 @@ ef10_nic_board_cfg(
 
EFX_MAC_ADDR_COPY(encp->enc_mac_addr, mac_addr);
 
+   /* Board configuration (legacy) */
+   rc = efx_mcdi_get_board_cfg(enp, &board_type, NULL, NULL);
+   if (rc != 0) {
+   /* Unprivileged functions may not be able to read board cfg */
+   if (rc == EACCES)
+   board_type = 0;
+   else
+   goto fail5;
+   }
+
+   encp->enc_board_type = board_type;
+   encp->enc_clk_mult = 1; /* not used for EF10 */
+
/* Get remaining controller-specific board config */
if ((rc = enop->eno_board_cfg(enp)) != 0)
if (rc != EACCES)
-   goto fail5;
+   goto fail6;
 
return (0);
 
+fail6:
+   EFSYS_PROBE(fail6);
 fail5:
EFSYS_PROBE(fail5);
 fail4:
diff --git a/drivers/net/sfc/base/hunt_nic.c b/drivers/net/sfc/base/hunt_nic.c
index 13f769c..58c2d13 100644
--- a/drivers/net/sfc/base/hunt_nic.c
+++ b/drivers/net/sfc/base/hunt_nic.c
@@ -77,7 +77,6 @@ hunt_board_cfg(
__inefx_nic_t *enp)
 {
efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
-   uint32_t board_type = 0;
ef10_link_state_t els;
efx_port_t *epp = &(enp->en_port);
uint32_t mask;
@@ -97,26 +96,13 @@ hunt_board_cfg(
EFX_STATIC_ASSERT(1U << EFX_VI_WINDOW_SHIFT_8K  == 8192);
encp->enc_vi_window_shift = EFX_VI_WINDOW_SHIFT_8K;
 
-   /* Board configuration */
-   rc = efx_mcdi_get_board_cfg(enp, &board_type, NULL, NULL);
-   if (rc != 0) {
-   /* Unprivileged functions may not be able to read board cfg */
-   if (rc == EACCES)
-   board_type = 0;
-   else
-   goto fail1;
-   }
-
-   encp->enc_board_type = board_type;
-   encp->enc_clk_mult = 1; /* not used for Huntington */
-
/* Fill out fields in enp->en_port and enp->en_nic_cfg from MCDI */
if ((rc = efx_mcdi_get_phy_cfg(enp)) != 0)
-   goto fail2;
+   goto fail1;
 
/* Obtain the default PHY advertised capabilities */
if ((rc = ef10_phy_get_link(enp, &els)) != 0)
-   goto fail3;
+   goto fail2;
epp->ep_default_adv_cap_mask = els.els_adv_cap_mask;
epp->ep_adv_cap_mask = els.els_adv_cap_mask;
 
@@ -147,7 +133,7 @@ hunt_board_cfg(
else if ((rc == ENOTSUP) || (rc == ENOENT))
encp->enc_bug35388_workaround = B_FALSE;
else
-   goto fail4;
+   goto fail3;
 
/*
 * If the bug41750 workaround is enabled, then do not test interrupts,
@@ -166,7 +152,7 @@ hunt_board_cfg(
} else if ((rc == ENOTSUP) || (rc == ENOENT)) {
encp->enc_bug41750_workaround = B_FALSE;
} else {
-   goto fail5;
+   goto fail4;
}
if (EFX_PCI_FUNCTION_IS_VF(encp)) {
/* Interrupt testing does not work for VFs. See bug50084. */
@@ -204,12 +190,12 @@ hunt_board_cfg(
} else if ((rc == ENOTSUP) || (rc == ENOENT)) {
encp->enc_bug26807_workaround = B_FALSE;
} else {
-   goto fail6;
+   goto fail5;
}
 
/* Get clock frequencies (in MHz). */
if ((rc = efx_mcdi_get_clock(enp, &sysclk, &dpcpu_clk)) != 0)
-   goto fail7;
+   goto fail6;
 
/*
 * The Huntington timer quantum is 1536 sysclk cycles, documented for
@@ -228,7 +214,7 @@ hunt_board_cfg(
 
/* Check capabilities of running datapath firmware */
if ((rc = ef10_get_datapath_caps(enp)) != 0)
-   goto fail8;
+   goto fail7;
 
/* Alignment for receive packet DMA buffers */
encp->enc_rx_buf_align_start = 1;
@@ -278,13 +264,13 @@ hunt_board_cfg(
 * can result in time-of-check/time-of-use bugs.
 */
if ((rc = ef10_get_privilege_mask(enp, &mask)) != 0)
-   goto fail9;
+  

[dpdk-dev] [PATCH 28/80] net/sfc/base: fix too long line

2018-02-19 Thread Andrew Rybchenko
Fixes: 6f619653b9b1 ("net/sfc/base: import MCDI implementation")

Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/efx_mcdi.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/sfc/base/efx_mcdi.c b/drivers/net/sfc/base/efx_mcdi.c
index 8156acc..9d7b741 100644
--- a/drivers/net/sfc/base/efx_mcdi.c
+++ b/drivers/net/sfc/base/efx_mcdi.c
@@ -1436,6 +1436,7 @@ efx_mcdi_get_phy_cfg(
const char *namep;
size_t namelen;
 #endif
+   uint32_t phy_media_type;
efx_rc_t rc;
 
(void) memset(payload, 0, sizeof (payload));
@@ -1486,8 +1487,8 @@ efx_mcdi_get_phy_cfg(
EFX_STATIC_ASSERT(MC_CMD_MEDIA_SFP_PLUS == EFX_PHY_MEDIA_SFP_PLUS);
EFX_STATIC_ASSERT(MC_CMD_MEDIA_BASE_T == EFX_PHY_MEDIA_BASE_T);
EFX_STATIC_ASSERT(MC_CMD_MEDIA_QSFP_PLUS == EFX_PHY_MEDIA_QSFP_PLUS);
-   epp->ep_fixed_port_type =
-   (efx_phy_media_type_t) MCDI_OUT_DWORD(req, 
GET_PHY_CFG_OUT_MEDIA_TYPE);
+   phy_media_type = MCDI_OUT_DWORD(req, GET_PHY_CFG_OUT_MEDIA_TYPE);
+   epp->ep_fixed_port_type = (efx_phy_media_type_t)phy_media_type;
if (epp->ep_fixed_port_type >= EFX_PHY_MEDIA_NTYPES)
epp->ep_fixed_port_type = EFX_PHY_MEDIA_INVALID;
 
-- 
2.7.4



[dpdk-dev] [PATCH 27/80] net/sfc/base: refactoring eliminating code analysis warnings

2018-02-19 Thread Andrew Rybchenko
From: Richard Houldsworth 

Addresses most of the warnings reported by the sfn windows driver.

Signed-off-by: Richard Houldsworth 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/ef10_mcdi.c   | 12 
 drivers/net/sfc/base/ef10_nvram.c  | 10 +++---
 drivers/net/sfc/base/ef10_vpd.c|  9 ++---
 drivers/net/sfc/base/efx_filter.c  |  1 +
 drivers/net/sfc/base/efx_mcdi.c| 14 ++
 drivers/net/sfc/base/efx_phy.c |  1 +
 drivers/net/sfc/base/siena_mcdi.c  | 12 
 drivers/net/sfc/base/siena_nvram.c | 17 -
 drivers/net/sfc/base/siena_vpd.c   | 25 -
 9 files changed, 69 insertions(+), 32 deletions(-)

diff --git a/drivers/net/sfc/base/ef10_mcdi.c b/drivers/net/sfc/base/ef10_mcdi.c
index b533033..8a3fc3b 100644
--- a/drivers/net/sfc/base/ef10_mcdi.c
+++ b/drivers/net/sfc/base/ef10_mcdi.c
@@ -188,13 +188,17 @@ ef10_mcdi_read_response(
 {
const efx_mcdi_transport_t *emtp = enp->en_mcdi.em_emtp;
efsys_mem_t *esmp = emtp->emt_dma_mem;
-   unsigned int pos;
+   unsigned int pos = 0;
efx_dword_t data;
+   size_t remaining = length;
+
+   while (remaining > 0) {
+   size_t chunk = MIN(remaining, sizeof (data));
 
-   for (pos = 0; pos < length; pos += sizeof (efx_dword_t)) {
EFSYS_MEM_READD(esmp, offset + pos, &data);
-   memcpy((uint8_t *)bufferp + pos, &data,
-   MIN(sizeof (data), length - pos));
+   memcpy((uint8_t *)bufferp + pos, &data, chunk);
+   pos += chunk;
+   remaining -= chunk;
}
 }
 
diff --git a/drivers/net/sfc/base/ef10_nvram.c 
b/drivers/net/sfc/base/ef10_nvram.c
index 6c670f2..2883ec8 100644
--- a/drivers/net/sfc/base/ef10_nvram.c
+++ b/drivers/net/sfc/base/ef10_nvram.c
@@ -1349,12 +1349,16 @@ ef10_nvram_partn_read_tlv(
 */
retry = 10;
do {
-   rc = ef10_nvram_read_tlv_segment(enp, partn, 0,
-   seg_data, partn_size);
-   } while ((rc == EAGAIN) && (--retry > 0));
+   if ((rc = ef10_nvram_read_tlv_segment(enp, partn, 0,
+   seg_data, partn_size)) != 0)
+   --retry;
+   } while ((rc == EAGAIN) && (retry > 0));
 
if (rc != 0) {
/* Failed to obtain consistent segment data */
+   if (rc == EAGAIN)
+   rc = EIO;
+
goto fail4;
}
 
diff --git a/drivers/net/sfc/base/ef10_vpd.c b/drivers/net/sfc/base/ef10_vpd.c
index f71bad3..097fe1d 100644
--- a/drivers/net/sfc/base/ef10_vpd.c
+++ b/drivers/net/sfc/base/ef10_vpd.c
@@ -136,19 +136,22 @@ ef10_vpd_read(
rc = ENOSPC;
goto fail2;
}
-   memcpy(data, dvpd, dvpd_size);
+   if (dvpd != NULL)
+   memcpy(data, dvpd, dvpd_size);
 
/* Pad data with all-1s, consistent with update operations */
memset(data + dvpd_size, 0xff, size - dvpd_size);
 
-   EFSYS_KMEM_FREE(enp->en_esip, dvpd_size, dvpd);
+   if (dvpd != NULL)
+   EFSYS_KMEM_FREE(enp->en_esip, dvpd_size, dvpd);
 
return (0);
 
 fail2:
EFSYS_PROBE(fail2);
 
-   EFSYS_KMEM_FREE(enp->en_esip, dvpd_size, dvpd);
+   if (dvpd != NULL)
+   EFSYS_KMEM_FREE(enp->en_esip, dvpd_size, dvpd);
 fail1:
EFSYS_PROBE1(fail1, efx_rc_t, rc);
 
diff --git a/drivers/net/sfc/base/efx_filter.c 
b/drivers/net/sfc/base/efx_filter.c
index e31accb..8705369 100644
--- a/drivers/net/sfc/base/efx_filter.c
+++ b/drivers/net/sfc/base/efx_filter.c
@@ -959,6 +959,7 @@ siena_filter_build(
 
default:
EFSYS_ASSERT(B_FALSE);
+   EFX_ZERO_OWORD(*filter);
return (0);
}
 
diff --git a/drivers/net/sfc/base/efx_mcdi.c b/drivers/net/sfc/base/efx_mcdi.c
index 254eb00..8156acc 100644
--- a/drivers/net/sfc/base/efx_mcdi.c
+++ b/drivers/net/sfc/base/efx_mcdi.c
@@ -1432,6 +1432,10 @@ efx_mcdi_get_phy_cfg(
efx_mcdi_req_t req;
uint8_t payload[MAX(MC_CMD_GET_PHY_CFG_IN_LEN,
MC_CMD_GET_PHY_CFG_OUT_LEN)];
+#if EFSYS_OPT_NAMES
+   const char *namep;
+   size_t namelen;
+#endif
efx_rc_t rc;
 
(void) memset(payload, 0, sizeof (payload));
@@ -1455,10 +1459,12 @@ efx_mcdi_get_phy_cfg(
 
encp->enc_phy_type = MCDI_OUT_DWORD(req, GET_PHY_CFG_OUT_TYPE);
 #if EFSYS_OPT_NAMES
-   (void) strncpy(encp->enc_phy_name,
-   MCDI_OUT2(req, char, GET_PHY_CFG_OUT_NAME),
-   MIN(sizeof (encp->enc_phy_name) - 1,
-   MC_CMD_GET_PHY_CFG_OUT_NAME_LEN));
+   namep = MCDI_OUT2(req, char, GET_PHY_CFG_OUT_NAME);
+   namelen = MIN(sizeof (encp->enc_phy_name) - 1,
+   strnlen(namep, MC_CMD_GET_PHY_CFG_OUT_NAME_LEN));
+   (void) memset(encp->enc_phy_name, 0,
+   sizeof (encp->enc_phy_name));
+   memcpy(encp->enc_phy_name, name

[dpdk-dev] [PATCH 69/80] net/sfc/base: add 1.3V voltage and current sensors

2018-02-19 Thread Andrew Rybchenko
From: Andy Moreton 

Signed-off-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/efx.h  | 4 +++-
 drivers/net/sfc/base/efx_mon.c  | 4 +++-
 drivers/net/sfc/base/mcdi_mon.c | 4 
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/net/sfc/base/efx.h b/drivers/net/sfc/base/efx.h
index 33e7875..3f86213 100644
--- a/drivers/net/sfc/base/efx.h
+++ b/drivers/net/sfc/base/efx.h
@@ -627,7 +627,7 @@ efx_mon_init(
 #defineEFX_MON_STATS_PAGE_SIZE 0x100
 #defineEFX_MON_MASK_ELEMENT_SIZE 32
 
-/* START MKCONFIG GENERATED MonitorHeaderStatsBlock fcc1b6748432e1ac */
+/* START MKCONFIG GENERATED MonitorHeaderStatsBlock 400fdb0517af1fca */
 typedef enum efx_mon_stat_e {
EFX_MON_STAT_2_5V,
EFX_MON_STAT_VCCP1,
@@ -710,6 +710,8 @@ typedef enum efx_mon_stat_e {
EFX_MON_STAT_I2V5,
EFX_MON_STAT_I3V3,
EFX_MON_STAT_I12V0,
+   EFX_MON_STAT_1_3V,
+   EFX_MON_STAT_I1V3,
EFX_MON_NSTATS
 } efx_mon_stat_t;
 
diff --git a/drivers/net/sfc/base/efx_mon.c b/drivers/net/sfc/base/efx_mon.c
index ac8d7e9..9fc268e 100644
--- a/drivers/net/sfc/base/efx_mon.c
+++ b/drivers/net/sfc/base/efx_mon.c
@@ -99,7 +99,7 @@ efx_mon_init(
 
 #if EFSYS_OPT_NAMES
 
-/* START MKCONFIG GENERATED MonitorStatNamesBlock a808884b01444549 */
+/* START MKCONFIG GENERATED MonitorStatNamesBlock 8150a068198c0f96 */
 static const char * const __mon_stat_name[] = {
"value_2_5v",
"value_vccp1",
@@ -182,6 +182,8 @@ static const char * const __mon_stat_name[] = {
"i2v5",
"i3v3",
"i12v0",
+   "1v3",
+   "i1v3",
 };
 
 /* END MKCONFIG GENERATED MonitorStatNamesBlock */
diff --git a/drivers/net/sfc/base/mcdi_mon.c b/drivers/net/sfc/base/mcdi_mon.c
index 0e44577..940bd02 100644
--- a/drivers/net/sfc/base/mcdi_mon.c
+++ b/drivers/net/sfc/base/mcdi_mon.c
@@ -135,6 +135,10 @@ static const struct mcdi_sensor_map_s {
STAT(Px, BOARD_BACK_TEMP),  /* 0x50 BOARD_BACK_TEMP */
STAT(Px, I1V8), /* 0x51 IN_I1V8 */
STAT(Px, I2V5), /* 0x52 IN_I2V5 */
+   STAT(Px, I3V3), /* 0x53 IN_I3V3 */
+   STAT(Px, I12V0),/* 0x54 IN_I12V0 */
+   STAT(Px, 1_3V), /* 0x55 IN_1V3 */
+   STAT(Px, I1V3), /* 0x56 IN_I1V3 */
 };
 
 #defineMCDI_STATIC_SENSOR_ASSERT(_field)   
\
-- 
2.7.4



[dpdk-dev] [PATCH 66/80] net/sfc/base: add Medford2 support for licencing

2018-02-19 Thread Andrew Rybchenko
From: Andy Moreton 

Signed-off-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/efx_lic.c | 23 ---
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/drivers/net/sfc/base/efx_lic.c b/drivers/net/sfc/base/efx_lic.c
index bfad0cd..49c0034 100644
--- a/drivers/net/sfc/base/efx_lic.c
+++ b/drivers/net/sfc/base/efx_lic.c
@@ -165,7 +165,7 @@ static const efx_lic_ops_t  __efx_lic_v2_ops = {
 
 #endif /* EFSYS_OPT_HUNTINGTON */
 
-#if EFSYS_OPT_MEDFORD
+#if EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2
 
 static __checkReturn   efx_rc_t
 efx_mcdi_licensing_v3_update_licenses(
@@ -289,7 +289,7 @@ static const efx_lic_ops_t  __efx_lic_v3_ops = {
efx_lic_v3_finish_partition,/* elo_finish_partition */
 };
 
-#endif /* EFSYS_OPT_MEDFORD */
+#endif /* EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2 */
 
 
 /* V1 Licensing - used in Siena Modena only */
@@ -822,7 +822,7 @@ efx_mcdi_licensing_get_key_stats(
 
 /* V3 Licensing - used starting from Medford family. See SF-114884-SW */
 
-#if EFSYS_OPT_MEDFORD
+#if EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2
 
 static __checkReturn   efx_rc_t
 efx_mcdi_licensing_v3_update_licenses(
@@ -832,7 +832,8 @@ efx_mcdi_licensing_v3_update_licenses(
uint8_t payload[MC_CMD_LICENSING_V3_IN_LEN];
efx_rc_t rc;
 
-   EFSYS_ASSERT(enp->en_family == EFX_FAMILY_MEDFORD);
+   EFSYS_ASSERT((enp->en_family == EFX_FAMILY_MEDFORD) ||
+   (enp->en_family == EFX_FAMILY_MEDFORD2));
 
(void) memset(payload, 0, sizeof (payload));
req.emr_cmd = MC_CMD_LICENSING_V3;
@@ -869,7 +870,8 @@ efx_mcdi_licensing_v3_report_license(
MC_CMD_LICENSING_V3_OUT_LEN)];
efx_rc_t rc;
 
-   EFSYS_ASSERT(enp->en_family == EFX_FAMILY_MEDFORD);
+   EFSYS_ASSERT((enp->en_family == EFX_FAMILY_MEDFORD) ||
+   (enp->en_family == EFX_FAMILY_MEDFORD2));
 
(void) memset(payload, 0, sizeof (payload));
req.emr_cmd = MC_CMD_LICENSING_V3;
@@ -933,7 +935,8 @@ efx_mcdi_licensing_v3_app_state(
uint32_t app_state;
efx_rc_t rc;
 
-   EFSYS_ASSERT(enp->en_family == EFX_FAMILY_MEDFORD);
+   EFSYS_ASSERT((enp->en_family == EFX_FAMILY_MEDFORD) ||
+   (enp->en_family == EFX_FAMILY_MEDFORD2));
 
(void) memset(payload, 0, sizeof (payload));
req.emr_cmd = MC_CMD_GET_LICENSED_V3_APP_STATE;
@@ -1265,7 +1268,7 @@ efx_lic_v3_finish_partition(
 }
 
 
-#endif /* EFSYS_OPT_MEDFORD */
+#endif /* EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2 */
 
__checkReturn   efx_rc_t
 efx_lic_init(
@@ -1299,6 +1302,12 @@ efx_lic_init(
break;
 #endif /* EFSYS_OPT_MEDFORD */
 
+#if EFSYS_OPT_MEDFORD2
+   case EFX_FAMILY_MEDFORD2:
+   elop = &__efx_lic_v3_ops;
+   break;
+#endif /* EFSYS_OPT_MEDFORD2 */
+
default:
EFSYS_ASSERT(0);
rc = ENOTSUP;
-- 
2.7.4



[dpdk-dev] [PATCH 62/80] net/sfc/base: support Medford2 event timer semantics

2018-02-19 Thread Andrew Rybchenko
From: Andy Moreton 

The event timer interface has changed for Medford2 - for
details see bug66418 comment 9. Update the common code to
use the new timer semantics for Medford2.

Signed-off-by: Andy Moreton 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/base/ef10_ev.c   | 10 --
 drivers/net/sfc/base/efx_regs_ef10.h |  6 ++
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/net/sfc/base/ef10_ev.c b/drivers/net/sfc/base/ef10_ev.c
index 256156b..6e00099 100644
--- a/drivers/net/sfc/base/ef10_ev.c
+++ b/drivers/net/sfc/base/ef10_ev.c
@@ -705,9 +705,15 @@ ef10_ev_qmoderate(
EFX_BAR_VI_WRITED(enp, ER_DD_EVQ_INDIRECT,
eep->ee_index, &dword, 0);
} else {
-   EFX_POPULATE_DWORD_2(dword,
+   /*
+* NOTE: The TMR_REL field introduced in Medford2 is
+* ignored on earlier EF10 controllers. See bug66418
+* comment 9 for details.
+*/
+   EFX_POPULATE_DWORD_3(dword,
ERF_DZ_TC_TIMER_MODE, mode,
-   ERF_DZ_TC_TIMER_VAL, ticks);
+   ERF_DZ_TC_TIMER_VAL, ticks,
+   ERF_FZ_TC_TMR_REL_VAL, ticks);
EFX_BAR_VI_WRITED(enp, ER_DZ_EVQ_TMR_REG,
eep->ee_index, &dword, 0);
}
diff --git a/drivers/net/sfc/base/efx_regs_ef10.h 
b/drivers/net/sfc/base/efx_regs_ef10.h
index a832ce7..2cb96e8 100644
--- a/drivers/net/sfc/base/efx_regs_ef10.h
+++ b/drivers/net/sfc/base/efx_regs_ef10.h
@@ -156,6 +156,8 @@ extern "C" {
 #defineER_FZ_EVQ_TMR_REG_64K_RESET 0x0
 
 
+#defineERF_FZ_TC_TMR_REL_VAL_LBN 16
+#defineERF_FZ_TC_TMR_REL_VAL_WIDTH 14
 #defineERF_FZ_TC_TIMER_MODE_LBN 14
 #defineERF_FZ_TC_TIMER_MODE_WIDTH 2
 #defineERF_FZ_TC_TIMER_VAL_LBN 0
@@ -174,6 +176,8 @@ extern "C" {
 #defineER_FZ_EVQ_TMR_REG_16K_RESET 0x0
 
 
+/* defined as ERF_FZ_TC_TMR_REL_VAL_LBN 16; */
+/* defined as ERF_FZ_TC_TMR_REL_VAL_WIDTH 14 */
 /* defined as ERF_FZ_TC_TIMER_MODE_LBN 14; */
 /* defined as ERF_FZ_TC_TIMER_MODE_WIDTH 2 */
 /* defined as ERF_FZ_TC_TIMER_VAL_LBN 0; */
@@ -192,6 +196,8 @@ extern "C" {
 #defineER_DZ_EVQ_TMR_REG_RESET 0x0
 
 
+/* defined as ERF_FZ_TC_TMR_REL_VAL_LBN 16; */
+/* defined as ERF_FZ_TC_TMR_REL_VAL_WIDTH 14 */
 #defineERF_DZ_TC_TIMER_MODE_LBN 14
 #defineERF_DZ_TC_TIMER_MODE_WIDTH 2
 #defineERF_DZ_TC_TIMER_VAL_LBN 0
-- 
2.7.4



  1   2   >