Re: [PATCH net] bnxt_en: don't try to offload VLAN 'modify' action

2018-09-19 Thread Sathya Perla
On Wed, Sep 19, 2018 at 10:31 PM Davide Caratti  wrote:
>
> bnxt offload code currently supports only 'push' and 'pop' operation: let
> .ndo_setup_tc() return -EOPNOTSUPP if VLAN 'modify' action is configured.
>
> Fixes: 2ae7408fedfe ("bnxt_en: bnxt: add TC flower filter offload support")
> Signed-off-by: Davide Caratti 

Acked-by: Sathya Perla 

Thanks!


Re: [benet] possible endianness bug in be_cmd_txq_create()

2018-01-28 Thread Sathya Perla
On Sun, Dec 10, 2017 at 10:11 PM, Al Viro  wrote:
>
> In be_cmd_txq_create() we have
> if (req->hdr.version > 0)
> req->if_id = cpu_to_le16(adapter->if_handle);
> req->num_pages = PAGES_4K_SPANNED(q_mem->va, q_mem->size);
> req->ulp_num = BE_ULP1_NUM;
> req->type = BE_ETH_TX_RING_TYPE_STANDARD;
> req->cq_id = cpu_to_le16(cq->id);
> req->queue_size = be_encoded_q_len(txq->len);
> be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem);
> ver = req->hdr.version;
>
...
>
> Everything appears to be consistent with little-endian data - direct
> assignments to u8 fields, cpu_to_le16 for cq_id and if_id, phys_addr
> array is also filled with little-endian data, so's ->hdr (several
> lines prior, by be_wrb_cmd_hdr_prepare()).
>
> The only exception is
> req->type = BE_ETH_TX_RING_TYPE_STANDARD;
> where we set a 16bit field with host-endian constant (2).
>
..
>
> So it really smells like this line should've been
> req->type = cpu_to_le16(BE_ETH_TX_RING_TYPE_STANDARD);
>
Sorry for replying late...I missed this mail. I guess the old
@emulex.com email ids don't work anymore -- it's @broadcom.com now!
Yes, this does look like a bug; we'll send a patch to fix this.

Thanks!


Re: [PATCH] cls_flower: check if filter is in HW before calling fl_hw_destroy_filter()

2018-01-24 Thread Sathya Perla
On Wed, Jan 24, 2018 at 9:37 PM, Jiri Pirko  wrote:
> Wed, Jan 24, 2018 at 12:42:55PM CET, sathya.pe...@broadcom.com wrote:
>>When a filter cannot be added in HW (i.e, fl_hw_replace_filter() returns
>>error), the TCA_CLS_FLAGS_IN_HW flag is not set in the filter flags.
>>
>>This flag (via tc_in_hw()) must be checked before issuing the call
>>to delete a filter in HW (fl_hw_destroy_filter()) and before issuing the
>>call to query stats (fl_hw_update_stats()).
>>
>>Signed-off-by: Sathya Perla 
>
> 1) You have to indicate what tree you aim this to be applied on:
>[patch net] or [patch net-next]
> 2) Please provided a "Fixes" line
> 3) Please use scripts/get_maintainer.pl to get the people to cc
> 4) Please aim the fix not only to cls_flower, but to other cls as well.

Ok, will do. thanks!


Re: [PATCH] cls_flower: check if filter is in HW before calling fl_hw_destroy_filter()

2018-01-24 Thread Sathya Perla
On Thu, Jan 25, 2018 at 3:53 AM, Jakub Kicinski  wrote:
>
> On Wed, 24 Jan 2018 17:12:55 +0530, Sathya Perla wrote:
> > When a filter cannot be added in HW (i.e, fl_hw_replace_filter() returns
> > error), the TCA_CLS_FLAGS_IN_HW flag is not set in the filter flags.
> >
> > This flag (via tc_in_hw()) must be checked before issuing the call
> > to delete a filter in HW (fl_hw_destroy_filter()) and before issuing the
> > call to query stats (fl_hw_update_stats()).
> >
> > Signed-off-by: Sathya Perla 
>
> Could you explain why you want to make that change?  Saying "tc_in_hw()
> must be checked" is a bit strong, tc_in_hw() is useless from correctness
> POV.  Your patch may be a good optimization, but with shared blocks in
> the picture now tc_in_hw() == true doesn't mean it's in *your* HW.

I agree that for shared filters when skip_sw is false
tcf_block_cb_call() can return a
positive status even if the filter add on one of the devices fails.
I'll change the commit-log wording to indicate that this new check is
an optimization.
Thanks!


[PATCH] cls_flower: check if filter is in HW before calling fl_hw_destroy_filter()

2018-01-24 Thread Sathya Perla
When a filter cannot be added in HW (i.e, fl_hw_replace_filter() returns
error), the TCA_CLS_FLAGS_IN_HW flag is not set in the filter flags.

This flag (via tc_in_hw()) must be checked before issuing the call
to delete a filter in HW (fl_hw_destroy_filter()) and before issuing the
call to query stats (fl_hw_update_stats()).

Signed-off-by: Sathya Perla 
---
 net/sched/cls_flower.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c
index 6132a73..dbcfb52 100644
--- a/net/sched/cls_flower.c
+++ b/net/sched/cls_flower.c
@@ -286,7 +286,7 @@ static void __fl_delete(struct tcf_proto *tp, struct 
cls_fl_filter *f)
 
idr_remove_ext(&head->handle_idr, f->handle);
list_del_rcu(&f->list);
-   if (!tc_skip_hw(f->flags))
+   if (tc_in_hw(f->flags))
fl_hw_destroy_filter(tp, f);
tcf_unbind_filter(tp, &f->res);
if (tcf_exts_get_net(&f->exts))
@@ -951,7 +951,7 @@ static int fl_change(struct net *net, struct sk_buff 
*in_skb,
if (!tc_skip_sw(fold->flags))
rhashtable_remove_fast(&head->ht, &fold->ht_node,
   head->ht_params);
-   if (!tc_skip_hw(fold->flags))
+   if (tc_in_hw(fold->flags))
fl_hw_destroy_filter(tp, fold);
}
 
@@ -1170,7 +1170,7 @@ static int fl_dump(struct net *net, struct tcf_proto *tp, 
void *fh,
goto nla_put_failure;
}
 
-   if (!tc_skip_hw(f->flags))
+   if (tc_in_hw(f->flags))
fl_hw_update_stats(tp, f);
 
if (fl_dump_key_val(skb, key->eth.dst, TCA_FLOWER_KEY_ETH_DST,
-- 
2.7.4



[net PATCH] bnxt_en: check for ingress qdisc in flower offload

2017-09-18 Thread Sathya Perla
Check for ingress-only qdisc for flower offload, as other qdiscs
are not supported for flower offload.

Suggested-by: Jiri Pirko 
Signed-off-by: Sathya Perla 
---
 drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c 
b/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c
index ccd699f..7dd3d13 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c
@@ -750,6 +750,10 @@ int bnxt_tc_setup_flower(struct bnxt *bp, u16 src_fid,
 {
int rc = 0;
 
+   if (!is_classid_clsact_ingress(cls_flower->common.classid) ||
+   cls_flower->common.chain_index)
+   return -EOPNOTSUPP;
+
switch (cls_flower->command) {
case TC_CLSFLOWER_REPLACE:
rc = bnxt_tc_add_flow(bp, src_fid, cls_flower);
-- 
2.7.4



[PATCH net-next] bnxt_en: add a dummy definition for bnxt_vf_rep_get_fid()

2017-08-28 Thread Sathya Perla
When bnxt VF-reps are not compiled in (CONFIG_BNXT_SRIOV is off)
bnxt_tc.c needs a dummy definition of the routine bnxt_vf_rep_get_fid().

Reported-by: kbuild test robot 
Fixes: 2ae7408fedfe ("bnxt_en: bnxt: add TC flower filter offload support")
Signed-off-by: Sathya Perla 
---
 drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.h | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.h 
b/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.h
index d8b5f89..7787cd24 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.h
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.h
@@ -80,5 +80,10 @@ static inline struct net_device *bnxt_get_vf_rep(struct bnxt 
*bp, u16 cfa_code)
 {
return NULL;
 }
+
+static inline u16 bnxt_vf_rep_get_fid(struct net_device *dev)
+{
+   return 0;
+}
 #endif /* CONFIG_BNXT_SRIOV */
 #endif /* BNXT_VFR_H */
-- 
2.7.4



[PATCH net-next] bnxt_re: add MAY_USE_DEVLINK dependency

2017-07-27 Thread Sathya Perla
bnxt_en depends on MAY_USE_DEVLINK; this is used to force bnxt_en
to be =m when DEVLINK is =m.

Now, bnxt_re selects bnxt_en. Unless bnxt_re also explicitly calls
out dependency on MAY_USE_DEVLINK, Kconfig does not force bnxt_re
to be =m when DEVLINK is =m, causing the following error:

drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.o: In function
`bnxt_dl_register':
bnxt_vfr.c:(.text+0x1440): undefined reference to `devlink_alloc'
bnxt_vfr.c:(.text+0x14c0): undefined reference to `devlink_register'
bnxt_vfr.c:(.text+0x14e0): undefined reference to `devlink_free'
drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.o: In function
`bnxt_dl_unregister':
bnxt_vfr.c:(.text+0x1534): undefined reference to `devlink_unregister'
bnxt_vfr.c:(.text+0x153c): undefined reference to `devlink_free'

Fix this by adding MAY_USE_DEVLINK dependency in bnxt_re.

Fixes: 4ab0c6a8ffd7 ("bnxt_en: add support to enable VF-representors")
Suggested-by: Arnd Bergmann 
Signed-off-by: Sathya Perla 
---
 drivers/infiniband/hw/bnxt_re/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/infiniband/hw/bnxt_re/Kconfig 
b/drivers/infiniband/hw/bnxt_re/Kconfig
index 19982a4..18f5ed0 100644
--- a/drivers/infiniband/hw/bnxt_re/Kconfig
+++ b/drivers/infiniband/hw/bnxt_re/Kconfig
@@ -1,6 +1,7 @@
 config INFINIBAND_BNXT_RE
 tristate "Broadcom Netxtreme HCA support"
 depends on ETHERNET && NETDEVICES && PCI && INET && DCB
+depends on MAY_USE_DEVLINK
 select NET_VENDOR_BROADCOM
 select BNXT
 ---help---
-- 
1.8.3.1



Re: [PATCH net-next 2/2] bnxt_en: define sriov_lock unconditionally

2017-07-27 Thread Sathya Perla
On Thu, Jul 27, 2017 at 1:18 PM, Arnd Bergmann  wrote:
[...]
>
> On today's linux-next:
>
> drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.o: In function `bnxt_dl_register':
> bnxt_vfr.c:(.text+0x1440): undefined reference to `devlink_alloc'
> bnxt_vfr.c:(.text+0x14c0): undefined reference to `devlink_register'
> bnxt_vfr.c:(.text+0x14e0): undefined reference to `devlink_free'
> drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.o: In function 
> `bnxt_dl_unregister':
> bnxt_vfr.c:(.text+0x1534): undefined reference to `devlink_unregister'
> bnxt_vfr.c:(.text+0x153c): undefined reference to `devlink_free'
>
> I think you are just missing a "depends on MAY_USE_DEVLINK"
> in INFINIBAND_BNXT_RE, which uses 'select BNXT'.
>
> This is a tricky corner case for Kconfig, where the MAY_USE_DEVLINK
> dependency is silently ignored for BNXT as long as MAY_USE_DEVLINK
> is not "=n".

Can you pls share your .config so that I can reproduce this issue and
ensure that my fix really works...


Re: [PATCH net-next 2/2] bnxt_en: define sriov_lock unconditionally

2017-07-26 Thread Sathya Perla
On Wed, Jul 26, 2017 at 2:35 PM, Arnd Bergmann  wrote:
[...]
>> Sathya already sent 3 patches to fix some of these issues.  But I need
>> to rework one of his patch and resend.
>
> Ok, thanks. I just ran into one more issue, and don't know if that's included
> as well. If not, please also add the patch below (or fold it into the one
> that adds the switchdev dependency to the ethernet driver):
>
> 8<--
> Subject: [PATCH] RDMA/bnxt_re: add NET_SWITCHDEV dependency
>
> The rdma side of BNXT enables the ethernet driver and has a list
> of its dependencies. However, the ethernet driver now also depends
> on NET_SWITCHDEV, so we have to add that dependency for both:

Arnd, after the patch "bnxt_en: use SWITCHDEV_SET_OPS() for setting
vf_rep_switchdev_ops" the bnxt_en driver doesn't need an explicit
NET_SWITCHDEV dependency. So, the bnxt_re driver shouldn't need one
either. Are you still seeing the bnxt_re issue even after pulling the
above patch??


[PATCH net-next 2/3] bnxt_en: use SWITCHDEV_SET_OPS() for setting vf_rep_switchdev_ops

2017-07-25 Thread Sathya Perla
This fixes the build error:
‘struct net_device’ has no member named ‘switchdev_ops’

Reported-by: kbuild test robot 
Fixes: c124a62ff2dd ("bnxt_en: add support for port_attr_get and and 
get_phys_port_name")
Signed-off-by: Sathya Perla 
---
 drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c 
b/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c
index 86850ae..9ba505f 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c
@@ -304,7 +304,7 @@ static void bnxt_vf_rep_netdev_init(struct bnxt *bp, struct 
bnxt_vf_rep *vf_rep,
 
dev->netdev_ops = &bnxt_vf_rep_netdev_ops;
dev->ethtool_ops = &bnxt_vf_rep_ethtool_ops;
-   dev->switchdev_ops = &bnxt_vf_rep_switchdev_ops;
+   SWITCHDEV_SET_OPS(dev, &bnxt_vf_rep_switchdev_ops);
/* Just inherit all the featues of the parent PF as the VF-R
 * uses the RX/TX rings of the parent PF
 */
-- 
1.8.3.1



[PATCH net-next 3/3] bnxt_en: fix switchdev port naming for external-port-rep and vf-reps

2017-07-25 Thread Sathya Perla
Fix the phys_port_name for the external physical port to be in
"pA" format and that of VF-rep to be in "pCvfD" format as
suggested by Jakub Kicinski.

Fixes: c124a62ff2dd ("bnxt_en: add support for port_attr_get and 
get_phys_port_name")
Signed-off-by: Sathya Perla 
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 6 +-
 drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c | 4 +++-
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c 
b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index badbc35..4b32cf0 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -7556,11 +7556,7 @@ static int bnxt_get_phys_port_name(struct net_device 
*dev, char *buf,
if (!BNXT_PF(bp))
return -EOPNOTSUPP;
 
-   /* The switch-id that the pf belongs to is exported by
-* the switchdev ndo. This name is just to distinguish from the
-* vf-rep ports.
-*/
-   rc = snprintf(buf, len, "pf%d", bp->pf.port_id);
+   rc = snprintf(buf, len, "p%d", bp->pf.port_id);
 
if (rc >= len)
return -EOPNOTSUPP;
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c 
b/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c
index 9ba505f..9419590 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c
@@ -141,9 +141,11 @@ static int bnxt_vf_rep_get_phys_port_name(struct 
net_device *dev, char *buf,
  size_t len)
 {
struct bnxt_vf_rep *vf_rep = netdev_priv(dev);
+   struct pci_dev *pf_pdev = vf_rep->bp->pdev;
int rc;
 
-   rc = snprintf(buf, len, "vfr%d", vf_rep->vf_idx);
+   rc = snprintf(buf, len, "pf%dvf%d", PCI_FUNC(pf_pdev->devfn),
+ vf_rep->vf_idx);
if (rc >= len)
return -EOPNOTSUPP;
return 0;
-- 
1.8.3.1



[PATCH net-next 1/3] bnxt_en: include bnxt_vfr.c code under CONFIG_BNXT_SRIOV switch

2017-07-25 Thread Sathya Perla
This fixes build error when CONFIG_BNXT_SRIOV is switched off:
>> drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c:165:16: error: 'struct
>> bnxt' has no member named 'sriov_lock'

Reported-by: kbuild test robot 
Fixes: 4ab0c6a8ffd7 ("bnxt_en: add support to enable VF-representors")
Signed-off-by: Sathya Perla 
---
 drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c 
b/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c
index 83478e9..86850ae 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c
@@ -16,6 +16,8 @@
 #include "bnxt.h"
 #include "bnxt_vfr.h"
 
+#ifdef CONFIG_BNXT_SRIOV
+
 #define CFA_HANDLE_INVALID 0x
 #define VF_IDX_INVALID 0x
 
@@ -487,3 +489,5 @@ void bnxt_dl_unregister(struct bnxt *bp)
devlink_unregister(dl);
devlink_free(dl);
 }
+
+#endif /* CONFIG_BNXT_SRIOV */
-- 
1.8.3.1



Re: [PATCH net-next 10/10] bnxt_en: add support for port_attr_get and and get_phys_port_name

2017-07-25 Thread Sathya Perla
On Tue, Jul 25, 2017 at 10:15 AM, Jakub Kicinski  wrote:
...
>> +static int bnxt_get_phys_port_name(struct net_device *dev, char *buf,
>> +size_t len)
>> +{
>> + struct bnxt *bp = netdev_priv(dev);
>> + int rc;
>> +
>> + /* The PF and it's VF-reps only support the switchdev framework */
>> + if (!BNXT_PF(bp))
>> + return -EOPNOTSUPP;
>> +
>> + /* The switch-id that the pf belongs to is exported by
>> +  * the switchdev ndo. This name is just to distinguish from the
>> +  * vf-rep ports.
>> +  */
>> + rc = snprintf(buf, len, "pf%d", bp->pf.port_id);
>
> This is worrisome.  What do you mean by PF?  In my experience, since
> for years PFs had one-to-one association with physical ports people use
> the terms interchangeably.  This causes a lot of headaches in proper
> eswitch modelling.
>
> I'm not sure whether this is a HW limitation or engineers trying to
> make things "easy for users" but most VF-representor patchsets we've
> seen on netdev don't include PF representors.  NICs have 3 types of
> ports - PFs, VFs and external ports/MACs.  For some reason there is a
> tendency to keep pretending PF and physical port is the same entity,
> which among other things makes it impossible to install VF->PF rules
> (as in from VF to the host, not to the network).
>
> Most high performance NIC vendors also have multi-PF NICs, even though
> those are not deployed by wider public.  If we keep pretending PF is
> the external port, those will get very awkward to model.  This is a bit
> of a pet peeve of mine :)

Jakub, we'll consider implementing a PF-rep as an add-on feature...

>
> If this bnxt_get_phys_port_name() relates to the external port, please
> change your implementation to comply with
> Documentation/networking/switchdev.txt, in particular:
>
>> Suggested naming convention is "swXpYsZ", where X is the switch name or ID, Y
>> is the port name or ID, and Z is the sub-port name or ID.  For example, 
>> sw1p1s0
>> would be sub-port 0 on port 1 on switch 1.
>
> So for physical ports the convention is p, and in case of
> breakout ps.

I'm sending a follow-up patch that fixes the naming for both the
external port and the VF-reps as proposed in your RFC ( switchdev:
clarify ndo_get_phys_port_name() formats)

thanks,
-Sathya


RE: [PATCH iproute2 1/1] tc: updated man page to reflect GET command to retrieve a single filter.

2016-11-18 Thread Sathya Perla
> -Original Message-
> From: netdev-ow...@vger.kernel.org [mailto:netdev-ow...@vger.kernel.org]
On Behalf Of Roman Mashak
>
> Signed-off-by: Roman Mashak 
> Signed-off-by: Jamal Hadi Salim 
> ---
>  man/man8/tc.8 | 10 +-
>  1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/man/man8/tc.8 b/man/man8/tc.8 index 4e99dca..3f4f8b5 100644
> --- a/man/man8/tc.8
> +++ b/man/man8/tc.8
> @@ -28,7 +28,7 @@ class-id ] qdisc
>
>  .B tc
>  .RI "[ " OPTIONS " ]"
> -.B filter [ add | change | replace | delete ] dev
> +.B filter [ add | change | replace | delete | get ] dev
>  DEV
>  .B [ parent
>  qdisc-id

The handle parameter seems to be missing from the TC filter syntax
synopsis ; as in:
tc [ OPTIONS ] filter [ add | change | replace | delete | get ]  dev  DEV
[
   parent  qdisc-id  | root ] protocol protocol prio priority handle
handle-ID

^

I guess the user would have to specify the handle-ID to retrieve a single
filter.

thanks,
-Sathya


RE: [net-next PATCH 0/4] be2net: patch set

2016-08-03 Thread Sathya Perla
> -Original Message-
> From: netdev-ow...@vger.kernel.org [mailto:netdev-ow...@vger.kernel.org]
On Behalf Of Sathya Perla
> Sent: Wednesday, July 27, 2016 2:56 PM
> To: netdev@vger.kernel.org
> Subject: [net-next PATCH 0/4] be2net: patch set
>
> Hi David, pls consider applying this patch-set to the net-next tree.
>
> Patch 1 fixes the driver to workaournd a bug in the Lancer FW in the
vlan-config cmd processing. The FW in some
> cases clears the vlan-promisc setting even if it cannot apply the vlan
filter. The driver has no means of knowing if
> the vlan-promisc setting has been cleared or not. This patch now
explicitly clears the vlan-promisc setting via the
> RX-Filter cmd and then tries to program the vlan-list.
>
> Patch 2 fixes the failure path in the vlan vid add code.
> The driver currently removes a new vid from the adapter->vids[] array if
> be_vid_config() returns an error, which occurs when there is an error in
HW/FW. This is wrong. After the HW/FW
> error is recovered from, we need the complete vids[] array to re-program
the vlan list.
>
> Patch 3 fixes the ndo_set_rx_mode() path to avoid unnecessary multicast
list updates to the FW. Each time the
> ndo_set_rx_mode() routine is called, the driver programs the multicast
list in the adapter without checking if
> there are any changes to the list. This leads to a flood of RX_FILTER
cmds when a number of vlan interfaces are
> configured over the device, as the ndo_ gets called for each vlan
interface. To avoid this, we now use
> __dev_mc_sync() and __dev_uc_sync() API, but only to detect if there is
a change in the mc/uc lists. Now that we
> use this API, the code has to be-designed to issue these API calls for
each invocation of the ndo_ call.
>
> Patch 4 replaces polling with sleeping in the FW completion path.
> The ndo_set_rx_mode() and ndo_add/del_vxlan_port() calls may be called
with BHs disabled. The driver currently
> issues the required cmds to the FW in these contexts and polls on
completions from the FW, while BHs remain
> disabled.  This can cause either packet loss or packet reception to be
delayed on that CPU.  This patch defers
> processing of the above cmds to a separate workqueue. With this change,
FW cmds are now issued only in
> process context. Now that the FW cmds are issued only in process
context, they can sleep waiting for a
> completion instead of polling.

David, do you want me to re-submit this patch-set after net-next re-opens
or would you consider applying this now itself?

thanks,
-Sathya


[net-next PATCH 3/4] be2net: Avoid unnecessary firmware updates of multicast list

2016-07-27 Thread Sathya Perla
From: Sriharsha Basavapatna 

Eachtime the ndo_set_rx_mode() routine is called, the driver programs the
multicast list in the adapter without checking if there are any changes to
the list. This leads to a flood of RX_FILTER cmds when a number of vlan
interfaces are configured over the device, as the ndo_ gets
called for each vlan interface. To avoid this, we now use __dev_mc_sync()
and __dev_uc_sync() API, but only to detect if there is a change in the
mc/uc lists. Now that we use this API, the code has to be-designed to
issue these API calls for each invocation of the be_set_rx_mode() call.

Signed-off-by: Sriharsha Basavapatna 
Signed-off-by: Sathya Perla 
---
 drivers/net/ethernet/emulex/benet/be.h  |   2 +
 drivers/net/ethernet/emulex/benet/be_main.c | 169 +---
 2 files changed, 130 insertions(+), 41 deletions(-)

diff --git a/drivers/net/ethernet/emulex/benet/be.h 
b/drivers/net/ethernet/emulex/benet/be.h
index 4555e04..6868712 100644
--- a/drivers/net/ethernet/emulex/benet/be.h
+++ b/drivers/net/ethernet/emulex/benet/be.h
@@ -573,6 +573,8 @@ struct be_adapter {
u32 uc_macs;/* Count of secondary UC MAC programmed */
unsigned long vids[BITS_TO_LONGS(VLAN_N_VID)];
u16 vlans_added;
+   bool update_uc_list;
+   bool update_mc_list;
 
u32 beacon_state;   /* for set_phys_id */
 
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c 
b/drivers/net/ethernet/emulex/benet/be_main.c
index 27fc1f0..4cf4997 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -1420,8 +1420,8 @@ static int be_vid_config(struct be_adapter *adapter)
u16 num = 0, i = 0;
int status = 0;
 
-   /* No need to further configure vids if in promiscuous mode */
-   if (be_in_all_promisc(adapter))
+   /* No need to change the VLAN state if the I/F is in promiscuous */
+   if (adapter->netdev->flags & IFF_PROMISC)
return 0;
 
if (adapter->vlans_added > be_max_vlans(adapter))
@@ -1483,12 +1483,6 @@ static int be_vlan_rem_vid(struct net_device *netdev, 
__be16 proto, u16 vid)
return be_vid_config(adapter);
 }
 
-static void be_clear_all_promisc(struct be_adapter *adapter)
-{
-   be_cmd_rx_filter(adapter, BE_IF_FLAGS_ALL_PROMISCUOUS, OFF);
-   adapter->if_flags &= ~BE_IF_FLAGS_ALL_PROMISCUOUS;
-}
-
 static void be_set_all_promisc(struct be_adapter *adapter)
 {
be_cmd_rx_filter(adapter, BE_IF_FLAGS_ALL_PROMISCUOUS, ON);
@@ -1507,42 +1501,144 @@ static void be_set_mc_promisc(struct be_adapter 
*adapter)
adapter->if_flags |= BE_IF_FLAGS_MCAST_PROMISCUOUS;
 }
 
-static void be_set_mc_list(struct be_adapter *adapter)
+static void be_set_uc_promisc(struct be_adapter *adapter)
 {
int status;
 
-   status = be_cmd_rx_filter(adapter, BE_IF_FLAGS_MULTICAST, ON);
+   if (adapter->if_flags & BE_IF_FLAGS_PROMISCUOUS)
+   return;
+
+   status = be_cmd_rx_filter(adapter, BE_IF_FLAGS_PROMISCUOUS, ON);
if (!status)
-   adapter->if_flags &= ~BE_IF_FLAGS_MCAST_PROMISCUOUS;
-   else
+   adapter->if_flags |= BE_IF_FLAGS_PROMISCUOUS;
+}
+
+static void be_clear_uc_promisc(struct be_adapter *adapter)
+{
+   int status;
+
+   if (!(adapter->if_flags & BE_IF_FLAGS_PROMISCUOUS))
+   return;
+
+   status = be_cmd_rx_filter(adapter, BE_IF_FLAGS_PROMISCUOUS, OFF);
+   if (!status)
+   adapter->if_flags &= ~BE_IF_FLAGS_PROMISCUOUS;
+}
+
+/* The below 2 functions are the callback args for __dev_mc_sync/dev_uc_sync().
+ * We use a single callback function for both sync and unsync. We really don't
+ * add/remove addresses through this callback. But, we use it to detect changes
+ * to the uc/mc lists. The entire uc/mc list is programmed in be_set_rx_mode().
+ */
+static int be_uc_list_update(struct net_device *netdev,
+const unsigned char *addr)
+{
+   struct be_adapter *adapter = netdev_priv(netdev);
+
+   adapter->update_uc_list = true;
+   return 0;
+}
+
+static int be_mc_list_update(struct net_device *netdev,
+const unsigned char *addr)
+{
+   struct be_adapter *adapter = netdev_priv(netdev);
+
+   adapter->update_mc_list = true;
+   return 0;
+}
+
+static void be_set_mc_list(struct be_adapter *adapter)
+{
+   struct net_device *netdev = adapter->netdev;
+   bool mc_promisc = false;
+   int status;
+
+   __dev_mc_sync(netdev, be_mc_list_update, be_mc_list_update);
+
+   if (netdev->flags & IFF_PROMISC) {
+   adapter->update_mc_list = false;
+   } else if (netdev->flags & IFF_ALLMULTI ||
+  netdev_mc_count(netdev) > be_max_mc(adapter)) {
+   /* Enable multicast promisc if num configured excee

[net-next PATCH 4/4] be2net: replace polling with sleeping in the FW completion path

2016-07-27 Thread Sathya Perla
The ndo_set_rx_mode() and ndo_add/del_vxlan_port() calls may be called with
BHs disabled. The driver currently issues the required cmds to the FW in
these contexts and polls on completions from the FW, while BHs remain
disabled.  This can cause either packet loss or packet reception to be
delayed on that CPU.

This patch defers processing of the above cmds to a separate workqueue.
With this change, FW cmds are now issued only in process context.
Now that the FW cmds are issued only in process context, they can sleep
waiting for a completion instead of polling. All the spin_lock_bh(mcc_lock)
calls are now replaced with mutex calls.

Also a new rx_filter_lock is now needed to protect the RX filtering fields
like vids[] between be_vlan_add/rem_vid() and __be_set_rx_mode() contexts.

Signed-off-by: Sathya Perla 
---
 drivers/net/ethernet/emulex/benet/be.h  |  19 +-
 drivers/net/ethernet/emulex/benet/be_cmds.c | 202 ++---
 drivers/net/ethernet/emulex/benet/be_main.c | 264 ++--
 3 files changed, 327 insertions(+), 158 deletions(-)

diff --git a/drivers/net/ethernet/emulex/benet/be.h 
b/drivers/net/ethernet/emulex/benet/be.h
index 6868712..86780b5 100644
--- a/drivers/net/ethernet/emulex/benet/be.h
+++ b/drivers/net/ethernet/emulex/benet/be.h
@@ -508,6 +508,10 @@ struct be_wrb_params {
u16 lso_mss;/* MSS for LSO */
 };
 
+struct be_eth_addr {
+   unsigned char mac[ETH_ALEN];
+};
+
 struct be_adapter {
struct pci_dev *pdev;
struct net_device *netdev;
@@ -523,7 +527,7 @@ struct be_adapter {
struct be_dma_mem mbox_mem_alloced;
 
struct be_mcc_obj mcc_obj;
-   spinlock_t mcc_lock;/* For serializing mcc cmds to BE card */
+   struct mutex mcc_lock;  /* For serializing mcc cmds to BE card */
spinlock_t mcc_cq_lock;
 
u16 cfg_num_rx_irqs;/* configured via set-channels */
@@ -570,11 +574,15 @@ struct be_adapter {
int if_handle;  /* Used to configure filtering */
u32 if_flags;   /* Interface filtering flags */
u32 *pmac_id;   /* MAC addr handle used by BE card */
+   struct be_eth_addr *uc_list;/* list of uc-addrs programmed (not perm) */
u32 uc_macs;/* Count of secondary UC MAC programmed */
+   struct be_eth_addr *mc_list;/* list of mcast addrs programmed */
+   u32 mc_count;
unsigned long vids[BITS_TO_LONGS(VLAN_N_VID)];
u16 vlans_added;
bool update_uc_list;
bool update_mc_list;
+   struct mutex rx_filter_lock;/* For protecting vids[] & mc/uc_list[] */
 
u32 beacon_state;   /* for set_phys_id */
 
@@ -628,6 +636,15 @@ struct be_adapter {
u8 phy_state; /* state of sfp optics (functional, faulted, etc.,) */
 };
 
+/* Used for defered FW config cmds. Add fields to this struct as reqd */
+struct be_cmd_work {
+   struct work_struct work;
+   struct be_adapter *adapter;
+   union {
+   __be16 vxlan_port;
+   } info;
+};
+
 #define be_physfn(adapter) (!adapter->virtfn)
 #define be_virtfn(adapter) (adapter->virtfn)
 #define sriov_enabled(adapter) (adapter->flags &   \
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c 
b/drivers/net/ethernet/emulex/benet/be_cmds.c
index 2cc1175..fa11a5a 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.c
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.c
@@ -571,7 +571,7 @@ int be_process_mcc(struct be_adapter *adapter)
 /* Wait till no more pending mcc requests are present */
 static int be_mcc_wait_compl(struct be_adapter *adapter)
 {
-#define mcc_timeout12 /* 12s timeout */
+#define mcc_timeout12000 /* 12s timeout */
int i, status = 0;
struct be_mcc_obj *mcc_obj = &adapter->mcc_obj;
 
@@ -585,7 +585,7 @@ static int be_mcc_wait_compl(struct be_adapter *adapter)
 
if (atomic_read(&mcc_obj->q.used) == 0)
break;
-   udelay(100);
+   usleep_range(500, 1000);
}
if (i == mcc_timeout) {
dev_err(&adapter->pdev->dev, "FW not responding\n");
@@ -863,7 +863,7 @@ static bool use_mcc(struct be_adapter *adapter)
 static int be_cmd_lock(struct be_adapter *adapter)
 {
if (use_mcc(adapter)) {
-   spin_lock_bh(&adapter->mcc_lock);
+   mutex_lock(&adapter->mcc_lock);
return 0;
} else {
return mutex_lock_interruptible(&adapter->mbox_lock);
@@ -874,7 +874,7 @@ static int be_cmd_lock(struct be_adapter *adapter)
 static void be_cmd_unlock(struct be_adapter *adapter)
 {
if (use_mcc(adapter))
-   spin_unlock_bh(&adapter->mcc_lock);
+   return mutex_unlock(&adapter->mcc_lock);
else
return mutex_unlock(&adapter->mbox_lock);

[net-next PATCH 0/4] be2net: patch set

2016-07-27 Thread Sathya Perla
Hi David, pls consider applying this patch-set to the net-next tree.

Patch 1 fixes the driver to workaournd a bug in the Lancer FW in the
vlan-config cmd processing. The FW in some cases clears the vlan-promisc
setting even if it cannot apply the vlan filter. The driver has no means
of knowing if the vlan-promisc setting has been cleared or not. This
patch now explicitly clears the vlan-promisc setting via the RX-Filter cmd
and then tries to program the vlan-list.

Patch 2 fixes the failure path in the vlan vid add code. 
The driver currently removes a new vid from the adapter->vids[] array if
be_vid_config() returns an error, which occurs when there is an error in
HW/FW. This is wrong. After the HW/FW error is recovered from, we need the
complete vids[] array to re-program the vlan list.

Patch 3 fixes the ndo_set_rx_mode() path to avoid unnecessary multicast
list updates to the FW. Each time the ndo_set_rx_mode() routine is called,
the driver programs the multicast list in the adapter without checking
if there are any changes to the list. This leads to a flood of RX_FILTER
cmds when a number of vlan interfaces are configured over the device,
as the ndo_ gets called for each vlan interface. To avoid this, we now
use __dev_mc_sync() and __dev_uc_sync() API, but only to detect if there
is a change in the mc/uc lists. Now that we use this API, the code has to
be-designed to issue these API calls for each invocation of the ndo_ call.

Patch 4 replaces polling with sleeping in the FW completion path.
The ndo_set_rx_mode() and ndo_add/del_vxlan_port() calls may be called with
BHs disabled. The driver currently issues the required cmds to the FW in
these contexts and polls on completions from the FW, while BHs remain
disabled.  This can cause either packet loss or packet reception to be
delayed on that CPU.  This patch defers processing of the above cmds to a
separate workqueue. With this change, FW cmds are now issued only in process
context. Now that the FW cmds are issued only in process context, they can
sleep waiting for a completion instead of polling.

Sathya Perla (2):
  be2net: do not remove vids from driver table if be_vid_config() fails.
  be2net: replace polling with sleeping in the FW completion path

Somnath Kotur (1):
  be2net: clear vlan-promisc setting before programming the vlan list

Sriharsha Basavapatna (1):
  be2net: Avoid unnecessary firmware updates of multicast list

 drivers/net/ethernet/emulex/benet/be.h  |  21 +-
 drivers/net/ethernet/emulex/benet/be_cmds.c | 202 ++---
 drivers/net/ethernet/emulex/benet/be_main.c | 422 ++--
 3 files changed, 450 insertions(+), 195 deletions(-)

-- 
2.4.1



[net-next PATCH 2/4] be2net: do not remove vids from driver table if be_vid_config() fails.

2016-07-27 Thread Sathya Perla
The driver currently removes a new vid from the adapter->vids[] array if
be_vid_config() returns an error, which occurs when there is an error in
HW/FW. This is wrong. After the HW/FW error is recovered from, we need the
complete vids[] array to re-program the vlan list.

Signed-off-by: Sathya Perla 
---
 drivers/net/ethernet/emulex/benet/be_main.c | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/emulex/benet/be_main.c 
b/drivers/net/ethernet/emulex/benet/be_main.c
index 2782299..27fc1f0 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -1463,13 +1463,7 @@ static int be_vlan_add_vid(struct net_device *netdev, 
__be16 proto, u16 vid)
set_bit(vid, adapter->vids);
adapter->vlans_added++;
 
-   status = be_vid_config(adapter);
-   if (status) {
-   adapter->vlans_added--;
-   clear_bit(vid, adapter->vids);
-   }
-
-   return status;
+   return be_vid_config(adapter);
 }
 
 static int be_vlan_rem_vid(struct net_device *netdev, __be16 proto, u16 vid)
-- 
2.4.1



[net-next PATCH 1/4] be2net: clear vlan-promisc setting before programming the vlan list

2016-07-27 Thread Sathya Perla
From: Somnath Kotur 

The Lancer FW has a bug due to which in some cases vlan-promisc setting
is cleared eventhough the vlan-list programming did not succeed (via
VLAN_CONFIG) cmd. The driver has no way of knowing if the vlan-promisc
mode was cleared or not when this cmd fails. To work around this issue,
this patch first explicitly clears the vlan-promisc mode via RX_FILTER
cmd and then tries to program the vlan list.
Signed-off-by: Somnath Kotur 

Signed-off-by: Sathya Perla 
---
 drivers/net/ethernet/emulex/benet/be_main.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/emulex/benet/be_main.c 
b/drivers/net/ethernet/emulex/benet/be_main.c
index 1f16e73..2782299 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -1427,6 +1427,11 @@ static int be_vid_config(struct be_adapter *adapter)
if (adapter->vlans_added > be_max_vlans(adapter))
return be_set_vlan_promisc(adapter);
 
+   if (adapter->if_flags & BE_IF_FLAGS_VLAN_PROMISCUOUS) {
+   status = be_clear_vlan_promisc(adapter);
+   if (status)
+   return status;
+   }
/* Construct VLAN Table to give to HW */
for_each_set_bit(i, adapter->vids, VLAN_N_VID)
vids[num++] = cpu_to_le16(i);
@@ -1439,8 +1444,6 @@ static int be_vid_config(struct be_adapter *adapter)
addl_status(status) ==
MCC_ADDL_STATUS_INSUFFICIENT_RESOURCES)
return be_set_vlan_promisc(adapter);
-   } else if (adapter->if_flags & BE_IF_FLAGS_VLAN_PROMISCUOUS) {
-   status = be_clear_vlan_promisc(adapter);
}
return status;
 }
-- 
2.4.1



RE: [net-next PATCH 4/4] be2net: replace polling with sleeping in the FW completion path

2016-07-27 Thread Sathya Perla
> -Original Message-
> From: Sathya Perla [mailto:sathya.pe...@broadcom.com]
> > >
> > > > @@ -4477,6 +4551,22 @@ static int be_if_create(struct be_adapter
> > *adapter)
> > > > u32 cap_flags = be_if_cap_flags(adapter);
> > > > int status;
> > > >
> > > > +   /* alloc required memory for other filtering fields */
> > > > +   adapter->pmac_id = kcalloc(be_max_uc(adapter),
> > > > +  sizeof(*adapter->pmac_id), 
> > > > GFP_KERNEL);
> > > > +   if (!adapter->pmac_id)
> > > > +   return -ENOMEM;
> > > > +
> > > > +   adapter->mc_list = kcalloc(be_max_mc(adapter),
> > > > +  sizeof(*adapter->mc_list), 
> > > > GFP_KERNEL);
> > > > +   if (!adapter->mc_list)
> > > > +   return -ENOMEM;
> > > > +
> > > > +   adapter->uc_list = kcalloc(be_max_uc(adapter),
> > > > +  sizeof(*adapter->uc_list), 
> > > > GFP_KERNEL);
> > > > +   if (!adapter->uc_list)
> > > > +   return -ENOMEM;
> > >
> > > These error paths are leaking memory, please audit this in the rest
> > > of
> > your change as well.
> >
> > David, thanks for catching this; will fix this (and others if any) and
> > send out a v2.
>
> David, actually, when be_if_create() returns an error, it falls back into
> the error path of
> be_setup() (the caller) and be_clear() is called. be_clear() calls
> be_if_destroy() which frees the allocated memory.
> So, this code will not leak memory in the error path.

David, can you accept the v1 patch set as-is, as it doesn't have the memory
leaks that you suspected initially?

thanks,
-Sathya


RE: [PATCH net] be2net: perform temperature query in adapter regardless of its interface state

2016-07-26 Thread Sathya Perla
> -Original Message-
> From: Guilherme G. Piccoli [mailto:gpicc...@linux.vnet.ibm.com]
>
> The be2net driver performs fw temperature queries on be_worker()
routine, which is executed each second for
> each be_adapter. There is a frequency threshold to avoid fw query to
happens at each call to be_worker();
> instead, currently a fw query occurs once in 64 runs of the procedure.
>
> Nevertheless, this fw temperature query is invoked only for adapters
which interface is up, so we can see I/O
> errors on read of hwmon counters from userspace (from tools like
lm-sensors) in case we have adapters'
> functions which interface is down.
>
> This patch moves the fw query code to be invoked even if interface is
down.
> No functional changes were introduced.
>
> Signed-off-by: Guilherme G. Piccoli 

Acked-by: Sathya Perla 


RE: [PATCH net-next 1/2] be2net: set temperature value for all adapter's functions

2016-07-26 Thread Sathya Perla
> -Original Message-
> From: Guilherme G. Piccoli [mailto:gpicc...@linux.vnet.ibm.com]
>
> On 07/25/2016 07:48 AM, Sathya Perla wrote:
> >> -Original Message-
> >> From: Guilherme G. Piccoli [mailto:gpicc...@linux.vnet.ibm.com]
> >>
> >> Temperature values on be2net driver are made available to userspace
> >> via
> > hwmon abstraction, so tools like lm-
> >> sensors can present them to the user.
> >> The driver provides hwmon structures for each adapter's function.
> >> Nevertheless, the temperature information come from fw queries
> >> performed
> > by
> >> be_worker() with some frequency, and this procedure is called with a
> > single function as argument; this means
> >> that the temperature value is updated only in the specific function
> >> that
> > was passed to be_worker().
> >>
> >> This can lead to incongruency in reported temperature by a function,
> >> or
> > in a worse scenario, some functions
> >> might be unable to provide temperature info to userspace, if they
> > weren't fed with this information from fw in
> >> be_worker() run.
> >
> > Hi, I'm wondering if you are OK with the temperature value being 128s
> > old
> > (2/2 patch), then why is it a problem
> > if two different functions report a temperature value that is queried
> > a few seconds apart?
> > Also, you'll not have a scenario where the FW cmd succeeds for one
> > function and fails for other functions.
> > It's a common FW for the entire adapter.
> >
> >>
> >> This patch changes the way temperature is set in be2net driver. At
> > anytime the fw query is performed, it will set
> >> the temperature value for all functions of the adapter, instead of
> >> only
> > setting the temperature of the function
> >> passed to be_worker().
> > If the possible inconsistency across functions is indeed a problem,
> > then a simpler solution would be to issue the FW cmd synchronously
> > when the sysfs attr is read, i.e., in
> > be_hwmon_show_temp() routine itself.
> >
>
> Hi Sathya, thanks very much for your quick reply. I agree with you that an
> 1 or 2 sec inconsistency wouldn't
> harm, but the main problem we're seeing is that be_worker() is being
> called with a single function as a parameter
> - in our case, the last function is being passed as argument to
> be_worker() multiple times in a row, and then we
> have its temperature updated but the other functions' temperature set as
> invalid.

Hi Guilherme, this doesn't sound right to me and is not expected. The
be_worker() routine must execute for *each* function every second.
Can you pls share the driver/fw version and any debug logs (with prints) you
may have and also lspci output.

>
> Regarding the temperature update run on be_hwmon_show_temp(), it was an
> idea too, but I was afraid in delay
> this output too much - imagine some userspace tool reads hwmon attributes
> for all functions almost at "same
> time", supposing the fw command can't run in parallel, the "last" read
> would need to wait 4 fw commands to
> complete before showing it's output.

I don't see any issue even if the sensors program queries each function one
after another. These calls would only be
a few milli-seconds apart.

> Besides, in a worse scenario, some "not-friendly" tool might issue lots of
> reads to hwmon per second then
> issuing lots of fw commands, which does not seem a good idea. Of course
> this last case we can avoid by
> implementing a counter or timer on be_hwmon_show_temp() to allow maximum
> number of fw cmds in a time
> frame.
Yes, this is not an issue. If the hwmon read is issued with-in a few seconds
of the previous read then you can just return the old temperature value.
We are anyway querying this value only once in 64s now.
But, I'd like to root-cause the issue you are seeing above before we "fix"
anything.

thanks,
-Sathya


RE: [net-next PATCH 4/4] be2net: replace polling with sleeping in the FW completion path

2016-07-26 Thread Sathya Perla
> -Original Message-
> From: Sathya Perla [mailto:sathya.pe...@broadcom.com]
>
> > -Original Message-
> > From: David Miller [mailto:da...@davemloft.net]
> >
> > > @@ -4477,6 +4551,22 @@ static int be_if_create(struct be_adapter
> *adapter)
> > >   u32 cap_flags = be_if_cap_flags(adapter);
> > >   int status;
> > >
> > > + /* alloc required memory for other filtering fields */
> > > + adapter->pmac_id = kcalloc(be_max_uc(adapter),
> > > +sizeof(*adapter->pmac_id), GFP_KERNEL);
> > > + if (!adapter->pmac_id)
> > > + return -ENOMEM;
> > > +
> > > + adapter->mc_list = kcalloc(be_max_mc(adapter),
> > > +sizeof(*adapter->mc_list), GFP_KERNEL);
> > > + if (!adapter->mc_list)
> > > + return -ENOMEM;
> > > +
> > > + adapter->uc_list = kcalloc(be_max_uc(adapter),
> > > +sizeof(*adapter->uc_list), GFP_KERNEL);
> > > + if (!adapter->uc_list)
> > > + return -ENOMEM;
> >
> > These error paths are leaking memory, please audit this in the rest of
> your change as well.
>
> David, thanks for catching this; will fix this (and others if any) and
> send out a v2.

David, actually, when be_if_create() returns an error, it falls back into
the error path of
be_setup() (the caller) and be_clear() is called. be_clear() calls
be_if_destroy() which frees the allocated memory.
So, this code will not leak memory in the error path.


RE: [net-next PATCH 4/4] be2net: replace polling with sleeping in the FW completion path

2016-07-26 Thread Sathya Perla
> -Original Message-
> From: David Miller [mailto:da...@davemloft.net]
>
> > @@ -4477,6 +4551,22 @@ static int be_if_create(struct be_adapter
*adapter)
> > u32 cap_flags = be_if_cap_flags(adapter);
> > int status;
> >
> > +   /* alloc required memory for other filtering fields */
> > +   adapter->pmac_id = kcalloc(be_max_uc(adapter),
> > +  sizeof(*adapter->pmac_id), GFP_KERNEL);
> > +   if (!adapter->pmac_id)
> > +   return -ENOMEM;
> > +
> > +   adapter->mc_list = kcalloc(be_max_mc(adapter),
> > +  sizeof(*adapter->mc_list), GFP_KERNEL);
> > +   if (!adapter->mc_list)
> > +   return -ENOMEM;
> > +
> > +   adapter->uc_list = kcalloc(be_max_uc(adapter),
> > +  sizeof(*adapter->uc_list), GFP_KERNEL);
> > +   if (!adapter->uc_list)
> > +   return -ENOMEM;
>
> These error paths are leaking memory, please audit this in the rest of
your change as well.

David, thanks for catching this; will fix this (and others if any) and
send out a v2.


RE: [PATCH net-next 1/2] be2net: set temperature value for all adapter's functions

2016-07-25 Thread Sathya Perla
> -Original Message-
> From: Guilherme G. Piccoli [mailto:gpicc...@linux.vnet.ibm.com]
>
> Temperature values on be2net driver are made available to userspace via
hwmon abstraction, so tools like lm-
> sensors can present them to the user.
> The driver provides hwmon structures for each adapter's function.
> Nevertheless, the temperature information come from fw queries performed
by
> be_worker() with some frequency, and this procedure is called with a
single function as argument; this means
> that the temperature value is updated only in the specific function that
was passed to be_worker().
>
> This can lead to incongruency in reported temperature by a function, or
in a worse scenario, some functions
> might be unable to provide temperature info to userspace, if they
weren't fed with this information from fw in
> be_worker() run.

Hi, I'm wondering if you are OK with the temperature value being 128s old
(2/2 patch), then why is it a problem
if two different functions report a temperature value that is queried a
few seconds apart?
Also, you'll not have a scenario where the FW cmd succeeds for one
function and fails for other functions.
It's a common FW for the entire adapter.

>
> This patch changes the way temperature is set in be2net driver. At
anytime the fw query is performed, it will set
> the temperature value for all functions of the adapter, instead of only
setting the temperature of the function
> passed to be_worker().
If the possible inconsistency across functions is indeed a problem, then a
simpler solution would be to
issue the FW cmd synchronously when the sysfs attr is read, i.e., in
be_hwmon_show_temp() routine itself.

thanks!
-Sathya


[net-next PATCH 2/4] be2net: do not remove vids from driver table if be_vid_config() fails.

2016-07-22 Thread Sathya Perla
The driver currently removes a new vid from the adapter->vids[] array if
be_vid_config() returns an error, which occurs when there is an error in
HW/FW. This is wrong. After the HW/FW error is recovered from, we need the
complete vids[] array to re-program the vlan list.

Signed-off-by: Sathya Perla 
---
 drivers/net/ethernet/emulex/benet/be_main.c | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/emulex/benet/be_main.c 
b/drivers/net/ethernet/emulex/benet/be_main.c
index 2782299..27fc1f0 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -1463,13 +1463,7 @@ static int be_vlan_add_vid(struct net_device *netdev, 
__be16 proto, u16 vid)
set_bit(vid, adapter->vids);
adapter->vlans_added++;
 
-   status = be_vid_config(adapter);
-   if (status) {
-   adapter->vlans_added--;
-   clear_bit(vid, adapter->vids);
-   }
-
-   return status;
+   return be_vid_config(adapter);
 }
 
 static int be_vlan_rem_vid(struct net_device *netdev, __be16 proto, u16 vid)
-- 
2.4.1



[net-next PATCH 1/4] be2net: clear vlan-promisc setting before programming the vlan list

2016-07-22 Thread Sathya Perla
From: Somnath Kotur 

The Lancer FW has a bug due to which in some cases vlan-promisc setting
is cleared eventhough the vlan-list programming did not succeed (via
VLAN_CONFIG) cmd. The driver has no way of knowing if the vlan-promisc
mode was cleared or not when this cmd fails. To work around this issue,
this patch first explicitly clears the vlan-promisc mode via RX_FILTER
cmd and then tries to program the vlan list.
Signed-off-by: Somnath Kotur 

Signed-off-by: Sathya Perla 
---
 drivers/net/ethernet/emulex/benet/be_main.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/emulex/benet/be_main.c 
b/drivers/net/ethernet/emulex/benet/be_main.c
index 1f16e73..2782299 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -1427,6 +1427,11 @@ static int be_vid_config(struct be_adapter *adapter)
if (adapter->vlans_added > be_max_vlans(adapter))
return be_set_vlan_promisc(adapter);
 
+   if (adapter->if_flags & BE_IF_FLAGS_VLAN_PROMISCUOUS) {
+   status = be_clear_vlan_promisc(adapter);
+   if (status)
+   return status;
+   }
/* Construct VLAN Table to give to HW */
for_each_set_bit(i, adapter->vids, VLAN_N_VID)
vids[num++] = cpu_to_le16(i);
@@ -1439,8 +1444,6 @@ static int be_vid_config(struct be_adapter *adapter)
addl_status(status) ==
MCC_ADDL_STATUS_INSUFFICIENT_RESOURCES)
return be_set_vlan_promisc(adapter);
-   } else if (adapter->if_flags & BE_IF_FLAGS_VLAN_PROMISCUOUS) {
-   status = be_clear_vlan_promisc(adapter);
}
return status;
 }
-- 
2.4.1



[net-next PATCH 0/4] be2net: patch set

2016-07-22 Thread Sathya Perla
Hi David, pls consider applying this patch-set to the net-next tree.

Patch 1 fixes the driver to workaournd a bug in the Lancer FW in the
vlan-config cmd processing. The FW in some cases clears the vlan-promisc
setting even if it cannot apply the vlan filter. The driver has no means
of knowing if the vlan-promisc setting has been cleared or not. This
patch now explicitly clears the vlan-promisc setting via the RX-Filter cmd
and then tries to program the vlan-list.

Patch 2 fixes the failure path in the vlan vid add code. 
The driver currently removes a new vid from the adapter->vids[] array if
be_vid_config() returns an error, which occurs when there is an error in
HW/FW. This is wrong. After the HW/FW error is recovered from, we need the
complete vids[] array to re-program the vlan list.

Patch 3 fixes the ndo_set_rx_mode() path to avoid unnecessary multicast
list updates to the FW. Each time the ndo_set_rx_mode() routine is called,
the driver programs the multicast list in the adapter without checking
if there are any changes to the list. This leads to a flood of RX_FILTER
cmds when a number of vlan interfaces are configured over the device,
as the ndo_ gets called for each vlan interface. To avoid this, we now
use __dev_mc_sync() and __dev_uc_sync() API, but only to detect if there
is a change in the mc/uc lists. Now that we use this API, the code has to
be-designed to issue these API calls for each invocation of the ndo_ call.

Patch 4 replaces polling with sleeping in the FW completion path.
The ndo_set_rx_mode() and ndo_add/del_vxlan_port() calls may be called with
BHs disabled. The driver currently issues the required cmds to the FW in
these contexts and polls on completions from the FW, while BHs remain
disabled.  This can cause either packet loss or packet reception to be
delayed on that CPU.  This patch defers processing of the above cmds to a
separate workqueue. With this change, FW cmds are now issued only in process
context. Now that the FW cmds are issued only in process context, they can
sleep waiting for a completion instead of polling.

Sathya Perla (2):
  be2net: do not remove vids from driver table if be_vid_config() fails.
  be2net: replace polling with sleeping in the FW completion path

Somnath Kotur (1):
  be2net: clear vlan-promisc setting before programming the vlan list

Sriharsha Basavapatna (1):
  be2net: Avoid unnecessary firmware updates of multicast list

 drivers/net/ethernet/emulex/benet/be.h  |  21 +-
 drivers/net/ethernet/emulex/benet/be_cmds.c | 202 ++---
 drivers/net/ethernet/emulex/benet/be_main.c | 422 ++--
 3 files changed, 450 insertions(+), 195 deletions(-)

-- 
2.4.1



[net-next PATCH 4/4] be2net: replace polling with sleeping in the FW completion path

2016-07-22 Thread Sathya Perla
The ndo_set_rx_mode() and ndo_add/del_vxlan_port() calls may be called with
BHs disabled. The driver currently issues the required cmds to the FW in
these contexts and polls on completions from the FW, while BHs remain
disabled.  This can cause either packet loss or packet reception to be
delayed on that CPU.

This patch defers processing of the above cmds to a separate workqueue.
With this change, FW cmds are now issued only in process context.
Now that the FW cmds are issued only in process context, they can sleep
waiting for a completion instead of polling. All the spin_lock_bh(mcc_lock)
calls are now replaced with mutex calls.

Also a new rx_filter_lock is now needed to protect the RX filtering fields
like vids[] between be_vlan_add/rem_vid() and __be_set_rx_mode() contexts.

Signed-off-by: Sathya Perla 
---
 drivers/net/ethernet/emulex/benet/be.h  |  19 +-
 drivers/net/ethernet/emulex/benet/be_cmds.c | 202 ++---
 drivers/net/ethernet/emulex/benet/be_main.c | 264 ++--
 3 files changed, 327 insertions(+), 158 deletions(-)

diff --git a/drivers/net/ethernet/emulex/benet/be.h 
b/drivers/net/ethernet/emulex/benet/be.h
index 6868712..86780b5 100644
--- a/drivers/net/ethernet/emulex/benet/be.h
+++ b/drivers/net/ethernet/emulex/benet/be.h
@@ -508,6 +508,10 @@ struct be_wrb_params {
u16 lso_mss;/* MSS for LSO */
 };
 
+struct be_eth_addr {
+   unsigned char mac[ETH_ALEN];
+};
+
 struct be_adapter {
struct pci_dev *pdev;
struct net_device *netdev;
@@ -523,7 +527,7 @@ struct be_adapter {
struct be_dma_mem mbox_mem_alloced;
 
struct be_mcc_obj mcc_obj;
-   spinlock_t mcc_lock;/* For serializing mcc cmds to BE card */
+   struct mutex mcc_lock;  /* For serializing mcc cmds to BE card */
spinlock_t mcc_cq_lock;
 
u16 cfg_num_rx_irqs;/* configured via set-channels */
@@ -570,11 +574,15 @@ struct be_adapter {
int if_handle;  /* Used to configure filtering */
u32 if_flags;   /* Interface filtering flags */
u32 *pmac_id;   /* MAC addr handle used by BE card */
+   struct be_eth_addr *uc_list;/* list of uc-addrs programmed (not perm) */
u32 uc_macs;/* Count of secondary UC MAC programmed */
+   struct be_eth_addr *mc_list;/* list of mcast addrs programmed */
+   u32 mc_count;
unsigned long vids[BITS_TO_LONGS(VLAN_N_VID)];
u16 vlans_added;
bool update_uc_list;
bool update_mc_list;
+   struct mutex rx_filter_lock;/* For protecting vids[] & mc/uc_list[] */
 
u32 beacon_state;   /* for set_phys_id */
 
@@ -628,6 +636,15 @@ struct be_adapter {
u8 phy_state; /* state of sfp optics (functional, faulted, etc.,) */
 };
 
+/* Used for defered FW config cmds. Add fields to this struct as reqd */
+struct be_cmd_work {
+   struct work_struct work;
+   struct be_adapter *adapter;
+   union {
+   __be16 vxlan_port;
+   } info;
+};
+
 #define be_physfn(adapter) (!adapter->virtfn)
 #define be_virtfn(adapter) (adapter->virtfn)
 #define sriov_enabled(adapter) (adapter->flags &   \
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c 
b/drivers/net/ethernet/emulex/benet/be_cmds.c
index 2cc1175..fa11a5a 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.c
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.c
@@ -571,7 +571,7 @@ int be_process_mcc(struct be_adapter *adapter)
 /* Wait till no more pending mcc requests are present */
 static int be_mcc_wait_compl(struct be_adapter *adapter)
 {
-#define mcc_timeout12 /* 12s timeout */
+#define mcc_timeout12000 /* 12s timeout */
int i, status = 0;
struct be_mcc_obj *mcc_obj = &adapter->mcc_obj;
 
@@ -585,7 +585,7 @@ static int be_mcc_wait_compl(struct be_adapter *adapter)
 
if (atomic_read(&mcc_obj->q.used) == 0)
break;
-   udelay(100);
+   usleep_range(500, 1000);
}
if (i == mcc_timeout) {
dev_err(&adapter->pdev->dev, "FW not responding\n");
@@ -863,7 +863,7 @@ static bool use_mcc(struct be_adapter *adapter)
 static int be_cmd_lock(struct be_adapter *adapter)
 {
if (use_mcc(adapter)) {
-   spin_lock_bh(&adapter->mcc_lock);
+   mutex_lock(&adapter->mcc_lock);
return 0;
} else {
return mutex_lock_interruptible(&adapter->mbox_lock);
@@ -874,7 +874,7 @@ static int be_cmd_lock(struct be_adapter *adapter)
 static void be_cmd_unlock(struct be_adapter *adapter)
 {
if (use_mcc(adapter))
-   spin_unlock_bh(&adapter->mcc_lock);
+   return mutex_unlock(&adapter->mcc_lock);
else
return mutex_unlock(&adapter->mbox_lock);

[net-next PATCH 3/4] be2net: Avoid unnecessary firmware updates of multicast list

2016-07-22 Thread Sathya Perla
From: Sriharsha Basavapatna 

Eachtime the ndo_set_rx_mode() routine is called, the driver programs the
multicast list in the adapter without checking if there are any changes to
the list. This leads to a flood of RX_FILTER cmds when a number of vlan
interfaces are configured over the device, as the ndo_ gets
called for each vlan interface. To avoid this, we now use __dev_mc_sync()
and __dev_uc_sync() API, but only to detect if there is a change in the
mc/uc lists. Now that we use this API, the code has to be-designed to
issue these API calls for each invocation of the be_set_rx_mode() call.

Signed-off-by: Sriharsha Basavapatna 
Signed-off-by: Sathya Perla 
---
 drivers/net/ethernet/emulex/benet/be.h  |   2 +
 drivers/net/ethernet/emulex/benet/be_main.c | 169 +---
 2 files changed, 130 insertions(+), 41 deletions(-)

diff --git a/drivers/net/ethernet/emulex/benet/be.h 
b/drivers/net/ethernet/emulex/benet/be.h
index 4555e04..6868712 100644
--- a/drivers/net/ethernet/emulex/benet/be.h
+++ b/drivers/net/ethernet/emulex/benet/be.h
@@ -573,6 +573,8 @@ struct be_adapter {
u32 uc_macs;/* Count of secondary UC MAC programmed */
unsigned long vids[BITS_TO_LONGS(VLAN_N_VID)];
u16 vlans_added;
+   bool update_uc_list;
+   bool update_mc_list;
 
u32 beacon_state;   /* for set_phys_id */
 
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c 
b/drivers/net/ethernet/emulex/benet/be_main.c
index 27fc1f0..4cf4997 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -1420,8 +1420,8 @@ static int be_vid_config(struct be_adapter *adapter)
u16 num = 0, i = 0;
int status = 0;
 
-   /* No need to further configure vids if in promiscuous mode */
-   if (be_in_all_promisc(adapter))
+   /* No need to change the VLAN state if the I/F is in promiscuous */
+   if (adapter->netdev->flags & IFF_PROMISC)
return 0;
 
if (adapter->vlans_added > be_max_vlans(adapter))
@@ -1483,12 +1483,6 @@ static int be_vlan_rem_vid(struct net_device *netdev, 
__be16 proto, u16 vid)
return be_vid_config(adapter);
 }
 
-static void be_clear_all_promisc(struct be_adapter *adapter)
-{
-   be_cmd_rx_filter(adapter, BE_IF_FLAGS_ALL_PROMISCUOUS, OFF);
-   adapter->if_flags &= ~BE_IF_FLAGS_ALL_PROMISCUOUS;
-}
-
 static void be_set_all_promisc(struct be_adapter *adapter)
 {
be_cmd_rx_filter(adapter, BE_IF_FLAGS_ALL_PROMISCUOUS, ON);
@@ -1507,42 +1501,144 @@ static void be_set_mc_promisc(struct be_adapter 
*adapter)
adapter->if_flags |= BE_IF_FLAGS_MCAST_PROMISCUOUS;
 }
 
-static void be_set_mc_list(struct be_adapter *adapter)
+static void be_set_uc_promisc(struct be_adapter *adapter)
 {
int status;
 
-   status = be_cmd_rx_filter(adapter, BE_IF_FLAGS_MULTICAST, ON);
+   if (adapter->if_flags & BE_IF_FLAGS_PROMISCUOUS)
+   return;
+
+   status = be_cmd_rx_filter(adapter, BE_IF_FLAGS_PROMISCUOUS, ON);
if (!status)
-   adapter->if_flags &= ~BE_IF_FLAGS_MCAST_PROMISCUOUS;
-   else
+   adapter->if_flags |= BE_IF_FLAGS_PROMISCUOUS;
+}
+
+static void be_clear_uc_promisc(struct be_adapter *adapter)
+{
+   int status;
+
+   if (!(adapter->if_flags & BE_IF_FLAGS_PROMISCUOUS))
+   return;
+
+   status = be_cmd_rx_filter(adapter, BE_IF_FLAGS_PROMISCUOUS, OFF);
+   if (!status)
+   adapter->if_flags &= ~BE_IF_FLAGS_PROMISCUOUS;
+}
+
+/* The below 2 functions are the callback args for __dev_mc_sync/dev_uc_sync().
+ * We use a single callback function for both sync and unsync. We really don't
+ * add/remove addresses through this callback. But, we use it to detect changes
+ * to the uc/mc lists. The entire uc/mc list is programmed in be_set_rx_mode().
+ */
+static int be_uc_list_update(struct net_device *netdev,
+const unsigned char *addr)
+{
+   struct be_adapter *adapter = netdev_priv(netdev);
+
+   adapter->update_uc_list = true;
+   return 0;
+}
+
+static int be_mc_list_update(struct net_device *netdev,
+const unsigned char *addr)
+{
+   struct be_adapter *adapter = netdev_priv(netdev);
+
+   adapter->update_mc_list = true;
+   return 0;
+}
+
+static void be_set_mc_list(struct be_adapter *adapter)
+{
+   struct net_device *netdev = adapter->netdev;
+   bool mc_promisc = false;
+   int status;
+
+   __dev_mc_sync(netdev, be_mc_list_update, be_mc_list_update);
+
+   if (netdev->flags & IFF_PROMISC) {
+   adapter->update_mc_list = false;
+   } else if (netdev->flags & IFF_ALLMULTI ||
+  netdev_mc_count(netdev) > be_max_mc(adapter)) {
+   /* Enable multicast promisc if num configured excee

RE: [patch] be2net: signedness bug in be_msix_enable()

2016-06-30 Thread Sathya Perla
> -Original Message-
> From: Dan Carpenter [mailto:dan.carpen...@oracle.com]
>
> "num_vec" needs to be signed for the error handling to work.
>
> Fixes: e261768e9e39 ('be2net: support asymmetric rx/tx queue counts')
> Signed-off-by: Dan Carpenter 
>
> diff --git a/drivers/net/ethernet/emulex/benet/be_main.c
b/drivers/net/ethernet/emulex/benet/be_main.c
> index 1873c74..1f16e73 100644
> --- a/drivers/net/ethernet/emulex/benet/be_main.c
> +++ b/drivers/net/ethernet/emulex/benet/be_main.c
> @@ -3251,8 +3251,9 @@ static void be_msix_disable(struct be_adapter
*adapter)
>
>  static int be_msix_enable(struct be_adapter *adapter)  {
> - unsigned int i, num_vec, max_roce_eqs;
> + unsigned int i, max_roce_eqs;
>   struct device *dev = &adapter->pdev->dev;
> + int num_vec;
>

Oops...thanks for catching this! This must go into net-next.

Acked-by: Sathya Perla 


[net-next PATCH 0/5] be2net: patch set

2016-06-22 Thread Sathya Perla
Hi Dave, pls consider commiting the following patches to the net-next tree.
Thanks!

Patch 1 replaces the be_max_eqs() macro with two new macros called
be_max_nic_eqs() and be_max_func_eqs() to clear confusion in that part
of the code.

Patch 2 adds support to configure asymmetric number of rx/tx queues via
ethtool set-channels option.

Patch 3 disables EVB when VFs are not enabled on a BE3 SR-IOV config to
avoid the broadcast echo problem.

Patch 4 updates copyright markings in be2net src files

Patch 5 updates the be2net maintainers' list

Sathya Perla (3):
  be2net: fix definition of be_max_eqs()
  be2net: support asymmetric rx/tx queue counts
  be2net: update be2net maintainers list

Somnath Kotur (2):
  be2net: Fix broadcast echoes from EVB in BE3
  be2net: Change copyright markings in source files

 MAINTAINERS|  3 +-
 drivers/net/ethernet/emulex/benet/be.h | 36 +--
 drivers/net/ethernet/emulex/benet/be_cmds.c| 13 +++-
 drivers/net/ethernet/emulex/benet/be_cmds.h|  2 +-
 drivers/net/ethernet/emulex/benet/be_ethtool.c | 31 +++--
 drivers/net/ethernet/emulex/benet/be_main.c| 89 +-
 drivers/net/ethernet/emulex/benet/be_roce.c|  2 +-
 drivers/net/ethernet/emulex/benet/be_roce.h|  2 +-
 8 files changed, 128 insertions(+), 50 deletions(-)

-- 
2.4.1



[net-next PATCH 4/5] be2net: Change copyright markings in source files

2016-06-22 Thread Sathya Perla
From: Somnath Kotur 

This patch updates year and company name in the copyright markings in the
be2net source files.

Signed-off-by: Somnath Kotur 
Signed-off-by: Sathya Perla 
---
 drivers/net/ethernet/emulex/benet/be.h | 2 +-
 drivers/net/ethernet/emulex/benet/be_cmds.c| 2 +-
 drivers/net/ethernet/emulex/benet/be_cmds.h| 2 +-
 drivers/net/ethernet/emulex/benet/be_ethtool.c | 2 +-
 drivers/net/ethernet/emulex/benet/be_main.c| 2 +-
 drivers/net/ethernet/emulex/benet/be_roce.c| 2 +-
 drivers/net/ethernet/emulex/benet/be_roce.h| 2 +-
 7 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/emulex/benet/be.h 
b/drivers/net/ethernet/emulex/benet/be.h
index 096cb1f5..4555e04 100644
--- a/drivers/net/ethernet/emulex/benet/be.h
+++ b/drivers/net/ethernet/emulex/benet/be.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005 - 2015 Emulex
+ * Copyright (C) 2005 - 2016 Broadcom
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c 
b/drivers/net/ethernet/emulex/benet/be_cmds.c
index a98b6ab..2cc1175 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.c
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005 - 2015 Emulex
+ * Copyright (C) 2005 - 2016 Broadcom
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.h 
b/drivers/net/ethernet/emulex/benet/be_cmds.h
index cb96ddd..0d6be22 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.h
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005 - 2015 Emulex
+ * Copyright (C) 2005 - 2016 Broadcom
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or
diff --git a/drivers/net/ethernet/emulex/benet/be_ethtool.c 
b/drivers/net/ethernet/emulex/benet/be_ethtool.c
index 71940b9..50e7be5 100644
--- a/drivers/net/ethernet/emulex/benet/be_ethtool.c
+++ b/drivers/net/ethernet/emulex/benet/be_ethtool.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005 - 2015 Emulex
+ * Copyright (C) 2005 - 2016 Broadcom
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c 
b/drivers/net/ethernet/emulex/benet/be_main.c
index f11a19b..1873c74 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005 - 2015 Emulex
+ * Copyright (C) 2005 - 2016 Broadcom
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or
diff --git a/drivers/net/ethernet/emulex/benet/be_roce.c 
b/drivers/net/ethernet/emulex/benet/be_roce.c
index 4089156..2b62841 100644
--- a/drivers/net/ethernet/emulex/benet/be_roce.c
+++ b/drivers/net/ethernet/emulex/benet/be_roce.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005 - 2015 Emulex
+ * Copyright (C) 2005 - 2016 Broadcom
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or
diff --git a/drivers/net/ethernet/emulex/benet/be_roce.h 
b/drivers/net/ethernet/emulex/benet/be_roce.h
index fde6097..e51719a 100644
--- a/drivers/net/ethernet/emulex/benet/be_roce.h
+++ b/drivers/net/ethernet/emulex/benet/be_roce.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005 - 2015 Emulex
+ * Copyright (C) 2005 - 2016 Broadcom
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or
-- 
2.4.1



[net-next PATCH 1/5] be2net: fix definition of be_max_eqs()

2016-06-22 Thread Sathya Perla
The EQs available on a function are shared between NIC and RoCE.
The be_max_eqs() macro was so far being used to refer to the max number of
EQs available for NIC. This has caused some confusion in the code. To fix
this confusion this patch introduces a new macro called be_max_nic_eqs()
to refer to the max number of EQs avialable for NIC only and renames
be_max_eqs() to be_max_func_eqs().

Signed-off-by: Sathya Perla 
---
 drivers/net/ethernet/emulex/benet/be.h  |  8 ++--
 drivers/net/ethernet/emulex/benet/be_main.c | 29 +
 2 files changed, 19 insertions(+), 18 deletions(-)

diff --git a/drivers/net/ethernet/emulex/benet/be.h 
b/drivers/net/ethernet/emulex/benet/be.h
index e1e6c40..f8040ef 100644
--- a/drivers/net/ethernet/emulex/benet/be.h
+++ b/drivers/net/ethernet/emulex/benet/be.h
@@ -443,6 +443,7 @@ struct be_resources {
u16 max_iface_count;
u16 max_mcc_count;
u16 max_evt_qs;
+   u16 max_nic_evt_qs; /* NIC's share of evt qs */
u32 if_cap_flags;
u32 vf_if_cap_flags;/* VF if capability flags */
u32 flags;
@@ -644,7 +645,10 @@ struct be_adapter {
 #define be_max_txqs(adapter)   (adapter->res.max_tx_qs)
 #define be_max_prio_txqs(adapter)  (adapter->res.max_prio_tx_qs)
 #define be_max_rxqs(adapter)   (adapter->res.max_rx_qs)
-#define be_max_eqs(adapter)(adapter->res.max_evt_qs)
+/* Max number of EQs available for the function (NIC + RoCE (if enabled)) */
+#define be_max_func_eqs(adapter)   (adapter->res.max_evt_qs)
+/* Max number of EQs available avaialble only for NIC */
+#define be_max_nic_eqs(adapter)(adapter->res.max_nic_evt_qs)
 #define be_if_cap_flags(adapter)   (adapter->res.if_cap_flags)
 #define be_max_pf_pool_rss_tables(adapter) \
(adapter->pool_res.max_rss_tables)
@@ -654,7 +658,7 @@ static inline u16 be_max_qs(struct be_adapter *adapter)
/* If no RSS, need atleast the one def RXQ */
u16 num = max_t(u16, be_max_rss(adapter), 1);
 
-   num = min(num, be_max_eqs(adapter));
+   num = min(num, be_max_nic_eqs(adapter));
return min_t(u16, num, num_online_cpus());
 }
 
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c 
b/drivers/net/ethernet/emulex/benet/be_main.c
index 3d94789..c67830f 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -3252,12 +3252,12 @@ static int be_msix_enable(struct be_adapter *adapter)
int i, num_vec;
struct device *dev = &adapter->pdev->dev;
 
-   /* If RoCE is supported, program the max number of NIC vectors that
-* may be configured via set-channels, along with vectors needed for
-* RoCe. Else, just program the number we'll use initially.
+   /* If RoCE is supported, program the max number of vectors that
+* could be used for NIC and RoCE, else, just program the number
+* we'll use initially.
 */
if (be_roce_supported(adapter))
-   num_vec = min_t(int, 2 * be_max_eqs(adapter),
+   num_vec = min_t(int, be_max_func_eqs(adapter),
2 * num_online_cpus());
else
num_vec = adapter->cfg_num_qs;
@@ -4219,16 +4219,13 @@ static int be_get_resources(struct be_adapter *adapter)
struct be_resources res = {0};
int status;
 
-   if (BEx_chip(adapter)) {
-   BEx_get_resources(adapter, &res);
-   adapter->res = res;
-   }
-
/* For Lancer, SH etc read per-function resource limits from FW.
 * GET_FUNC_CONFIG returns per function guaranteed limits.
 * GET_PROFILE_CONFIG returns PCI-E related limits PF-pool limits
 */
-   if (!BEx_chip(adapter)) {
+   if (BEx_chip(adapter)) {
+   BEx_get_resources(adapter, &res);
+   } else {
status = be_cmd_get_func_config(adapter, &res);
if (status)
return status;
@@ -4237,13 +4234,13 @@ static int be_get_resources(struct be_adapter *adapter)
if (res.max_rss_qs && res.max_rss_qs == res.max_rx_qs &&
!(res.if_cap_flags & BE_IF_FLAGS_DEFQ_RSS))
res.max_rss_qs -= 1;
-
-   /* If RoCE may be enabled stash away half the EQs for RoCE */
-   if (be_roce_supported(adapter))
-   res.max_evt_qs /= 2;
-   adapter->res = res;
}
 
+   /* If RoCE is supported stash away half the EQs for RoCE */
+   res.max_nic_evt_qs = be_roce_supported(adapter) ?
+   res.max_evt_qs / 2 : res.max_evt_qs;
+   adapter->res = res;
+
/* If FW supports RSS default queue, then skip creating non-RSS
 * queue for non-IP traffic.
 */
@@ -425

[net-next PATCH 2/5] be2net: support asymmetric rx/tx queue counts

2016-06-22 Thread Sathya Perla
be2net so far supported creation of RX/TX queues only in pairs.
On configs where rx and tx queue counts are different, creation of only
the lesser number of queues has been supported.

This patch now allows a combination of RX/TX-only channels along with
combined channels. N TX-queues and M RX-queues can be created with the
following cmds:
ethtool -L ethX combined N rx M-N  (when N < M)
ethtool -L ethX combined M tx N-M (when M < N)

Setting both RX-only and TX-only channels is still not supported.
It is mandatory to create atleast one combined channel.

Signed-off-by: Sathya Perla 
---
 drivers/net/ethernet/emulex/benet/be.h | 32 ++
 drivers/net/ethernet/emulex/benet/be_ethtool.c | 29 
 drivers/net/ethernet/emulex/benet/be_main.c| 38 --
 3 files changed, 74 insertions(+), 25 deletions(-)

diff --git a/drivers/net/ethernet/emulex/benet/be.h 
b/drivers/net/ethernet/emulex/benet/be.h
index f8040ef..096cb1f5 100644
--- a/drivers/net/ethernet/emulex/benet/be.h
+++ b/drivers/net/ethernet/emulex/benet/be.h
@@ -526,7 +526,8 @@ struct be_adapter {
spinlock_t mcc_lock;/* For serializing mcc cmds to BE card */
spinlock_t mcc_cq_lock;
 
-   u16 cfg_num_qs; /* configured via set-channels */
+   u16 cfg_num_rx_irqs;/* configured via set-channels */
+   u16 cfg_num_tx_irqs;/* configured via set-channels */
u16 num_evt_qs;
u16 num_msix_vec;
struct be_eq_obj eq_obj[MAX_EVT_QS];
@@ -652,14 +653,35 @@ struct be_adapter {
 #define be_if_cap_flags(adapter)   (adapter->res.if_cap_flags)
 #define be_max_pf_pool_rss_tables(adapter) \
(adapter->pool_res.max_rss_tables)
+/* Max irqs avaialble for NIC */
+#define be_max_irqs(adapter)   \
+   (min_t(u16, be_max_nic_eqs(adapter), num_online_cpus()))
 
-static inline u16 be_max_qs(struct be_adapter *adapter)
+/* Max irqs *needed* for RX queues */
+static inline u16 be_max_rx_irqs(struct be_adapter *adapter)
 {
-   /* If no RSS, need atleast the one def RXQ */
+   /* If no RSS, need atleast one irq for def-RXQ */
u16 num = max_t(u16, be_max_rss(adapter), 1);
 
-   num = min(num, be_max_nic_eqs(adapter));
-   return min_t(u16, num, num_online_cpus());
+   return min_t(u16, num, be_max_irqs(adapter));
+}
+
+/* Max irqs *needed* for TX queues */
+static inline u16 be_max_tx_irqs(struct be_adapter *adapter)
+{
+   return min_t(u16, be_max_txqs(adapter), be_max_irqs(adapter));
+}
+
+/* Max irqs *needed* for combined queues */
+static inline u16 be_max_qp_irqs(struct be_adapter *adapter)
+{
+   return min(be_max_tx_irqs(adapter), be_max_rx_irqs(adapter));
+}
+
+/* Max irqs *needed* for RX and TX queues together */
+static inline u16 be_max_any_irqs(struct be_adapter *adapter)
+{
+   return max(be_max_tx_irqs(adapter), be_max_rx_irqs(adapter));
 }
 
 /* Is BE in pvid_tagging mode */
diff --git a/drivers/net/ethernet/emulex/benet/be_ethtool.c 
b/drivers/net/ethernet/emulex/benet/be_ethtool.c
index c569cd7..71940b9 100644
--- a/drivers/net/ethernet/emulex/benet/be_ethtool.c
+++ b/drivers/net/ethernet/emulex/benet/be_ethtool.c
@@ -1196,9 +1196,17 @@ static void be_get_channels(struct net_device *netdev,
struct ethtool_channels *ch)
 {
struct be_adapter *adapter = netdev_priv(netdev);
+   u16 num_rx_irqs = max_t(u16, adapter->num_rss_qs, 1);
 
-   ch->combined_count = adapter->num_evt_qs;
-   ch->max_combined = be_max_qs(adapter);
+   /* num_tx_qs is always same as the number of irqs used for TX */
+   ch->combined_count = min(adapter->num_tx_qs, num_rx_irqs);
+   ch->rx_count = num_rx_irqs - ch->combined_count;
+   ch->tx_count = adapter->num_tx_qs - ch->combined_count;
+
+   ch->max_combined = be_max_qp_irqs(adapter);
+   /* The user must create atleast one combined channel */
+   ch->max_rx = be_max_rx_irqs(adapter) - 1;
+   ch->max_tx = be_max_tx_irqs(adapter) - 1;
 }
 
 static int be_set_channels(struct net_device  *netdev,
@@ -1207,11 +1215,22 @@ static int be_set_channels(struct net_device  *netdev,
struct be_adapter *adapter = netdev_priv(netdev);
int status;
 
-   if (ch->rx_count || ch->tx_count || ch->other_count ||
-   !ch->combined_count || ch->combined_count > be_max_qs(adapter))
+   /* we support either only combined channels or a combination of
+* combined and either RX-only or TX-only channels.
+*/
+   if (ch->other_count || !ch->combined_count ||
+   (ch->rx_count && ch->tx_count))
+   return -EINVAL;
+
+   if (ch->combined_count > be_max_qp_irqs(adapter) ||
+   (ch->rx_count &&
+(ch->rx_count + ch->combined_count) > be_m

[net-next PATCH 5/5] be2net: update be2net maintainers list

2016-06-22 Thread Sathya Perla
This patch removes Padmanabh's name from the maintainers list as he's no
longer with the company. It also adds the driver name on the headline to
make it easy to lookup the maintainers list by the driver name.

Signed-off-by: Sathya Perla 
---
 MAINTAINERS | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 50f69ba..cab9975 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -10280,10 +10280,9 @@ W: http://www.avagotech.com
 S: Supported
 F: drivers/scsi/be2iscsi/
 
-Emulex 10Gbps NIC BE2, BE3-R, Lancer, Skyhawk-R DRIVER
+Emulex 10Gbps NIC BE2, BE3-R, Lancer, Skyhawk-R DRIVER (be2net)
 M:     Sathya Perla 
 M: Ajit Khaparde 
-M: Padmanabh Ratnakar 
 M: Sriharsha Basavapatna 
 M: Somnath Kotur 
 L: netdev@vger.kernel.org
-- 
2.4.1



[net-next PATCH 3/5] be2net: Fix broadcast echoes from EVB in BE3

2016-06-22 Thread Sathya Perla
From: Somnath Kotur 

On SR-IOV profiles, when the user connects a Linux Bridge or OVS to a BE3
vport, they suffer the "broadcast/multicast echo" problem. BE3 EVB echoes
broadcast and multicast packets back to PF's vport confusing the
Linux bridge.  BE3 relies on the src-mac addr being programmed on the
interface to avoid sending back an echo of a broadcast or multicast packet
on a vPort. When a Linux bridge is connected to a BE3, the mac-addr of the
VM behind the bridge doesn't get configured on the vPort and so echo
cancellation doesn't work.
This patch worksaround this problem by disabling the EVB initially
and re-enabling it *only* when SR-IOV is enabled by the user. For the
driver fix to work, the BE3 FW version must be >= 11.1.84.0.

Signed-off-by: Somnath Kotur 
Signed-off-by: Sathya Perla 
---
 drivers/net/ethernet/emulex/benet/be_cmds.c | 11 ++-
 drivers/net/ethernet/emulex/benet/be_main.c | 23 +++
 2 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c 
b/drivers/net/ethernet/emulex/benet/be_cmds.c
index 29aeb91..a98b6ab 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.c
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.c
@@ -87,6 +87,11 @@ static struct be_cmd_priv_map cmd_priv_map[] = {
CMD_SUBSYSTEM_LOWLEVEL,
BE_PRIV_DEVCFG | BE_PRIV_DEVSEC
},
+   {
+   OPCODE_COMMON_SET_HSW_CONFIG,
+   CMD_SUBSYSTEM_COMMON,
+   BE_PRIV_DEVCFG | BE_PRIV_VHADM
+   },
 };
 
 static bool be_cmd_allowed(struct be_adapter *adapter, u8 opcode, u8 subsystem)
@@ -3850,6 +3855,10 @@ int be_cmd_set_hsw_config(struct be_adapter *adapter, 
u16 pvid,
void *ctxt;
int status;
 
+   if (!be_cmd_allowed(adapter, OPCODE_COMMON_SET_HSW_CONFIG,
+   CMD_SUBSYSTEM_COMMON))
+   return -EPERM;
+
spin_lock_bh(&adapter->mcc_lock);
 
wrb = wrb_from_mccq(adapter);
@@ -3871,7 +3880,7 @@ int be_cmd_set_hsw_config(struct be_adapter *adapter, u16 
pvid,
AMAP_SET_BITS(struct amap_set_hsw_context, pvid_valid, ctxt, 1);
AMAP_SET_BITS(struct amap_set_hsw_context, pvid, ctxt, pvid);
}
-   if (!BEx_chip(adapter) && hsw_mode) {
+   if (hsw_mode) {
AMAP_SET_BITS(struct amap_set_hsw_context, interface_id,
  ctxt, adapter->hba_port_num);
AMAP_SET_BITS(struct amap_set_hsw_context, pport, ctxt, 1);
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c 
b/drivers/net/ethernet/emulex/benet/be_main.c
index a654c12..f11a19b 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -3729,6 +3729,11 @@ static void be_vf_clear(struct be_adapter *adapter)
 
be_cmd_if_destroy(adapter, vf_cfg->if_handle, vf + 1);
}
+
+   if (BE3_chip(adapter))
+   be_cmd_set_hsw_config(adapter, 0, 0,
+ adapter->if_handle,
+ PORT_FWD_TYPE_PASSTHRU, 0);
 done:
kfree(adapter->vf_cfg);
adapter->num_vfs = 0;
@@ -4019,6 +4024,15 @@ static int be_vf_setup(struct be_adapter *adapter)
}
}
 
+   if (BE3_chip(adapter)) {
+   /* On BE3, enable VEB only when SRIOV is enabled */
+   status = be_cmd_set_hsw_config(adapter, 0, 0,
+  adapter->if_handle,
+  PORT_FWD_TYPE_VEB, 0);
+   if (status)
+   goto err;
+   }
+
adapter->flags |= BE_FLAGS_SRIOV_ENABLED;
return 0;
 err:
@@ -4564,6 +4578,15 @@ static int be_setup(struct be_adapter *adapter)
be_cmd_set_logical_link_config(adapter,
   IFLA_VF_LINK_STATE_AUTO, 0);
 
+   /* BE3 EVB echoes broadcast/multicast packets back to PF's vport
+* confusing a linux bridge or OVS that it might be connected to.
+* Set the EVB to PASSTHRU mode which effectively disables the EVB
+* when SRIOV is not enabled.
+*/
+   if (BE3_chip(adapter))
+   be_cmd_set_hsw_config(adapter, 0, 0, adapter->if_handle,
+ PORT_FWD_TYPE_PASSTHRU, 0);
+
if (adapter->num_vfs)
be_vf_setup(adapter);
 
-- 
2.4.1



[net-next PATCH 0/3] be2net: patch set

2016-06-06 Thread Sathya Perla
Hi David, the following patch set contains three non-critical fixes that
can go into the net-next tree.

Patch 1 fixes the logic for provisioning queue pairs on VFs to take into
account the limit on number of TXQs too as in some profiles the number
of TXQs is less than that of RXQs.

Patch 2 enables WoL support from shutdown on Skyhawk.

Patch 3 enhances the logic for provisioning queue pairs on VFs on
SR-IOV over multi-partition configs. Each PF (partition) on a port has to
compute the number of RSS tables it's VFs can use.

thanks!

Somnath Kotur (1):
  be2net: Fix provisioning of RSS for VFs in multi-partition
configurations

Sriharsha Basavapatna (1):
  be2net: Enable Wake-On-LAN from shutdown for Skyhawk

Suresh Reddy (1):
  be2net: use max-TXQs limit too while provisioning VF queue pairs

 drivers/net/ethernet/emulex/benet/be.h |  16 +-
 drivers/net/ethernet/emulex/benet/be_cmds.c| 147 +-
 drivers/net/ethernet/emulex/benet/be_cmds.h|  14 +-
 drivers/net/ethernet/emulex/benet/be_ethtool.c |  35 -
 drivers/net/ethernet/emulex/benet/be_main.c| 203 +++--
 5 files changed, 256 insertions(+), 159 deletions(-)

-- 
2.4.1



[net-next PATCH 3/3] be2net: Fix provisioning of RSS for VFs in multi-partition configurations

2016-06-06 Thread Sathya Perla
From: Somnath Kotur 

Currently, we do not distribute queue resources to enable RSS for VFs
in multi-channel/partition configurations.
Fix this by having each PF(SRIOV capable) calculate it's share of the
15 RSS Policy Tables available per port before provisioning resources for
all the VFs.
This  proportional share calculation is done based on division of the
PF's MAX VFs with the Total MAX VFs on that port. It also needs to
learn about the no: of NIC PFs on the port and subtract that from
the 15 RSS Policy Tables on the port.

Signed-off-by: Somnath Kotur 
Signed-off-by: Sathya Perla 
---
 drivers/net/ethernet/emulex/benet/be.h  | 15 -
 drivers/net/ethernet/emulex/benet/be_cmds.c | 52 +-
 drivers/net/ethernet/emulex/benet/be_cmds.h |  8 ++-
 drivers/net/ethernet/emulex/benet/be_main.c | 85 -
 4 files changed, 130 insertions(+), 30 deletions(-)

diff --git a/drivers/net/ethernet/emulex/benet/be.h 
b/drivers/net/ethernet/emulex/benet/be.h
index ee0bdb7..e1e6c40 100644
--- a/drivers/net/ethernet/emulex/benet/be.h
+++ b/drivers/net/ethernet/emulex/benet/be.h
@@ -97,7 +97,8 @@
 * SURF/DPDK
 */
 
-#define MAX_RSS_IFACES 15
+#define MAX_PORT_RSS_TABLES15
+#define MAX_NIC_FUNCS  16
 #define MAX_RX_QS  32
 #define MAX_EVT_QS 32
 #define MAX_TX_QS  32
@@ -445,6 +446,16 @@ struct be_resources {
u32 if_cap_flags;
u32 vf_if_cap_flags;/* VF if capability flags */
u32 flags;
+   /* Calculated PF Pool's share of RSS Tables. This is not enforced by
+* the FW, but is a self-imposed driver limitation.
+*/
+   u16 max_rss_tables;
+};
+
+/* These are port-wide values */
+struct be_port_resources {
+   u16 max_vfs;
+   u16 nic_pfs;
 };
 
 #define be_is_os2bmc_enabled(adapter) (adapter->flags & BE_FLAGS_OS2BMC)
@@ -635,6 +646,8 @@ struct be_adapter {
 #define be_max_rxqs(adapter)   (adapter->res.max_rx_qs)
 #define be_max_eqs(adapter)(adapter->res.max_evt_qs)
 #define be_if_cap_flags(adapter)   (adapter->res.if_cap_flags)
+#define be_max_pf_pool_rss_tables(adapter) \
+   (adapter->pool_res.max_rss_tables)
 
 static inline u16 be_max_qs(struct be_adapter *adapter)
 {
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c 
b/drivers/net/ethernet/emulex/benet/be_cmds.c
index ddc8611..29aeb91 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.c
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.c
@@ -4363,9 +4363,35 @@ err:
return status;
 }
 
+/* This routine returns a list of all the NIC PF_nums in the adapter */
+u16 be_get_nic_pf_num_list(u8 *buf, u32 desc_count, u16 *nic_pf_nums)
+{
+   struct be_res_desc_hdr *hdr = (struct be_res_desc_hdr *)buf;
+   struct be_pcie_res_desc *pcie = NULL;
+   int i;
+   u16 nic_pf_count = 0;
+
+   for (i = 0; i < desc_count; i++) {
+   if (hdr->desc_type == PCIE_RESOURCE_DESC_TYPE_V0 ||
+   hdr->desc_type == PCIE_RESOURCE_DESC_TYPE_V1) {
+   pcie = (struct be_pcie_res_desc *)hdr;
+   if (pcie->pf_state && (pcie->pf_type == MISSION_NIC ||
+  pcie->pf_type == MISSION_RDMA)) {
+   nic_pf_nums[nic_pf_count++] = pcie->pf_num;
+   }
+   }
+
+   hdr->desc_len = hdr->desc_len ? : RESOURCE_DESC_SIZE_V0;
+   hdr = (void *)hdr + hdr->desc_len;
+   }
+   return nic_pf_count;
+}
+
 /* Will use MBOX only if MCCQ has not been created */
 int be_cmd_get_profile_config(struct be_adapter *adapter,
- struct be_resources *res, u8 query, u8 domain)
+ struct be_resources *res,
+ struct be_port_resources *port_res,
+ u8 profile_type, u8 query, u8 domain)
 {
struct be_cmd_resp_get_profile_config *resp;
struct be_cmd_req_get_profile_config *req;
@@ -4392,7 +4418,7 @@ int be_cmd_get_profile_config(struct be_adapter *adapter,
 
if (!lancer_chip(adapter))
req->hdr.version = 1;
-   req->type = ACTIVE_PROFILE_TYPE;
+   req->type = profile_type;
req->hdr.domain = domain;
 
/* When QUERY_MODIFIABLE_FIELDS_TYPE bit is set, cmd returns the
@@ -4409,6 +4435,28 @@ int be_cmd_get_profile_config(struct be_adapter *adapter,
resp = cmd.va;
desc_count = le16_to_cpu(resp->desc_count);
 
+   if (port_res) {
+   u16 nic_pf_cnt = 0, i;
+   u16 nic_pf_num_list[MAX_NIC_FUNCS];
+
+   nic_pf_cnt = be_get_nic_pf_num_list(resp->func_param,
+

[net-next PATCH 2/3] be2net: Enable Wake-On-LAN from shutdown for Skyhawk

2016-06-06 Thread Sathya Perla
From: Sriharsha Basavapatna 

Skyhawk does support wake-up from ACPI shutdown state - S5, provided the
platform supports it (like Auxiliary power source etc). The changes listed
below are done to fix this.

1) There's no need to defer the HW configuration of WOL to be_suspend().
Remove this in be_suspend() and move it to be_set_wol() ethtool function
so it is configured directly in the context of ethtool. This automatically
takes care of the shutdown case.

2) The driver incorrectly uses WOL_CAP field in the FW response to
get_acpi_wol_cap() command, to determine if WOL is enabled. Instead the
driver must rely on the macaddr field in the response to infer WOL state.

3) In be_get_config() during init, if we find that WOL is enabled in FW,
call pci_enable_wake() to enable pmcsr.pme_en bit. This is needed to
support persistent WOL configuration provided by the FW in some platforms.

4) Remove code in be_set_wol() that writes to PCICFG_PM_CONTROL_OFFSET
to set pme_en bit; pci_enable_wake() sets that.

Fixes: 028991e49 ("Enabling Wake-on-LAN is not supported in S5 state")
Signed-off-by: Sriharsha Basavapatna 
Signed-off-by: Sathya Perla 
---
 drivers/net/ethernet/emulex/benet/be_cmds.c|  5 ++-
 drivers/net/ethernet/emulex/benet/be_cmds.h|  4 ++-
 drivers/net/ethernet/emulex/benet/be_ethtool.c | 35 ++---
 drivers/net/ethernet/emulex/benet/be_main.c| 42 ++
 4 files changed, 39 insertions(+), 47 deletions(-)

diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c 
b/drivers/net/ethernet/emulex/benet/be_cmds.c
index bef92c4..ddc8611 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.c
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.c
@@ -4023,7 +4023,10 @@ int be_cmd_get_acpi_wol_cap(struct be_adapter *adapter)
resp = (struct be_cmd_resp_acpi_wol_magic_config_v1 *)cmd.va;
 
adapter->wol_cap = resp->wol_settings;
-   if (adapter->wol_cap & BE_WOL_CAP)
+
+   /* Non-zero macaddr indicates WOL is enabled */
+   if (adapter->wol_cap & BE_WOL_CAP &&
+   !is_zero_ether_addr(resp->magic_mac))
adapter->wol_en = true;
}
 err:
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.h 
b/drivers/net/ethernet/emulex/benet/be_cmds.h
index b63ae37..855a170 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.h
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.h
@@ -1556,7 +1556,9 @@ struct be_cmd_resp_acpi_wol_magic_config_v1 {
u8 rsvd0[2];
u8 wol_settings;
u8 rsvd1[5];
-   u32 rsvd2[295];
+   u32 rsvd2[288];
+   u8 magic_mac[6];
+   u8 rsvd3[22];
 } __packed;
 
 #define BE_GET_WOL_CAP 2
diff --git a/drivers/net/ethernet/emulex/benet/be_ethtool.c 
b/drivers/net/ethernet/emulex/benet/be_ethtool.c
index 2ff6916..c569cd7 100644
--- a/drivers/net/ethernet/emulex/benet/be_ethtool.c
+++ b/drivers/net/ethernet/emulex/benet/be_ethtool.c
@@ -793,6 +793,11 @@ static void be_get_wol(struct net_device *netdev, struct 
ethtool_wolinfo *wol)
 static int be_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
 {
struct be_adapter *adapter = netdev_priv(netdev);
+   struct device *dev = &adapter->pdev->dev;
+   struct be_dma_mem cmd;
+   u8 mac[ETH_ALEN];
+   bool enable;
+   int status;
 
if (wol->wolopts & ~WAKE_MAGIC)
return -EOPNOTSUPP;
@@ -802,12 +807,32 @@ static int be_set_wol(struct net_device *netdev, struct 
ethtool_wolinfo *wol)
return -EOPNOTSUPP;
}
 
-   if (wol->wolopts & WAKE_MAGIC)
-   adapter->wol_en = true;
-   else
-   adapter->wol_en = false;
+   cmd.size = sizeof(struct be_cmd_req_acpi_wol_magic_config);
+   cmd.va = dma_zalloc_coherent(dev, cmd.size, &cmd.dma, GFP_KERNEL);
+   if (!cmd.va)
+   return -ENOMEM;
 
-   return 0;
+   eth_zero_addr(mac);
+
+   enable = wol->wolopts & WAKE_MAGIC;
+   if (enable)
+   ether_addr_copy(mac, adapter->netdev->dev_addr);
+
+   status = be_cmd_enable_magic_wol(adapter, mac, &cmd);
+   if (status) {
+   dev_err(dev, "Could not set Wake-on-lan mac address\n");
+   status = be_cmd_status(status);
+   goto err;
+   }
+
+   pci_enable_wake(adapter->pdev, PCI_D3hot, enable);
+   pci_enable_wake(adapter->pdev, PCI_D3cold, enable);
+
+   adapter->wol_en = enable ? true : false;
+
+err:
+   dma_free_coherent(dev, cmd.size, cmd.va, cmd.dma);
+   return status;
 }
 
 static int be_test_ddr_dma(struct be_adapter *adapter)
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c 
b/drivers/net/ethernet/emulex/benet/be_main.c
index 8601047..32823a7 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/ne

[net-next PATCH 1/3] be2net: use max-TXQs limit too while provisioning VF queue pairs

2016-06-06 Thread Sathya Perla
From: Suresh Reddy 

When the PF driver provisions resources for VFs, it currently only looks
at max RSS queues available to calculate the number of VF queue pairs.
This logic breaks when there are less number of TX-queues than RSS-queues.
This patch fixes this problem by using the max-TXQs available in the
PF-pool in the calculations. As a part of this change the
be_calculate_vf_qs() routine is renamed as be_calculate_vf_res() and the
code that calculates limits on other related resources is moved here to
contain all resource calculation code inside one routine.

Signed-off-by: Suresh Reddy 
Signed-off-by: Sathya Perla 
---
 drivers/net/ethernet/emulex/benet/be.h  |  1 +
 drivers/net/ethernet/emulex/benet/be_cmds.c | 90 +++--
 drivers/net/ethernet/emulex/benet/be_cmds.h |  2 +-
 drivers/net/ethernet/emulex/benet/be_main.c | 82 +-
 4 files changed, 90 insertions(+), 85 deletions(-)

diff --git a/drivers/net/ethernet/emulex/benet/be.h 
b/drivers/net/ethernet/emulex/benet/be.h
index fe3763d..ee0bdb7 100644
--- a/drivers/net/ethernet/emulex/benet/be.h
+++ b/drivers/net/ethernet/emulex/benet/be.h
@@ -444,6 +444,7 @@ struct be_resources {
u16 max_evt_qs;
u32 if_cap_flags;
u32 vf_if_cap_flags;/* VF if capability flags */
+   u32 flags;
 };
 
 #define be_is_os2bmc_enabled(adapter) (adapter->flags & BE_FLAGS_OS2BMC)
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c 
b/drivers/net/ethernet/emulex/benet/be_cmds.c
index 22402db..bef92c4 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.c
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.c
@@ -4465,7 +4465,7 @@ static int be_cmd_set_profile_config(struct be_adapter 
*adapter, void *desc,
 }
 
 /* Mark all fields invalid */
-static void be_reset_nic_desc(struct be_nic_res_desc *nic)
+void be_reset_nic_desc(struct be_nic_res_desc *nic)
 {
memset(nic, 0, sizeof(*nic));
nic->unicast_mac_count = 0x;
@@ -4534,73 +4534,9 @@ int be_cmd_config_qos(struct be_adapter *adapter, u32 
max_rate, u16 link_speed,
 1, version, domain);
 }
 
-static void be_fill_vf_res_template(struct be_adapter *adapter,
-   struct be_resources pool_res,
-   u16 num_vfs, u16 num_vf_qs,
-   struct be_nic_res_desc *nic_vft)
-{
-   u32 vf_if_cap_flags = pool_res.vf_if_cap_flags;
-   struct be_resources res_mod = {0};
-
-   /* Resource with fields set to all '1's by GET_PROFILE_CONFIG cmd,
-* which are modifiable using SET_PROFILE_CONFIG cmd.
-*/
-   be_cmd_get_profile_config(adapter, &res_mod, RESOURCE_MODIFIABLE, 0);
-
-   /* If RSS IFACE capability flags are modifiable for a VF, set the
-* capability flag as valid and set RSS and DEFQ_RSS IFACE flags if
-* more than 1 RSSQ is available for a VF.
-* Otherwise, provision only 1 queue pair for VF.
-*/
-   if (res_mod.vf_if_cap_flags & BE_IF_FLAGS_RSS) {
-   nic_vft->flags |= BIT(IF_CAPS_FLAGS_VALID_SHIFT);
-   if (num_vf_qs > 1) {
-   vf_if_cap_flags |= BE_IF_FLAGS_RSS;
-   if (pool_res.if_cap_flags & BE_IF_FLAGS_DEFQ_RSS)
-   vf_if_cap_flags |= BE_IF_FLAGS_DEFQ_RSS;
-   } else {
-   vf_if_cap_flags &= ~(BE_IF_FLAGS_RSS |
-BE_IF_FLAGS_DEFQ_RSS);
-   }
-   } else {
-   num_vf_qs = 1;
-   }
-
-   if (res_mod.vf_if_cap_flags & BE_IF_FLAGS_VLAN_PROMISCUOUS) {
-   nic_vft->flags |= BIT(IF_CAPS_FLAGS_VALID_SHIFT);
-   vf_if_cap_flags &= ~BE_IF_FLAGS_VLAN_PROMISCUOUS;
-   }
-
-   nic_vft->cap_flags = cpu_to_le32(vf_if_cap_flags);
-   nic_vft->rq_count = cpu_to_le16(num_vf_qs);
-   nic_vft->txq_count = cpu_to_le16(num_vf_qs);
-   nic_vft->rssq_count = cpu_to_le16(num_vf_qs);
-   nic_vft->cq_count = cpu_to_le16(pool_res.max_cq_count /
-   (num_vfs + 1));
-
-   /* Distribute unicast MACs, VLANs, IFACE count and MCCQ count equally
-* among the PF and it's VFs, if the fields are changeable
-*/
-   if (res_mod.max_uc_mac == FIELD_MODIFIABLE)
-   nic_vft->unicast_mac_count = cpu_to_le16(pool_res.max_uc_mac /
-(num_vfs + 1));
-
-   if (res_mod.max_vlans == FIELD_MODIFIABLE)
-   nic_vft->vlan_count = cpu_to_le16(pool_res.max_vlans /
- (num_vfs + 1));
-
-   if (res_mod.max_iface_count == FIELD_MODIFIABLE)
-   nic_vft->iface_count = cpu_to_le16(pool_res.max_iface_count /
-   

Re: [PATCH 1/1] be2net: Don't leak iomapped memory on removal.

2016-03-03 Thread Sathya Perla
On Fri, Mar 4, 2016 at 4:05 AM, Douglas Miller
 wrote:
> The adapter->pcicfg resource is either mapped via pci_iomap() or
> derived from adapter->db. During be_remove() this resource was ignored
> and so could remain mapped after remove.
>
> Add a flag to track whether adapter->pcicfg was mapped or not, then
> use that flag in be_unmap_pci_bars() to unmap if required.
>
> Signed-off-by: Douglas Miller 

Acked-by: Sathya Perla 

Could you pls add the "fixes" tag line to this patch:
Fixes: 25848c901 ("use PCI MMIO read instead of config read for errors")

thanks for the fix,
-Sathya


[PATCH] be2net: don't enable multicast flag in be_enable_if_filters() routine

2016-03-02 Thread Sathya Perla
From: Venkat Duvvuru 

When the interface is opened (in be_open()) the routine
be_enable_if_filters() must be called to switch on the basic filtering
capabilities of an interface that are not changed at run-time.
These include the flags UNTAGGED, BROADCAST and PASS_L3L4_ERRORS.
Other flags such as MULTICAST and PROMISC must be enabled later by
be_set_rx_mode() based on the state in the netdev/adapter struct.

be_enable_if_filters() routine is wrongly trying to enable MULTICAST flag
without checking the current adapter state. This can cause the RX_FILTER
cmds to the FW to fail.  This patch fixes this problem by only enabling
the basic filtering flags in be_enable_if_filters().

The VF must be able to issue RX_FILTER cmd with any filter flag, as long
as the PF allowed those flags (if_cap_flags) in the iface it provisioned
for the VF. This rule is applicable even when the VF doesn't have the
FILTMGMT privilege. There is a bug in BE3 FW that wrongly fails RX_FILTER
multicast programming cmds on VFs that don't have FILTMGMT privilege.
This patch also helps in insulating the VF driver from be_open failures due
to the FW bug. A fix for the BE3 FW issue will be available in
versions >= 11.0.283.0 and 10.6.334.0

Reported-by: Ivan Vecera 
Signed-off-by: Venkat Duvvuru 
Signed-off-by: Sathya Perla 
---
 drivers/net/ethernet/emulex/benet/be_cmds.h |  9 ++---
 drivers/net/ethernet/emulex/benet/be_main.c | 16 +---
 2 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.h 
b/drivers/net/ethernet/emulex/benet/be_cmds.h
index 241819b..6d9a8d7 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.h
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.h
@@ -622,10 +622,13 @@ enum be_if_flags {
 BE_IF_FLAGS_VLAN_PROMISCUOUS |\
 BE_IF_FLAGS_MCAST_PROMISCUOUS)
 
-#define BE_IF_EN_FLAGS (BE_IF_FLAGS_BROADCAST | BE_IF_FLAGS_PASS_L3L4_ERRORS |\
-   BE_IF_FLAGS_MULTICAST | BE_IF_FLAGS_UNTAGGED)
+#define BE_IF_FILT_FLAGS_BASIC (BE_IF_FLAGS_BROADCAST | \
+   BE_IF_FLAGS_PASS_L3L4_ERRORS | \
+   BE_IF_FLAGS_UNTAGGED)
 
-#define BE_IF_ALL_FILT_FLAGS   (BE_IF_EN_FLAGS | BE_IF_FLAGS_ALL_PROMISCUOUS)
+#define BE_IF_ALL_FILT_FLAGS   (BE_IF_FILT_FLAGS_BASIC | \
+BE_IF_FLAGS_MULTICAST | \
+BE_IF_FLAGS_ALL_PROMISCUOUS)
 
 /* An RX interface is an object with one or more MAC addresses and
  * filtering capabilities. */
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c 
b/drivers/net/ethernet/emulex/benet/be_main.c
index f99de36..db81e3d 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -125,6 +125,11 @@ static const char * const ue_status_hi_desc[] = {
"Unknown"
 };
 
+#define BE_VF_IF_EN_FLAGS  (BE_IF_FLAGS_UNTAGGED | \
+BE_IF_FLAGS_BROADCAST | \
+BE_IF_FLAGS_MULTICAST | \
+BE_IF_FLAGS_PASS_L3L4_ERRORS)
+
 static void be_queue_free(struct be_adapter *adapter, struct be_queue_info *q)
 {
struct be_dma_mem *mem = &q->dma_mem;
@@ -3537,7 +3542,7 @@ static int be_enable_if_filters(struct be_adapter 
*adapter)
 {
int status;
 
-   status = be_cmd_rx_filter(adapter, BE_IF_EN_FLAGS, ON);
+   status = be_cmd_rx_filter(adapter, BE_IF_FILT_FLAGS_BASIC, ON);
if (status)
return status;
 
@@ -3857,8 +3862,7 @@ static int be_vfs_if_create(struct be_adapter *adapter)
int status;
 
/* If a FW profile exists, then cap_flags are updated */
-   cap_flags = BE_IF_FLAGS_UNTAGGED | BE_IF_FLAGS_BROADCAST |
-   BE_IF_FLAGS_MULTICAST | BE_IF_FLAGS_PASS_L3L4_ERRORS;
+   cap_flags = BE_VF_IF_EN_FLAGS;
 
for_all_vfs(adapter, vf_cfg, vf) {
if (!BE3_chip(adapter)) {
@@ -3874,10 +3878,8 @@ static int be_vfs_if_create(struct be_adapter *adapter)
}
}
 
-   en_flags = cap_flags & (BE_IF_FLAGS_UNTAGGED |
-   BE_IF_FLAGS_BROADCAST |
-   BE_IF_FLAGS_MULTICAST |
-   BE_IF_FLAGS_PASS_L3L4_ERRORS);
+   /* PF should enable IF flags during proxy if_create call */
+   en_flags = cap_flags & BE_VF_IF_EN_FLAGS;
status = be_cmd_if_create(adapter, cap_flags, en_flags,
  &vf_cfg->if_handle, vf + 1);
if (status)
-- 
2.4.1



Re: [PATCH net] be2net: don't {en,dis}able filters on BE3 when transparent tagging is enabled

2016-02-28 Thread Sathya Perla
On Fri, Feb 26, 2016 at 6:43 PM, Ivan Vecera  wrote:
> Should the MULTICAST bit be masked in any be_cmd_rx_filter() call on BE3's
> VFs if the trans. tagging is enabled?

Not on any be_cmd_rx_filter() call, but on the first call in
be_open()->be_if_enable_filters() where the basic filtering flags are
being enabled and the driver is explicitly checking for the return
status. We have a fix for this already in our internal builds that
hasn't been upstreamed yet. Will send out a patch for this asap.
Thanks for the help on this Ivan!


Re: [PATCH net] be2net: don't {en,dis}able filters on BE3 when transparent tagging is enabled

2016-02-26 Thread Sathya Perla
On Fri, Feb 26, 2016 at 5:54 PM, Ivan Vecera  wrote:
> On 26.2.2016 12:36, Sathya Perla wrote:
>>
>> On Fri, Feb 26, 2016 at 2:16 PM, Ivan Vecera  wrote:
>>>
>>> The FILTMGMT privilege is necessary on BE3 chip to manipulare filters
>>> like MC, UC list management, VLAN filter, promisc mode... This privilege
>>> is dropped for VFs when transparrent tagging is enabled on them. This
>>> prevents to make interface up for such VF because be_enable_if_filters()
>>> called from be_open() fails thus be_open() also fails.
>>>
>>> Cc: Sathya Perla 
>>> Cc: Sriharsha Basavapatna 
>>> Signed-off-by: Ivan Vecera 
...
>>
>>
>> Ivan, in the be_enable_if_filters() routine the VF tries to enable the
>> basic filtering flags (not promisc mode etc) via the RX_FILTER cmd,
>> for which the VFs shouldn't need any FILTMGMT privileges. I also don't
>> expect be_cmd_pmac_add() to fail as the PF would have already
>> provisioned the mac-addr for the VF.
>> We should be able to reproduce this first thing Monday morning and see
>> what's wrong. Also, as the privilege rules are same across all chips,
>> any fix must be applicable for all chips that be2net supports.
>
> Hi Sathya,
> if the transparent VLAN tagging is enabled then be_enable_if_filters() will
> fail and be_open() will also fail. This happens only on BE3 not on Lancer as
> this does not support SR-IOV. I don't see any problem on Skyhawk.
>
> Log from the guest after 'ip link set ... up':
>
> [root@bootp-73-131-183 ~]# dmesg | tail -n 20
> pci :00:07.0: no hotplug settings from platform
> be2net :00:07.0: be2net version is 10.6.0.3r
> be2net :00:07.0: enabling device (0040 -> 0042)
> be2net :00:07.0: setting latency timer to 64
> be2net :00:07.0: FW config: function_mode=0x14003, function_caps=0x4
> be2net :00:07.0: VF is not privileged to issue opcode 125-1
> be2net :00:07.0: Max: txqs 1, rxqs 1, rss 0, eqs 1, vfs 0
> be2net :00:07.0: Max: uc-macs 2, mc-macs 64, vlans 64
>   alloc irq_desc for 29 on node -1
>   alloc kstat_irqs on node -1
> be2net :00:07.0: irq 29 for MSI/MSI-X
> be2net :00:07.0: enabled 1 MSI-x vector(s) for NIC
> be2net :00:07.0: created 1 TX queue(s)
> be2net :00:07.0: created 1 RX queue(s)
> be2net :00:07.0: LPVID: 3
> be2net :00:07.0: FW version is 10.4.255.25
> be2net :00:07.0: HW Flow control - TX:1 RX:1
> be2net :00:07.0: Emulex OneConnect(be3): VF  port 0
> be2net :00:07.0: VF is not privileged to issue opcode 34-1
> be2net :00:07.0: VF is not privileged to issue opcode 60-1
>
> The be_open() calls be_enable_if_filters() -> be_cmd_rx_filter(). Command
> with opcode 34 alias NTWK_RX_FILTER fails thus be_open() also fails and
> be_close() is called as cleaning-up action. The be_close() calls then
> be_disable_if_filters() that calls be_cmd_pmac_del() (opcode 60). This also
> fails.
>
> As I has written above under Skyhawk this does not happen... so I has
> created BE3 specific patch.
>

Ivan, thanks for the dmesg log. I think the root-cause of this issue
is the MULTICAST bit in the BE_IF_EN_FLAGS. The FW is not allowing the
VF driver's be_cmd_rx_filter(BE_IF_EN_FLAGS) call. In
be_enable_if_filters() we are sensitive to this error, but in
be_set_rx_mode() we ignore any FW errors.
I'll provide an update Monday morningthanks!


Re: [PATCH net] be2net: don't {en,dis}able filters on BE3 when transparent tagging is enabled

2016-02-26 Thread Sathya Perla
On Fri, Feb 26, 2016 at 2:16 PM, Ivan Vecera  wrote:
> The FILTMGMT privilege is necessary on BE3 chip to manipulare filters
> like MC, UC list management, VLAN filter, promisc mode... This privilege
> is dropped for VFs when transparrent tagging is enabled on them. This
> prevents to make interface up for such VF because be_enable_if_filters()
> called from be_open() fails thus be_open() also fails.
>
> Cc: Sathya Perla 
> Cc: Sriharsha Basavapatna 
> Signed-off-by: Ivan Vecera 
> ---
>  drivers/net/ethernet/emulex/benet/be_main.c | 11 +++
>  1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/ethernet/emulex/benet/be_main.c 
> b/drivers/net/ethernet/emulex/benet/be_main.c
> index f99de36..2e176f6 100644
> --- a/drivers/net/ethernet/emulex/benet/be_main.c
> +++ b/drivers/net/ethernet/emulex/benet/be_main.c
> @@ -3430,7 +3430,8 @@ static int be_close(struct net_device *netdev)
> if (!(adapter->flags & BE_FLAGS_SETUP_DONE))
> return 0;
>
> -   be_disable_if_filters(adapter);
> +   if (!(BEx_chip(adapter) && be_pvid_tagging_enabled(adapter)))
> +   be_disable_if_filters(adapter);
>
> if (adapter->flags & BE_FLAGS_NAPI_ENABLED) {
> for_all_evt_queues(adapter, eqo, i) {
> @@ -3571,9 +3572,11 @@ static int be_open(struct net_device *netdev)
> if (status)
> goto err;
>
> -   status = be_enable_if_filters(adapter);
> -   if (status)
> -   goto err;
> +   if (!(BEx_chip(adapter) && be_pvid_tagging_enabled(adapter))) {
> +   status = be_enable_if_filters(adapter);
> +   if (status)
> +   goto err;

Ivan, in the be_enable_if_filters() routine the VF tries to enable the
basic filtering flags (not promisc mode etc) via the RX_FILTER cmd,
for which the VFs shouldn't need any FILTMGMT privileges. I also don't
expect be_cmd_pmac_add() to fail as the PF would have already
provisioned the mac-addr for the VF.
We should be able to reproduce this first thing Monday morning and see
what's wrong. Also, as the privilege rules are same across all chips,
any fix must be applicable for all chips that be2net supports.

thanks,
-Sathya


Re: [PATCH net-next v2] be2net: don't report EVB for older chipsets when SR-IOV is disabled

2016-02-11 Thread Sathya Perla
On Thu, Feb 11, 2016 at 12:42 PM, Ivan Vecera  wrote:
> The EVB (virtual bridge) functionality should be disabled on older BE3
> and Lancer chips if SR-IOV is disabled in the NIC's BIOS. This setting
> is identified by the zero value of total VFs reported by the card.
> The GET_HSW_CONFIG command cannot be used as it is not supported by
> these older chipset's FW.
>
> v2: added the comment

Acked-by: Sathya Perla 


Re: [PATCH net-next] be2net: don't report EVB for older chipsets when SR-IOV is disabled

2016-02-11 Thread Sathya Perla
On Wed, Feb 10, 2016 at 1:13 PM, Ivan Vecera  wrote:
>
> The EVB (virtual bridge) functionality should be disabled on older BE3
> and Lancer chips if SR-IOV is disabled in the NIC's BIOS. This setting
> is identified by the zero value of total VFs reported by the card.
> The GET_HSW_CONFIG command cannot be used as it is not supported > by these 
> older chipset's FW.
>
..
> ---
>  drivers/net/ethernet/emulex/benet/be_main.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/net/ethernet/emulex/benet/be_main.c 
> b/drivers/net/ethernet/emulex/benet/be_main.c
> index 9c1fc9d..886fe95 100644
> --- a/drivers/net/ethernet/emulex/benet/be_main.c
> +++ b/drivers/net/ethernet/emulex/benet/be_main.c
> @@ -4588,6 +4588,8 @@ static int be_ndo_bridge_getlink(struct sk_buff *skb, 
> u32 pid, u32 seq,
>
> /* BE and Lancer chips support VEB mode only */
> if (BEx_chip(adapter) || lancer_chip(adapter)) {
> +   if (!pci_sriov_get_totalvfs(adapter->pdev))
> +   return 0;

Ivan, could you add a one line comment above this check that says "On
BE3/Lancer the VEB is disabled in non-SRIOV profiles". This is to
differentiate this behavior from Skyhawk, where the VEB may be enabled
even in non-SRIOV profiles, like nPAR...

thanks,
-Sathya


[PATCH] update be2net maintainers' email addresses

2016-02-02 Thread Sathya Perla
be2net maintainers' email addresses changed from avagotech.com to
broadcom.com starting today. While updating the list, I'm also adding
Somnath's name to the list.

Signed-off-by: Sathya Perla 
---
 MAINTAINERS | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index f678c37..413777a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -9793,10 +9793,11 @@ S:  Supported
 F: drivers/scsi/be2iscsi/
 
 Emulex 10Gbps NIC BE2, BE3-R, Lancer, Skyhawk-R DRIVER
-M:     Sathya Perla 
-M: Ajit Khaparde 
-M: Padmanabh Ratnakar 
-M: Sriharsha Basavapatna 
+M:     Sathya Perla 
+M: Ajit Khaparde 
+M: Padmanabh Ratnakar 
+M: Sriharsha Basavapatna 
+M: Somnath Kotur 
 L: netdev@vger.kernel.org
 W: http://www.emulex.com
 S: Supported
-- 
2.4.1



Re: [PATCH] be2net: Delete an unnecessary check in two functions

2016-01-05 Thread Sathya Perla
On Fri, Jan 1, 2016 at 4:52 AM, SF Markus Elfring
 wrote:
> From: Markus Elfring 
> Date: Fri, 1 Jan 2016 00:11:57 +0100
>
> Remove two checks for null pointers which would be handled by usual
> error detection before.
>
> Signed-off-by: Markus Elfring 

Acked-by: Sathya Perla 

This patch is suitable for the net-next tree. Thanks!
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-next v3 04/10] be2net: move FW flash cmd code to be_cmds.c

2015-12-29 Thread Sathya Perla
From: Suresh Reddy 

All code relating to FW cmds is in be_cmds.[ch] excepting FW flash cmd
related code. This patch moves these routines from be_main.c to be_cmds.c

Signed-off-by: Suresh Reddy 
Signed-off-by: Sathya Perla 
---
 drivers/net/ethernet/emulex/benet/be_cmds.c | 583 +++-
 drivers/net/ethernet/emulex/benet/be_cmds.h |  15 +-
 drivers/net/ethernet/emulex/benet/be_main.c | 564 ---
 3 files changed, 578 insertions(+), 584 deletions(-)

diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c 
b/drivers/net/ethernet/emulex/benet/be_cmds.c
index 8083eca..da3b398 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.c
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.c
@@ -2291,10 +2291,11 @@ err:
return status;
 }
 
-int lancer_cmd_write_object(struct be_adapter *adapter, struct be_dma_mem *cmd,
-   u32 data_size, u32 data_offset,
-   const char *obj_name, u32 *data_written,
-   u8 *change_status, u8 *addn_status)
+static int lancer_cmd_write_object(struct be_adapter *adapter,
+  struct be_dma_mem *cmd, u32 data_size,
+  u32 data_offset, const char *obj_name,
+  u32 *data_written, u8 *change_status,
+  u8 *addn_status)
 {
struct be_mcc_wrb *wrb;
struct lancer_cmd_req_write_object *req;
@@ -2410,7 +2411,8 @@ int be_cmd_query_sfp_info(struct be_adapter *adapter)
return status;
 }
 
-int lancer_cmd_delete_object(struct be_adapter *adapter, const char *obj_name)
+static int lancer_cmd_delete_object(struct be_adapter *adapter,
+   const char *obj_name)
 {
struct lancer_cmd_req_delete_object *req;
struct be_mcc_wrb *wrb;
@@ -2485,9 +2487,9 @@ err_unlock:
return status;
 }
 
-int be_cmd_write_flashrom(struct be_adapter *adapter, struct be_dma_mem *cmd,
- u32 flash_type, u32 flash_opcode, u32 img_offset,
- u32 buf_size)
+static int be_cmd_write_flashrom(struct be_adapter *adapter,
+struct be_dma_mem *cmd, u32 flash_type,
+u32 flash_opcode, u32 img_offset, u32 buf_size)
 {
struct be_mcc_wrb *wrb;
struct be_cmd_write_flashrom *req;
@@ -2533,8 +2535,8 @@ err_unlock:
return status;
 }
 
-int be_cmd_get_flash_crc(struct be_adapter *adapter, u8 *flashed_crc,
-u16 img_optype, u32 img_offset, u32 crc_offset)
+static int be_cmd_get_flash_crc(struct be_adapter *adapter, u8 *flashed_crc,
+   u16 img_optype, u32 img_offset, u32 crc_offset)
 {
struct be_cmd_read_flash_crc *req;
struct be_mcc_wrb *wrb;
@@ -2571,6 +2573,567 @@ err:
return status;
 }
 
+static char flash_cookie[2][16] = {"*** SE FLAS", "H DIRECTORY *** "};
+
+static bool phy_flashing_required(struct be_adapter *adapter)
+{
+   return (adapter->phy.phy_type == PHY_TYPE_TN_8022 &&
+   adapter->phy.interface_type == PHY_TYPE_BASET_10GB);
+}
+
+static bool is_comp_in_ufi(struct be_adapter *adapter,
+  struct flash_section_info *fsec, int type)
+{
+   int i = 0, img_type = 0;
+   struct flash_section_info_g2 *fsec_g2 = NULL;
+
+   if (BE2_chip(adapter))
+   fsec_g2 = (struct flash_section_info_g2 *)fsec;
+
+   for (i = 0; i < MAX_FLASH_COMP; i++) {
+   if (fsec_g2)
+   img_type = le32_to_cpu(fsec_g2->fsec_entry[i].type);
+   else
+   img_type = le32_to_cpu(fsec->fsec_entry[i].type);
+
+   if (img_type == type)
+   return true;
+   }
+   return false;
+}
+
+static struct flash_section_info *get_fsec_info(struct be_adapter *adapter,
+   int header_size,
+   const struct firmware *fw)
+{
+   struct flash_section_info *fsec = NULL;
+   const u8 *p = fw->data;
+
+   p += header_size;
+   while (p < (fw->data + fw->size)) {
+   fsec = (struct flash_section_info *)p;
+   if (!memcmp(flash_cookie, fsec->cookie, sizeof(flash_cookie)))
+   return fsec;
+   p += 32;
+   }
+   return NULL;
+}
+
+static int be_check_flash_crc(struct be_adapter *adapter, const u8 *p,
+ u32 img_offset, u32 img_size, int hdr_size,
+ u16 img_optype, bool *crc_match)
+{
+   u32 crc_offset;
+   int status;
+   u8 crc[4];
+
+   status = be_cmd_get_flash_crc(adapter, crc, img_optype, img_offset,
+ img_size - 4);
+   if (status)
+   return status;
+

[PATCH net-next v3 01/10] be2net: fix VF link state transition from disabled to auto

2015-12-29 Thread Sathya Perla
From: Suresh Reddy 

The VF link state setting transition from "disable" to "auto" does not work
due to a bug in SET_LOGICAL_LINK_CONFIG_V1 cmd in FW. This issue could not
be fixed in FW due to some backward compatibility issues it causes with
some released drivers. The issue has been fixed by introducing a new
version (v2) of the cmd from 10.6 FW onwards. In v2, to set the VF link
state to auto, both PLINK_ENABLE and PLINK_TRACK bits have to be set to 1.

The VF link state setting feature now works on Lancer chips too from
FW ver 10.6.315.0 onwards.

Signed-off-by: Suresh Reddy 
Signed-off-by: Sathya Perla 
---
 drivers/net/ethernet/emulex/benet/be_cmds.c | 35 +
 drivers/net/ethernet/emulex/benet/be_cmds.h |  3 ++-
 2 files changed, 28 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c 
b/drivers/net/ethernet/emulex/benet/be_cmds.c
index 1795c93..8083eca 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.c
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.c
@@ -4260,16 +4260,13 @@ err:
return status;
 }
 
-int be_cmd_set_logical_link_config(struct be_adapter *adapter,
-  int link_state, u8 domain)
+int __be_cmd_set_logical_link_config(struct be_adapter *adapter,
+int link_state, int version, u8 domain)
 {
struct be_mcc_wrb *wrb;
struct be_cmd_req_set_ll_link *req;
int status;
 
-   if (BEx_chip(adapter) || lancer_chip(adapter))
-   return -EOPNOTSUPP;
-
spin_lock_bh(&adapter->mcc_lock);
 
wrb = wrb_from_mccq(adapter);
@@ -4284,14 +4281,15 @@ int be_cmd_set_logical_link_config(struct be_adapter 
*adapter,
   OPCODE_COMMON_SET_LOGICAL_LINK_CONFIG,
   sizeof(*req), wrb, NULL);
 
-   req->hdr.version = 1;
+   req->hdr.version = version;
req->hdr.domain = domain;
 
-   if (link_state == IFLA_VF_LINK_STATE_ENABLE)
-   req->link_config |= 1;
+   if (link_state == IFLA_VF_LINK_STATE_ENABLE ||
+   link_state == IFLA_VF_LINK_STATE_AUTO)
+   req->link_config |= PLINK_ENABLE;
 
if (link_state == IFLA_VF_LINK_STATE_AUTO)
-   req->link_config |= 1 << PLINK_TRACK_SHIFT;
+   req->link_config |= PLINK_TRACK;
 
status = be_mcc_notify_wait(adapter);
 err:
@@ -4299,6 +4297,25 @@ err:
return status;
 }
 
+int be_cmd_set_logical_link_config(struct be_adapter *adapter,
+  int link_state, u8 domain)
+{
+   int status;
+
+   if (BEx_chip(adapter))
+   return -EOPNOTSUPP;
+
+   status = __be_cmd_set_logical_link_config(adapter, link_state,
+ 2, domain);
+
+   /* Version 2 of the command will not be recognized by older FW.
+* On such a failure issue version 1 of the command.
+*/
+   if (base_status(status) == MCC_STATUS_ILLEGAL_REQUEST)
+   status = __be_cmd_set_logical_link_config(adapter, link_state,
+ 1, domain);
+   return status;
+}
 int be_roce_mcc_cmd(void *netdev_handle, void *wrb_payload,
int wrb_payload_size, u16 *cmd_status, u16 *ext_status)
 {
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.h 
b/drivers/net/ethernet/emulex/benet/be_cmds.h
index 91155ea..9690c3a 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.h
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.h
@@ -2246,7 +2246,8 @@ struct be_cmd_resp_get_iface_list {
 };
 
 /*** Set logical link /
-#define PLINK_TRACK_SHIFT  8
+#define PLINK_ENABLEBIT(0)
+#define PLINK_TRACK BIT(8)
 struct be_cmd_req_set_ll_link {
struct be_cmd_req_hdr hdr;
u32 link_config; /* Bit 0: UP_DOWN, Bit 9: PLINK */
-- 
2.4.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-next v3 06/10] be2net: remove a line of code that has no effect

2015-12-29 Thread Sathya Perla
This patch removes a line of code that changes adapter->recommended_prio
value followed by yet another assignment.
Also, the variable is used to store the vlan priority value that is already
shifted to the PCP bits position in the vlan tag format. Hence, the name of
this variable is changed to recommended_prio_bits.

Signed-off-by: Sathya Perla 
---
 drivers/net/ethernet/emulex/benet/be.h  | 2 +-
 drivers/net/ethernet/emulex/benet/be_cmds.c | 3 +--
 drivers/net/ethernet/emulex/benet/be_main.c | 2 +-
 3 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/emulex/benet/be.h 
b/drivers/net/ethernet/emulex/benet/be.h
index d463563..93e5eab 100644
--- a/drivers/net/ethernet/emulex/benet/be.h
+++ b/drivers/net/ethernet/emulex/benet/be.h
@@ -521,7 +521,7 @@ struct be_adapter {
struct be_drv_stats drv_stats;
struct be_aic_obj aic_obj[MAX_EVT_QS];
u8 vlan_prio_bmap;  /* Available Priority BitMap */
-   u16 recommended_prio;   /* Recommended Priority */
+   u16 recommended_prio_bits;/* Recommended Priority bits in vlan tag */
struct be_dma_mem rx_filter; /* Cmd DMA mem for rx-filter */
 
struct be_dma_mem stats_cmd;
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c 
b/drivers/net/ethernet/emulex/benet/be_cmds.c
index 451f9ea..7c0e7ff 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.c
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.c
@@ -308,8 +308,7 @@ static void be_async_grp5_cos_priority_process(struct 
be_adapter *adapter,
 
if (evt->valid) {
adapter->vlan_prio_bmap = evt->available_priority_bmap;
-   adapter->recommended_prio &= ~VLAN_PRIO_MASK;
-   adapter->recommended_prio =
+   adapter->recommended_prio_bits =
evt->reco_default_priority << VLAN_PRIO_SHIFT;
}
 }
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c 
b/drivers/net/ethernet/emulex/benet/be_main.c
index 646b021..c9f9d4b 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -729,7 +729,7 @@ static inline u16 be_get_tx_vlan_tag(struct be_adapter 
*adapter,
/* If vlan priority provided by OS is NOT in available bmap */
if (!(adapter->vlan_prio_bmap & (1 << vlan_prio)))
vlan_tag = (vlan_tag & ~VLAN_PRIO_MASK) |
-   adapter->recommended_prio;
+   adapter->recommended_prio_bits;
 
return vlan_tag;
 }
-- 
2.4.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-next v3 03/10] be2net: cleanup FW flash image related macro defines

2015-12-29 Thread Sathya Perla
From: Suresh Reddy 

Many constant definitions relating to the FW-image layout
(such as section offset values) were defined in decimal format rather than
hexa-decimal. This makes this part of the code un-readable. Also some
defines related to BE2 are labeld "g2" and defines related to BE3 are
labeled "g3".  This patch cleans up all of this to make this code more
readable.

Signed-off-by: Suresh Reddy 
Signed-off-by: Sathya Perla 
---
 drivers/net/ethernet/emulex/benet/be_cmds.h | 141 
 drivers/net/ethernet/emulex/benet/be_main.c |  78 +++
 2 files changed, 118 insertions(+), 101 deletions(-)

diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.h 
b/drivers/net/ethernet/emulex/benet/be_cmds.h
index 9690c3a..8c6b606 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.h
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.h
@@ -1207,68 +1207,85 @@ struct be_cmd_resp_get_beacon_state {
 /* Flashrom related descriptors */
 #define MAX_FLASH_COMP 32
 
-#define OPTYPE_ISCSI_ACTIVE0
-#define OPTYPE_REDBOOT 1
-#define OPTYPE_BIOS2
-#define OPTYPE_PXE_BIOS3
-#define OPTYPE_OFFSET_SPECIFIED7
-#define OPTYPE_FCOE_BIOS   8
-#define OPTYPE_ISCSI_BACKUP9
-#define OPTYPE_FCOE_FW_ACTIVE  10
-#define OPTYPE_FCOE_FW_BACKUP  11
-#define OPTYPE_NCSI_FW 13
-#define OPTYPE_REDBOOT_DIR 18
-#define OPTYPE_REDBOOT_CONFIG  19
-#define OPTYPE_SH_PHY_FW   21
-#define OPTYPE_FLASHISM_JUMPVECTOR 22
-#define OPTYPE_UFI_DIR 23
-#define OPTYPE_PHY_FW  99
-
-#define FLASH_BIOS_IMAGE_MAX_SIZE_g2   262144  /* Max OPTION ROM image sz */
-#define FLASH_REDBOOT_IMAGE_MAX_SIZE_g2262144  /* Max Redboot image sz 
   */
-#define FLASH_IMAGE_MAX_SIZE_g21310720 /* Max firmware image 
size */
-
-#define FLASH_NCSI_IMAGE_MAX_SIZE_g3   262144
-#define FLASH_PHY_FW_IMAGE_MAX_SIZE_g3 262144
-#define FLASH_BIOS_IMAGE_MAX_SIZE_g3   524288  /* Max OPTION ROM image sz */
-#define FLASH_REDBOOT_IMAGE_MAX_SIZE_g31048576 /* Max Redboot image sz 
   */
-#define FLASH_IMAGE_MAX_SIZE_g32097152 /* Max firmware image 
size */
-
-/* Offsets for components on Flash. */
-#define FLASH_REDBOOT_START_g2 0
-#define FLASH_FCoE_BIOS_START_g2   524288
-#define FLASH_iSCSI_PRIMARY_IMAGE_START_g2 1048576
-#define FLASH_iSCSI_BACKUP_IMAGE_START_g2  2359296
-#define FLASH_FCoE_PRIMARY_IMAGE_START_g2  3670016
-#define FLASH_FCoE_BACKUP_IMAGE_START_g2   4980736
-#define FLASH_iSCSI_BIOS_START_g2  7340032
-#define FLASH_PXE_BIOS_START_g27864320
-
-#define FLASH_REDBOOT_START_g3 262144
-#define FLASH_PHY_FW_START_g3  1310720
-#define FLASH_iSCSI_PRIMARY_IMAGE_START_g3 2097152
-#define FLASH_iSCSI_BACKUP_IMAGE_START_g3  4194304
-#define FLASH_FCoE_PRIMARY_IMAGE_START_g3  6291456
-#define FLASH_FCoE_BACKUP_IMAGE_START_g3   8388608
-#define FLASH_iSCSI_BIOS_START_g3  12582912
-#define FLASH_PXE_BIOS_START_g313107200
-#define FLASH_FCoE_BIOS_START_g3   13631488
-#define FLASH_NCSI_START_g315990784
-
-#define IMAGE_NCSI 16
-#define IMAGE_OPTION_ROM_PXE   32
-#define IMAGE_OPTION_ROM_FCoE  33
-#define IMAGE_OPTION_ROM_ISCSI 34
-#define IMAGE_FLASHISM_JUMPVECTOR  48
-#define IMAGE_FIRMWARE_iSCSI   160
-#define IMAGE_FIRMWARE_FCoE162
-#define IMAGE_FIRMWARE_BACKUP_iSCSI176
-#define IMAGE_FIRMWARE_BACKUP_FCoE 178
-#define IMAGE_FIRMWARE_PHY 192
-#define IMAGE_REDBOOT_DIR  208
-#define IMAGE_REDBOOT_CONFIG   209
-#define IMAGE_UFI_DIR  210
-#define IMAGE_BOOT_CODE224
+/* Optypes of each component in the UFI */
+enum {
+   OPTYPE_ISCSI_ACTIVE = 0,
+   OPTYPE_REDBOOT = 1,
+   OPTYPE_BIOS = 2,
+   OPTYPE_PXE_BIOS = 3,
+   OPTYPE_OFFSET_SPECIFIED = 7,
+   OPTYPE_FCOE_BIOS = 8,
+   OPTYPE_ISCSI_BACKUP = 9,
+   OPTYPE_FCOE_FW_ACTIVE = 10,
+   OPTYPE_FCOE_FW_BACKUP = 11,
+   OPTYPE_NCSI_FW = 13,
+   OPTYPE_REDBOOT_DIR = 18,
+   OPTYPE_REDBOOT_CONFIG = 19,
+   OPTYPE_SH_PHY_FW = 21,
+   OPTYPE_FLASHISM_JUMPVECTOR = 22,
+   OPTYPE_UFI_DIR = 23,
+   OPTYPE_PHY_FW = 99
+};
+
+/* Maximum sizes of components in BE2 FW UFI */
+enum {
+   BE2_BIOS_COMP_MAX_SIZE = 0x4,
+   BE2_REDBOOT_COMP_MAX_SIZE = 0x4,
+   BE2_COMP_MAX_SIZE = 0x14
+};
+
+/* Maximum sizes of components in BE3 FW UFI */
+enum {
+   BE3_NCSI_COMP_MAX_SIZE = 0x4,
+   BE3_PHY_FW_COMP_MAX_SIZE = 0x4,
+   BE3_BIOS_COMP_MAX_SIZE = 0x8,
+   BE3_REDBOOT_COMP

[PATCH net-next v3 09/10] be2net: support ethtool get-dump option

2015-12-29 Thread Sathya Perla
From: Venkat Duvvuru 

This patch adds support for ethtool's --get-dump option in be2net,
to retrieve FW dump. In the past when this option was not yet available,
this feature was supported via the --register-dump option as a workaround.
This patch removes support for FW-dump via --register-dump option as it is
now available via --get-dump option. Even though the
"ethtool --register-dump" cmd which used to work earlier, will now fail
with ENOTSUPP error, we feel it is not an issue as this is used only
for diagnostics purpose.

Signed-off-by: Venkat Duvvuru 
Signed-off-by: Sathya Perla 
---
 drivers/net/ethernet/emulex/benet/be.h |  1 +
 drivers/net/ethernet/emulex/benet/be_cmds.c| 38 
 drivers/net/ethernet/emulex/benet/be_cmds.h|  4 +-
 drivers/net/ethernet/emulex/benet/be_ethtool.c | 82 --
 drivers/net/ethernet/emulex/benet/be_main.c|  3 +
 5 files changed, 71 insertions(+), 57 deletions(-)

diff --git a/drivers/net/ethernet/emulex/benet/be.h 
b/drivers/net/ethernet/emulex/benet/be.h
index 66988f4..8b8212f 100644
--- a/drivers/net/ethernet/emulex/benet/be.h
+++ b/drivers/net/ethernet/emulex/benet/be.h
@@ -592,6 +592,7 @@ struct be_adapter {
struct rss_info rss_info;
/* Filters for packets that need to be sent to BMC */
u32 bmc_filt_mask;
+   u32 fat_dump_len;
u16 serial_num[CNTL_SERIAL_NUM_WORDS];
 };
 
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c 
b/drivers/net/ethernet/emulex/benet/be_cmds.c
index b92ee06..b63d8ad 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.c
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.c
@@ -1712,49 +1712,40 @@ err:
 }
 
 /* Uses synchronous mcc */
-int be_cmd_get_reg_len(struct be_adapter *adapter, u32 *log_size)
+int be_cmd_get_fat_dump_len(struct be_adapter *adapter, u32 *dump_size)
 {
-   struct be_mcc_wrb *wrb;
+   struct be_mcc_wrb wrb = {0};
struct be_cmd_req_get_fat *req;
int status;
 
-   spin_lock_bh(&adapter->mcc_lock);
-
-   wrb = wrb_from_mccq(adapter);
-   if (!wrb) {
-   status = -EBUSY;
-   goto err;
-   }
-   req = embedded_payload(wrb);
+   req = embedded_payload(&wrb);
 
be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON,
-  OPCODE_COMMON_MANAGE_FAT, sizeof(*req), wrb,
-  NULL);
+  OPCODE_COMMON_MANAGE_FAT, sizeof(*req),
+  &wrb, NULL);
req->fat_operation = cpu_to_le32(QUERY_FAT);
-   status = be_mcc_notify_wait(adapter);
+   status = be_cmd_notify_wait(adapter, &wrb);
if (!status) {
-   struct be_cmd_resp_get_fat *resp = embedded_payload(wrb);
+   struct be_cmd_resp_get_fat *resp = embedded_payload(&wrb);
 
-   if (log_size && resp->log_size)
-   *log_size = le32_to_cpu(resp->log_size) -
+   if (dump_size && resp->log_size)
+   *dump_size = le32_to_cpu(resp->log_size) -
sizeof(u32);
}
-err:
-   spin_unlock_bh(&adapter->mcc_lock);
return status;
 }
 
-int be_cmd_get_regs(struct be_adapter *adapter, u32 buf_len, void *buf)
+int be_cmd_get_fat_dump(struct be_adapter *adapter, u32 buf_len, void *buf)
 {
struct be_dma_mem get_fat_cmd;
struct be_mcc_wrb *wrb;
struct be_cmd_req_get_fat *req;
u32 offset = 0, total_size, buf_size,
log_offset = sizeof(u32), payload_len;
-   int status = 0;
+   int status;
 
if (buf_len == 0)
-   return -EIO;
+   return 0;
 
total_size = buf_len;
 
@@ -1762,11 +1753,8 @@ int be_cmd_get_regs(struct be_adapter *adapter, u32 
buf_len, void *buf)
get_fat_cmd.va = dma_zalloc_coherent(&adapter->pdev->dev,
 get_fat_cmd.size,
 &get_fat_cmd.dma, GFP_ATOMIC);
-   if (!get_fat_cmd.va) {
-   dev_err(&adapter->pdev->dev,
-   "Memory allocation failure while reading FAT data\n");
+   if (!get_fat_cmd.va)
return -ENOMEM;
-   }
 
spin_lock_bh(&adapter->mcc_lock);
 
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.h 
b/drivers/net/ethernet/emulex/benet/be_cmds.h
index 5098170..241819b 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.h
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.h
@@ -2365,9 +2365,9 @@ int be_cmd_config_qos(struct be_adapter *adapter, u32 
max_rate,
 void be_detect_error(struct be_adapter *adapter);
 int be_cmd_get_die_temperature(struct be_adapter *adapter);
 int be_cmd_get_cntl_attributes(struct be_adapter *adapter);
+int be_cmd_get_fat_dump_len(str

[PATCH net-next v3 10/10] be2net: bump up the driver version to 11.0.0.0

2015-12-29 Thread Sathya Perla
From: Suresh Reddy 

Signed-off-by: Suresh Reddy 
Signed-off-by: Sathya Perla 
---
 drivers/net/ethernet/emulex/benet/be.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/emulex/benet/be.h 
b/drivers/net/ethernet/emulex/benet/be.h
index 8b8212f..22bf7af 100644
--- a/drivers/net/ethernet/emulex/benet/be.h
+++ b/drivers/net/ethernet/emulex/benet/be.h
@@ -37,7 +37,7 @@
 #include "be_hw.h"
 #include "be_roce.h"
 
-#define DRV_VER"10.6.0.3"
+#define DRV_VER"11.0.0.0"
 #define DRV_NAME   "be2net"
 #define BE_NAME"Emulex BladeEngine2"
 #define BE3_NAME   "Emulex BladeEngine3"
-- 
2.4.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-next v3 08/10] be2net: fix port-res desc query of GET_PROFILE_CONFIG FW cmd

2015-12-29 Thread Sathya Perla
From: Suresh Reddy 

Commit 72ef3a88fa8e ("be2net: set pci_func_num while issuing
GET_PROFILE_CONFIG cmd") passed a specific pf_num while issuing a
GET_PROFILE_CONFIG cmd as FW returns descriptors for all functions when
pf_num is zero. But, when pf_num is set to a non-zero value, FW does not
return the Port resource descriptor.
This patch fixes this by setting pf_num to 0 while issuing the query cmd
and adds code to pick the correct NIC resource descriptor from the list of
descriptors returned by FW.

Fixes: 72ef3a88fa8e ("be2net: set pci_func_num while issuing
 GET_PROFILE_CONFIG cmd")
Signed-off-by: Suresh Reddy 

Signed-off-by: Sathya Perla 
---
 drivers/net/ethernet/emulex/benet/be.h  |  4 +-
 drivers/net/ethernet/emulex/benet/be_cmds.c | 85 -
 drivers/net/ethernet/emulex/benet/be_cmds.h | 11 +---
 drivers/net/ethernet/emulex/benet/be_main.c | 16 --
 4 files changed, 63 insertions(+), 53 deletions(-)

diff --git a/drivers/net/ethernet/emulex/benet/be.h 
b/drivers/net/ethernet/emulex/benet/be.h
index 0af32f1..66988f4 100644
--- a/drivers/net/ethernet/emulex/benet/be.h
+++ b/drivers/net/ethernet/emulex/benet/be.h
@@ -570,6 +570,8 @@ struct be_adapter {
struct be_resources pool_res;   /* resources available for the port */
struct be_resources res;/* resources available for the func */
u16 num_vfs;/* Number of VFs provisioned by PF */
+   u8 pf_num;  /* Numbering used by FW, starts at 0 */
+   u8 vf_num;  /* Numbering used by FW, starts at 1 */
u8 virtfn;
struct be_vf_cfg *vf_cfg;
bool be3_native;
@@ -587,8 +589,6 @@ struct be_adapter {
u32 msg_enable;
int be_get_temp_freq;
struct be_hwmon hwmon_info;
-   u8 pf_number;
-   u8 pci_func_num;
struct rss_info rss_info;
/* Filters for packets that need to be sent to BMC */
u32 bmc_filt_mask;
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c 
b/drivers/net/ethernet/emulex/benet/be_cmds.c
index 7c0e7ff..b92ee06 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.c
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.c
@@ -3466,7 +3466,6 @@ int be_cmd_get_cntl_attributes(struct be_adapter *adapter)
if (!status) {
attribs = attribs_cmd.va + sizeof(struct be_cmd_resp_hdr);
adapter->hba_port_num = attribs->hba_attribs.phy_port;
-   adapter->pci_func_num = attribs->pci_func_num;
serial_num = attribs->hba_attribs.controller_serial_number;
for (i = 0; i < CNTL_SERIAL_NUM_WORDS; i++)
adapter->serial_num[i] = le32_to_cpu(serial_num[i]) &
@@ -4149,14 +4148,16 @@ int be_cmd_query_port_name(struct be_adapter *adapter)
return status;
 }
 
-/* Descriptor type */
-enum {
-   FUNC_DESC = 1,
-   VFT_DESC = 2
-};
-
+/* When more than 1 NIC descriptor is present in the descriptor list,
+ * the caller must specify the pf_num to obtain the NIC descriptor
+ * corresponding to its pci function.
+ * get_vft must be true when the caller wants the VF-template desc of the
+ * PF-pool.
+ * The pf_num should be set to PF_NUM_IGNORE when the caller knows
+ * that only it's NIC descriptor is present in the descriptor list.
+ */
 static struct be_nic_res_desc *be_get_nic_desc(u8 *buf, u32 desc_count,
-  int desc_type)
+  bool get_vft, u8 pf_num)
 {
struct be_res_desc_hdr *hdr = (struct be_res_desc_hdr *)buf;
struct be_nic_res_desc *nic;
@@ -4166,40 +4167,42 @@ static struct be_nic_res_desc *be_get_nic_desc(u8 *buf, 
u32 desc_count,
if (hdr->desc_type == NIC_RESOURCE_DESC_TYPE_V0 ||
hdr->desc_type == NIC_RESOURCE_DESC_TYPE_V1) {
nic = (struct be_nic_res_desc *)hdr;
-   if (desc_type == FUNC_DESC ||
-   (desc_type == VFT_DESC &&
-nic->flags & (1 << VFT_SHIFT)))
+
+   if ((pf_num == PF_NUM_IGNORE ||
+nic->pf_num == pf_num) &&
+   (!get_vft || nic->flags & BIT(VFT_SHIFT)))
return nic;
}
-
hdr->desc_len = hdr->desc_len ? : RESOURCE_DESC_SIZE_V0;
hdr = (void *)hdr + hdr->desc_len;
}
return NULL;
 }
 
-static struct be_nic_res_desc *be_get_vft_desc(u8 *buf, u32 desc_count)
+static struct be_nic_res_desc *be_get_vft_desc(u8 *buf, u32 desc_count,
+  u8 pf_num)
 {
-   return be_get_nic_desc(buf, desc_count, VFT_DESC);
+   return be_get_nic_desc(buf, desc_count, true, pf_num);
 }
 
-sta

[PATCH net-next v3 02/10] be2net: avoid configuring VEPA mode on BE3

2015-12-29 Thread Sathya Perla
From: Suresh Reddy 

BE3 chip doesn't support VEPA mode.

Signed-off-by: Suresh Reddy 
Signed-off-by: Sathya Perla 
---
 drivers/net/ethernet/emulex/benet/be_main.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/ethernet/emulex/benet/be_main.c 
b/drivers/net/ethernet/emulex/benet/be_main.c
index 34e324f..2f76cbe 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -5108,6 +5108,9 @@ static int be_ndo_bridge_setlink(struct net_device *dev, 
struct nlmsghdr *nlh,
return -EINVAL;
 
mode = nla_get_u16(attr);
+   if (BE3_chip(adapter) && mode == BRIDGE_MODE_VEPA)
+   return -EOPNOTSUPP;
+
if (mode != BRIDGE_MODE_VEPA && mode != BRIDGE_MODE_VEB)
return -EINVAL;
 
-- 
2.4.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-next v3 05/10] be2net: log digital signature errors while flashing FW image

2015-12-29 Thread Sathya Perla
From: Suresh Reddy 

>From FW version 11.0 onwards, the FW supports a new "secure mode" feature
(based on a jumper setting on the adapter.) In this mode, the FW image when
flashed is authenticated with a digital signature. This patch logs
appropriate error messages and return a status to ethtool when errors
relating to FW image authentication occur.

Signed-off-by: Suresh Reddy 
Signed-off-by: Sathya Perla 
---
 drivers/net/ethernet/emulex/benet/be_cmds.c | 14 +-
 drivers/net/ethernet/emulex/benet/be_cmds.h |  4 +++-
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c 
b/drivers/net/ethernet/emulex/benet/be_cmds.c
index da3b398..451f9ea 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.c
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.c
@@ -2959,7 +2959,19 @@ flash:
} else if (status) {
dev_err(dev, "Flashing section type 0x%x failed\n",
img_type);
-   return -EFAULT;
+
+   switch (addl_status(status)) {
+   case MCC_ADDL_STATUS_MISSING_SIGNATURE:
+   dev_err(dev,
+   "Digital signature missing in FW\n");
+   return -EINVAL;
+   case MCC_ADDL_STATUS_INVALID_SIGNATURE:
+   dev_err(dev,
+   "Invalid digital signature in FW\n");
+   return -EINVAL;
+   default:
+   return -EFAULT;
+   }
}
}
return 0;
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.h 
b/drivers/net/ethernet/emulex/benet/be_cmds.h
index 4b0ca99..16415ca 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.h
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.h
@@ -66,7 +66,9 @@ enum mcc_addl_status {
MCC_ADDL_STATUS_INSUFFICIENT_RESOURCES = 0x16,
MCC_ADDL_STATUS_FLASH_IMAGE_CRC_MISMATCH = 0x4d,
MCC_ADDL_STATUS_TOO_MANY_INTERFACES = 0x4a,
-   MCC_ADDL_STATUS_INSUFFICIENT_VLANS = 0xab
+   MCC_ADDL_STATUS_INSUFFICIENT_VLANS = 0xab,
+   MCC_ADDL_STATUS_INVALID_SIGNATURE = 0x56,
+   MCC_ADDL_STATUS_MISSING_SIGNATURE = 0x57
 };
 
 #define CQE_BASE_STATUS_MASK   0x
-- 
2.4.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-next v3 00/10] be2net: patch set

2015-12-29 Thread Sathya Perla
Hi David,
The following patch set contains some feature additions, code re-organization
and cleanup and a few non-critical fixes. Pls consider applying this to
the net-next tree. Thanks.

v3 changes: add a default case to the switch statement in patch 5 to
satisfy the compiler (-Wswitch).
v2 changes: replaced an if/else block that checks for error values with a
switch/case statement in patch 5.

Patch 1 fixes VF link state transition from disabled to auto that did
not work due to an issue in the FW. This issue could not be fixed in FW due
to some backward compatibility issues it causes with released drivers.
The issue has been fixed by introducing a new version (v2) of the cmd
from 10.6 FW onwards. This patch adds support for v2 version of this cmd.

Patch 2 reports a EOPNOTSUPP status to ethtool when the user tries to
configure BE3/SRIOV in VEPA mode as it is not supported by the chip.

Patch 3 cleansup FW flash image related constant definitions. Many of these
definitions (such as section offset values) were defined in decimal format
rather than hexa-decimal. This makes this part of the code un-readable.
Also some defines related to BE2 are labeld "g2" and defines related to BE3
are labeled "g3".  This patch cleans up all of this to make this code more
readable.

Patch 4 moves the FW cmd code to be_cmds.c. All code relating to FW cmds
has been in be_cmds.[ch], excepting FW flash cmd related code.
This patch moves these routines from be_main.c to be_cmds.c.

Patch 5 adds a log message to report digital signature errors while
flashing a FW image. From FW version 11.0 onwards, the FW supports a new
"secure mode" feature (based on a jumper setting on the adapter.) In this
mode, the FW image when flashed is authenticated with a digital signature.

Patch 6 removes a line of code that has no effect.

Patch 7 removes some unused variables.

Patch 8 fixes port resource descriptor query via the GET_PROFILE FW cmd.
An earlier commit passed a specific pf_num while issuing this cmd as FW
returns descriptors for all functions when pf_num is zero. But, when pf_num
is set to a non-zero value, FW does not return the port resource descriptor.
This patch fixes this by setting pf_num to 0 while issuing the query cmd
and adds code to pick the correct NIC resource descriptor from the list of
descriptors returned by FW.

Patch 9 adds support for ethtool get-dump feature. In the past when this
option was not yet available, this feature was supported via the
--register-dump option as a workaround.  This patch removes support for
FW-dump via --register-dump option as it is now available via --get-dump
option. Even though the "ethtool --register-dump" cmd which used to work
earlier, will now fail with ENOTSUPP error, we feel it is not an issue as
this is used only for diagnostics purpose.

Patch 10 bumps up the driver version.

Sathya Perla (1):
  be2net: remove a line of code that has no effect

Suresh Reddy (7):
  be2net: fix VF link state transition from disabled to auto
  be2net: avoid configuring VEPA mode on BE3
  be2net: cleanup FW flash image related macro defines
  be2net: move FW flash cmd code to be_cmds.c
  be2net: log digital signature errors while flashing FW image
  be2net: fix port-res desc query of GET_PROFILE_CONFIG FW cmd
  be2net: bump up the driver version to 11.0.0.0

Venkat Duvvuru (2):
  be2net: remove unused error variables
  be2net: support ethtool get-dump option

 drivers/net/ethernet/emulex/benet/be.h |  13 +-
 drivers/net/ethernet/emulex/benet/be_cmds.c| 756 ++---
 drivers/net/ethernet/emulex/benet/be_cmds.h| 178 +++---
 drivers/net/ethernet/emulex/benet/be_ethtool.c |  82 ++-
 drivers/net/ethernet/emulex/benet/be_main.c| 588 +--
 5 files changed, 841 insertions(+), 776 deletions(-)

-- 
2.4.1
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-next v3 07/10] be2net: remove unused error variables

2015-12-29 Thread Sathya Perla
From: Venkat Duvvuru 

eeh_error, fw_timeout, hw_error variables in the be_adapter structure are
not used anymore. An earlier patch that introduced adapter->err_flags to
store this information missed removing these variables.

Signed-off-by: Venkat Duvvuru 
Signed-off-by: Sathya Perla 
---
 drivers/net/ethernet/emulex/benet/be.h | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/net/ethernet/emulex/benet/be.h 
b/drivers/net/ethernet/emulex/benet/be.h
index 93e5eab..0af32f1 100644
--- a/drivers/net/ethernet/emulex/benet/be.h
+++ b/drivers/net/ethernet/emulex/benet/be.h
@@ -547,10 +547,6 @@ struct be_adapter {
 
u32 beacon_state;   /* for set_phys_id */
 
-   bool eeh_error;
-   bool fw_timeout;
-   bool hw_error;
-
u32 port_num;
char port_name;
u8 mc_type;
-- 
2.4.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH net-next v2 00/10] be2net: patch set

2015-12-29 Thread Sathya Perla
On Wed, Dec 30, 2015 at 2:20 AM, David Miller  wrote:
>
> Please fix the problems reported by the kbuild test robot, they happened
> when I tried to build this too.

David, the test robot is complaining that all values of the enum are
not being handled by the switch statement.
There is a "return -EFAULT" after the switch statement that handles
all the other enum values. Anyway, I'm going to send a v3 adding a
default case to the switch to satisfy the compilerthanks.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-next v2 08/10] be2net: fix port-res desc query of GET_PROFILE_CONFIG FW cmd

2015-12-27 Thread Sathya Perla
From: Suresh Reddy 

Commit 72ef3a88fa8e ("be2net: set pci_func_num while issuing
GET_PROFILE_CONFIG cmd") passed a specific pf_num while issuing a
GET_PROFILE_CONFIG cmd as FW returns descriptors for all functions when
pf_num is zero. But, when pf_num is set to a non-zero value, FW does not
return the Port resource descriptor.
This patch fixes this by setting pf_num to 0 while issuing the query cmd
and adds code to pick the correct NIC resource descriptor from the list of
descriptors returned by FW.

Fixes: 72ef3a88fa8e ("be2net: set pci_func_num while issuing
 GET_PROFILE_CONFIG cmd")
Signed-off-by: Suresh Reddy 

Signed-off-by: Sathya Perla 
---
 drivers/net/ethernet/emulex/benet/be.h  |  4 +-
 drivers/net/ethernet/emulex/benet/be_cmds.c | 85 -
 drivers/net/ethernet/emulex/benet/be_cmds.h | 11 +---
 drivers/net/ethernet/emulex/benet/be_main.c | 16 --
 4 files changed, 63 insertions(+), 53 deletions(-)

diff --git a/drivers/net/ethernet/emulex/benet/be.h 
b/drivers/net/ethernet/emulex/benet/be.h
index 0af32f1..66988f4 100644
--- a/drivers/net/ethernet/emulex/benet/be.h
+++ b/drivers/net/ethernet/emulex/benet/be.h
@@ -570,6 +570,8 @@ struct be_adapter {
struct be_resources pool_res;   /* resources available for the port */
struct be_resources res;/* resources available for the func */
u16 num_vfs;/* Number of VFs provisioned by PF */
+   u8 pf_num;  /* Numbering used by FW, starts at 0 */
+   u8 vf_num;  /* Numbering used by FW, starts at 1 */
u8 virtfn;
struct be_vf_cfg *vf_cfg;
bool be3_native;
@@ -587,8 +589,6 @@ struct be_adapter {
u32 msg_enable;
int be_get_temp_freq;
struct be_hwmon hwmon_info;
-   u8 pf_number;
-   u8 pci_func_num;
struct rss_info rss_info;
/* Filters for packets that need to be sent to BMC */
u32 bmc_filt_mask;
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c 
b/drivers/net/ethernet/emulex/benet/be_cmds.c
index 23f8b9e..87c3dba 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.c
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.c
@@ -3465,7 +3465,6 @@ int be_cmd_get_cntl_attributes(struct be_adapter *adapter)
if (!status) {
attribs = attribs_cmd.va + sizeof(struct be_cmd_resp_hdr);
adapter->hba_port_num = attribs->hba_attribs.phy_port;
-   adapter->pci_func_num = attribs->pci_func_num;
serial_num = attribs->hba_attribs.controller_serial_number;
for (i = 0; i < CNTL_SERIAL_NUM_WORDS; i++)
adapter->serial_num[i] = le32_to_cpu(serial_num[i]) &
@@ -4148,14 +4147,16 @@ int be_cmd_query_port_name(struct be_adapter *adapter)
return status;
 }
 
-/* Descriptor type */
-enum {
-   FUNC_DESC = 1,
-   VFT_DESC = 2
-};
-
+/* When more than 1 NIC descriptor is present in the descriptor list,
+ * the caller must specify the pf_num to obtain the NIC descriptor
+ * corresponding to its pci function.
+ * get_vft must be true when the caller wants the VF-template desc of the
+ * PF-pool.
+ * The pf_num should be set to PF_NUM_IGNORE when the caller knows
+ * that only it's NIC descriptor is present in the descriptor list.
+ */
 static struct be_nic_res_desc *be_get_nic_desc(u8 *buf, u32 desc_count,
-  int desc_type)
+  bool get_vft, u8 pf_num)
 {
struct be_res_desc_hdr *hdr = (struct be_res_desc_hdr *)buf;
struct be_nic_res_desc *nic;
@@ -4165,40 +4166,42 @@ static struct be_nic_res_desc *be_get_nic_desc(u8 *buf, 
u32 desc_count,
if (hdr->desc_type == NIC_RESOURCE_DESC_TYPE_V0 ||
hdr->desc_type == NIC_RESOURCE_DESC_TYPE_V1) {
nic = (struct be_nic_res_desc *)hdr;
-   if (desc_type == FUNC_DESC ||
-   (desc_type == VFT_DESC &&
-nic->flags & (1 << VFT_SHIFT)))
+
+   if ((pf_num == PF_NUM_IGNORE ||
+nic->pf_num == pf_num) &&
+   (!get_vft || nic->flags & BIT(VFT_SHIFT)))
return nic;
}
-
hdr->desc_len = hdr->desc_len ? : RESOURCE_DESC_SIZE_V0;
hdr = (void *)hdr + hdr->desc_len;
}
return NULL;
 }
 
-static struct be_nic_res_desc *be_get_vft_desc(u8 *buf, u32 desc_count)
+static struct be_nic_res_desc *be_get_vft_desc(u8 *buf, u32 desc_count,
+  u8 pf_num)
 {
-   return be_get_nic_desc(buf, desc_count, VFT_DESC);
+   return be_get_nic_desc(buf, desc_count, true, pf_num);
 }
 
-sta

[PATCH net-next v2 05/10] be2net: log digital signature errors while flashing FW image

2015-12-27 Thread Sathya Perla
From: Suresh Reddy 

>From FW version 11.0 onwards, the FW supports a new "secure mode" feature
(based on a jumper setting on the adapter.) In this mode, the FW image when
flashed is authenticated with a digital signature. This patch logs
appropriate error messages and return a status to ethtool when errors
relating to FW image authentication occur.

Signed-off-by: Suresh Reddy 
Signed-off-by: Sathya Perla 
---
 drivers/net/ethernet/emulex/benet/be_cmds.c | 11 +++
 drivers/net/ethernet/emulex/benet/be_cmds.h |  4 +++-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c 
b/drivers/net/ethernet/emulex/benet/be_cmds.c
index da3b398..91b4689 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.c
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.c
@@ -2959,6 +2959,17 @@ flash:
} else if (status) {
dev_err(dev, "Flashing section type 0x%x failed\n",
img_type);
+
+   switch (addl_status(status)) {
+   case MCC_ADDL_STATUS_MISSING_SIGNATURE:
+   dev_err(dev,
+   "Digital signature missing in FW\n");
+   return -EINVAL;
+   case MCC_ADDL_STATUS_INVALID_SIGNATURE:
+   dev_err(dev,
+   "Invalid digital signature in FW\n");
+   return -EINVAL;
+   }
return -EFAULT;
}
}
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.h 
b/drivers/net/ethernet/emulex/benet/be_cmds.h
index 4b0ca99..16415ca 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.h
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.h
@@ -66,7 +66,9 @@ enum mcc_addl_status {
MCC_ADDL_STATUS_INSUFFICIENT_RESOURCES = 0x16,
MCC_ADDL_STATUS_FLASH_IMAGE_CRC_MISMATCH = 0x4d,
MCC_ADDL_STATUS_TOO_MANY_INTERFACES = 0x4a,
-   MCC_ADDL_STATUS_INSUFFICIENT_VLANS = 0xab
+   MCC_ADDL_STATUS_INSUFFICIENT_VLANS = 0xab,
+   MCC_ADDL_STATUS_INVALID_SIGNATURE = 0x56,
+   MCC_ADDL_STATUS_MISSING_SIGNATURE = 0x57
 };
 
 #define CQE_BASE_STATUS_MASK   0x
-- 
2.4.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-next v2 06/10] be2net: remove a line of code that has no effect

2015-12-27 Thread Sathya Perla
This patch removes a line of code that changes adapter->recommended_prio
value followed by yet another assignment.
Also, the variable is used to store the vlan priority value that is already
shifted to the PCP bits position in the vlan tag format. Hence, the name of
this variable is changed to recommended_prio_bits.

Signed-off-by: Sathya Perla 
---
 drivers/net/ethernet/emulex/benet/be.h  | 2 +-
 drivers/net/ethernet/emulex/benet/be_cmds.c | 3 +--
 drivers/net/ethernet/emulex/benet/be_main.c | 2 +-
 3 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/emulex/benet/be.h 
b/drivers/net/ethernet/emulex/benet/be.h
index d463563..93e5eab 100644
--- a/drivers/net/ethernet/emulex/benet/be.h
+++ b/drivers/net/ethernet/emulex/benet/be.h
@@ -521,7 +521,7 @@ struct be_adapter {
struct be_drv_stats drv_stats;
struct be_aic_obj aic_obj[MAX_EVT_QS];
u8 vlan_prio_bmap;  /* Available Priority BitMap */
-   u16 recommended_prio;   /* Recommended Priority */
+   u16 recommended_prio_bits;/* Recommended Priority bits in vlan tag */
struct be_dma_mem rx_filter; /* Cmd DMA mem for rx-filter */
 
struct be_dma_mem stats_cmd;
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c 
b/drivers/net/ethernet/emulex/benet/be_cmds.c
index 91b4689..23f8b9e 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.c
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.c
@@ -308,8 +308,7 @@ static void be_async_grp5_cos_priority_process(struct 
be_adapter *adapter,
 
if (evt->valid) {
adapter->vlan_prio_bmap = evt->available_priority_bmap;
-   adapter->recommended_prio &= ~VLAN_PRIO_MASK;
-   adapter->recommended_prio =
+   adapter->recommended_prio_bits =
evt->reco_default_priority << VLAN_PRIO_SHIFT;
}
 }
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c 
b/drivers/net/ethernet/emulex/benet/be_main.c
index 646b021..c9f9d4b 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -729,7 +729,7 @@ static inline u16 be_get_tx_vlan_tag(struct be_adapter 
*adapter,
/* If vlan priority provided by OS is NOT in available bmap */
if (!(adapter->vlan_prio_bmap & (1 << vlan_prio)))
vlan_tag = (vlan_tag & ~VLAN_PRIO_MASK) |
-   adapter->recommended_prio;
+   adapter->recommended_prio_bits;
 
return vlan_tag;
 }
-- 
2.4.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-next v2 04/10] be2net: move FW flash cmd code to be_cmds.c

2015-12-27 Thread Sathya Perla
From: Suresh Reddy 

All code relating to FW cmds is in be_cmds.[ch] excepting FW flash cmd
related code. This patch moves these routines from be_main.c to be_cmds.c

Signed-off-by: Suresh Reddy 
Signed-off-by: Sathya Perla 
---
 drivers/net/ethernet/emulex/benet/be_cmds.c | 583 +++-
 drivers/net/ethernet/emulex/benet/be_cmds.h |  15 +-
 drivers/net/ethernet/emulex/benet/be_main.c | 564 ---
 3 files changed, 578 insertions(+), 584 deletions(-)

diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c 
b/drivers/net/ethernet/emulex/benet/be_cmds.c
index 8083eca..da3b398 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.c
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.c
@@ -2291,10 +2291,11 @@ err:
return status;
 }
 
-int lancer_cmd_write_object(struct be_adapter *adapter, struct be_dma_mem *cmd,
-   u32 data_size, u32 data_offset,
-   const char *obj_name, u32 *data_written,
-   u8 *change_status, u8 *addn_status)
+static int lancer_cmd_write_object(struct be_adapter *adapter,
+  struct be_dma_mem *cmd, u32 data_size,
+  u32 data_offset, const char *obj_name,
+  u32 *data_written, u8 *change_status,
+  u8 *addn_status)
 {
struct be_mcc_wrb *wrb;
struct lancer_cmd_req_write_object *req;
@@ -2410,7 +2411,8 @@ int be_cmd_query_sfp_info(struct be_adapter *adapter)
return status;
 }
 
-int lancer_cmd_delete_object(struct be_adapter *adapter, const char *obj_name)
+static int lancer_cmd_delete_object(struct be_adapter *adapter,
+   const char *obj_name)
 {
struct lancer_cmd_req_delete_object *req;
struct be_mcc_wrb *wrb;
@@ -2485,9 +2487,9 @@ err_unlock:
return status;
 }
 
-int be_cmd_write_flashrom(struct be_adapter *adapter, struct be_dma_mem *cmd,
- u32 flash_type, u32 flash_opcode, u32 img_offset,
- u32 buf_size)
+static int be_cmd_write_flashrom(struct be_adapter *adapter,
+struct be_dma_mem *cmd, u32 flash_type,
+u32 flash_opcode, u32 img_offset, u32 buf_size)
 {
struct be_mcc_wrb *wrb;
struct be_cmd_write_flashrom *req;
@@ -2533,8 +2535,8 @@ err_unlock:
return status;
 }
 
-int be_cmd_get_flash_crc(struct be_adapter *adapter, u8 *flashed_crc,
-u16 img_optype, u32 img_offset, u32 crc_offset)
+static int be_cmd_get_flash_crc(struct be_adapter *adapter, u8 *flashed_crc,
+   u16 img_optype, u32 img_offset, u32 crc_offset)
 {
struct be_cmd_read_flash_crc *req;
struct be_mcc_wrb *wrb;
@@ -2571,6 +2573,567 @@ err:
return status;
 }
 
+static char flash_cookie[2][16] = {"*** SE FLAS", "H DIRECTORY *** "};
+
+static bool phy_flashing_required(struct be_adapter *adapter)
+{
+   return (adapter->phy.phy_type == PHY_TYPE_TN_8022 &&
+   adapter->phy.interface_type == PHY_TYPE_BASET_10GB);
+}
+
+static bool is_comp_in_ufi(struct be_adapter *adapter,
+  struct flash_section_info *fsec, int type)
+{
+   int i = 0, img_type = 0;
+   struct flash_section_info_g2 *fsec_g2 = NULL;
+
+   if (BE2_chip(adapter))
+   fsec_g2 = (struct flash_section_info_g2 *)fsec;
+
+   for (i = 0; i < MAX_FLASH_COMP; i++) {
+   if (fsec_g2)
+   img_type = le32_to_cpu(fsec_g2->fsec_entry[i].type);
+   else
+   img_type = le32_to_cpu(fsec->fsec_entry[i].type);
+
+   if (img_type == type)
+   return true;
+   }
+   return false;
+}
+
+static struct flash_section_info *get_fsec_info(struct be_adapter *adapter,
+   int header_size,
+   const struct firmware *fw)
+{
+   struct flash_section_info *fsec = NULL;
+   const u8 *p = fw->data;
+
+   p += header_size;
+   while (p < (fw->data + fw->size)) {
+   fsec = (struct flash_section_info *)p;
+   if (!memcmp(flash_cookie, fsec->cookie, sizeof(flash_cookie)))
+   return fsec;
+   p += 32;
+   }
+   return NULL;
+}
+
+static int be_check_flash_crc(struct be_adapter *adapter, const u8 *p,
+ u32 img_offset, u32 img_size, int hdr_size,
+ u16 img_optype, bool *crc_match)
+{
+   u32 crc_offset;
+   int status;
+   u8 crc[4];
+
+   status = be_cmd_get_flash_crc(adapter, crc, img_optype, img_offset,
+ img_size - 4);
+   if (status)
+   return status;
+

[PATCH net-next v2 10/10] be2net: bump up the driver version to 11.0.0.0

2015-12-27 Thread Sathya Perla
From: Suresh Reddy 

Signed-off-by: Suresh Reddy 
Signed-off-by: Sathya Perla 
---
 drivers/net/ethernet/emulex/benet/be.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/emulex/benet/be.h 
b/drivers/net/ethernet/emulex/benet/be.h
index 8b8212f..22bf7af 100644
--- a/drivers/net/ethernet/emulex/benet/be.h
+++ b/drivers/net/ethernet/emulex/benet/be.h
@@ -37,7 +37,7 @@
 #include "be_hw.h"
 #include "be_roce.h"
 
-#define DRV_VER"10.6.0.3"
+#define DRV_VER"11.0.0.0"
 #define DRV_NAME   "be2net"
 #define BE_NAME"Emulex BladeEngine2"
 #define BE3_NAME   "Emulex BladeEngine3"
-- 
2.4.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-next v2 07/10] be2net: remove unused error variables

2015-12-27 Thread Sathya Perla
From: Venkat Duvvuru 

eeh_error, fw_timeout, hw_error variables in the be_adapter structure are
not used anymore. An earlier patch that introduced adapter->err_flags to
store this information missed removing these variables.

Signed-off-by: Venkat Duvvuru 
Signed-off-by: Sathya Perla 
---
 drivers/net/ethernet/emulex/benet/be.h | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/net/ethernet/emulex/benet/be.h 
b/drivers/net/ethernet/emulex/benet/be.h
index 93e5eab..0af32f1 100644
--- a/drivers/net/ethernet/emulex/benet/be.h
+++ b/drivers/net/ethernet/emulex/benet/be.h
@@ -547,10 +547,6 @@ struct be_adapter {
 
u32 beacon_state;   /* for set_phys_id */
 
-   bool eeh_error;
-   bool fw_timeout;
-   bool hw_error;
-
u32 port_num;
char port_name;
u8 mc_type;
-- 
2.4.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-next v2 09/10] be2net: support ethtool get-dump option

2015-12-27 Thread Sathya Perla
From: Venkat Duvvuru 

This patch adds support for ethtool's --get-dump option in be2net,
to retrieve FW dump. In the past when this option was not yet available,
this feature was supported via the --register-dump option as a workaround.
This patch removes support for FW-dump via --register-dump option as it is
now available via --get-dump option. Even though the
"ethtool --register-dump" cmd which used to work earlier, will now fail
with ENOTSUPP error, we feel it is not an issue as this is used only
for diagnostics purpose.

Signed-off-by: Venkat Duvvuru 
Signed-off-by: Sathya Perla 
---
 drivers/net/ethernet/emulex/benet/be.h |  1 +
 drivers/net/ethernet/emulex/benet/be_cmds.c| 38 
 drivers/net/ethernet/emulex/benet/be_cmds.h|  4 +-
 drivers/net/ethernet/emulex/benet/be_ethtool.c | 82 --
 drivers/net/ethernet/emulex/benet/be_main.c|  3 +
 5 files changed, 71 insertions(+), 57 deletions(-)

diff --git a/drivers/net/ethernet/emulex/benet/be.h 
b/drivers/net/ethernet/emulex/benet/be.h
index 66988f4..8b8212f 100644
--- a/drivers/net/ethernet/emulex/benet/be.h
+++ b/drivers/net/ethernet/emulex/benet/be.h
@@ -592,6 +592,7 @@ struct be_adapter {
struct rss_info rss_info;
/* Filters for packets that need to be sent to BMC */
u32 bmc_filt_mask;
+   u32 fat_dump_len;
u16 serial_num[CNTL_SERIAL_NUM_WORDS];
 };
 
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c 
b/drivers/net/ethernet/emulex/benet/be_cmds.c
index 87c3dba..5a5b40d 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.c
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.c
@@ -1712,49 +1712,40 @@ err:
 }
 
 /* Uses synchronous mcc */
-int be_cmd_get_reg_len(struct be_adapter *adapter, u32 *log_size)
+int be_cmd_get_fat_dump_len(struct be_adapter *adapter, u32 *dump_size)
 {
-   struct be_mcc_wrb *wrb;
+   struct be_mcc_wrb wrb = {0};
struct be_cmd_req_get_fat *req;
int status;
 
-   spin_lock_bh(&adapter->mcc_lock);
-
-   wrb = wrb_from_mccq(adapter);
-   if (!wrb) {
-   status = -EBUSY;
-   goto err;
-   }
-   req = embedded_payload(wrb);
+   req = embedded_payload(&wrb);
 
be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON,
-  OPCODE_COMMON_MANAGE_FAT, sizeof(*req), wrb,
-  NULL);
+  OPCODE_COMMON_MANAGE_FAT, sizeof(*req),
+  &wrb, NULL);
req->fat_operation = cpu_to_le32(QUERY_FAT);
-   status = be_mcc_notify_wait(adapter);
+   status = be_cmd_notify_wait(adapter, &wrb);
if (!status) {
-   struct be_cmd_resp_get_fat *resp = embedded_payload(wrb);
+   struct be_cmd_resp_get_fat *resp = embedded_payload(&wrb);
 
-   if (log_size && resp->log_size)
-   *log_size = le32_to_cpu(resp->log_size) -
+   if (dump_size && resp->log_size)
+   *dump_size = le32_to_cpu(resp->log_size) -
sizeof(u32);
}
-err:
-   spin_unlock_bh(&adapter->mcc_lock);
return status;
 }
 
-int be_cmd_get_regs(struct be_adapter *adapter, u32 buf_len, void *buf)
+int be_cmd_get_fat_dump(struct be_adapter *adapter, u32 buf_len, void *buf)
 {
struct be_dma_mem get_fat_cmd;
struct be_mcc_wrb *wrb;
struct be_cmd_req_get_fat *req;
u32 offset = 0, total_size, buf_size,
log_offset = sizeof(u32), payload_len;
-   int status = 0;
+   int status;
 
if (buf_len == 0)
-   return -EIO;
+   return 0;
 
total_size = buf_len;
 
@@ -1762,11 +1753,8 @@ int be_cmd_get_regs(struct be_adapter *adapter, u32 
buf_len, void *buf)
get_fat_cmd.va = dma_zalloc_coherent(&adapter->pdev->dev,
 get_fat_cmd.size,
 &get_fat_cmd.dma, GFP_ATOMIC);
-   if (!get_fat_cmd.va) {
-   dev_err(&adapter->pdev->dev,
-   "Memory allocation failure while reading FAT data\n");
+   if (!get_fat_cmd.va)
return -ENOMEM;
-   }
 
spin_lock_bh(&adapter->mcc_lock);
 
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.h 
b/drivers/net/ethernet/emulex/benet/be_cmds.h
index 5098170..241819b 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.h
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.h
@@ -2365,9 +2365,9 @@ int be_cmd_config_qos(struct be_adapter *adapter, u32 
max_rate,
 void be_detect_error(struct be_adapter *adapter);
 int be_cmd_get_die_temperature(struct be_adapter *adapter);
 int be_cmd_get_cntl_attributes(struct be_adapter *adapter);
+int be_cmd_get_fat_dump_len(str

[PATCH net-next v2 02/10] be2net: avoid configuring VEPA mode on BE3

2015-12-27 Thread Sathya Perla
From: Suresh Reddy 

BE3 chip doesn't support VEPA mode.

Signed-off-by: Suresh Reddy 
Signed-off-by: Sathya Perla 
---
 drivers/net/ethernet/emulex/benet/be_main.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/ethernet/emulex/benet/be_main.c 
b/drivers/net/ethernet/emulex/benet/be_main.c
index 34e324f..2f76cbe 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -5108,6 +5108,9 @@ static int be_ndo_bridge_setlink(struct net_device *dev, 
struct nlmsghdr *nlh,
return -EINVAL;
 
mode = nla_get_u16(attr);
+   if (BE3_chip(adapter) && mode == BRIDGE_MODE_VEPA)
+   return -EOPNOTSUPP;
+
if (mode != BRIDGE_MODE_VEPA && mode != BRIDGE_MODE_VEB)
return -EINVAL;
 
-- 
2.4.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-next v2 03/10] be2net: cleanup FW flash image related macro defines

2015-12-27 Thread Sathya Perla
From: Suresh Reddy 

Many constant definitions relating to the FW-image layout
(such as section offset values) were defined in decimal format rather than
hexa-decimal. This makes this part of the code un-readable. Also some
defines related to BE2 are labeld "g2" and defines related to BE3 are
labeled "g3".  This patch cleans up all of this to make this code more
readable.

Signed-off-by: Suresh Reddy 
Signed-off-by: Sathya Perla 
---
 drivers/net/ethernet/emulex/benet/be_cmds.h | 141 
 drivers/net/ethernet/emulex/benet/be_main.c |  78 +++
 2 files changed, 118 insertions(+), 101 deletions(-)

diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.h 
b/drivers/net/ethernet/emulex/benet/be_cmds.h
index 9690c3a..8c6b606 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.h
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.h
@@ -1207,68 +1207,85 @@ struct be_cmd_resp_get_beacon_state {
 /* Flashrom related descriptors */
 #define MAX_FLASH_COMP 32
 
-#define OPTYPE_ISCSI_ACTIVE0
-#define OPTYPE_REDBOOT 1
-#define OPTYPE_BIOS2
-#define OPTYPE_PXE_BIOS3
-#define OPTYPE_OFFSET_SPECIFIED7
-#define OPTYPE_FCOE_BIOS   8
-#define OPTYPE_ISCSI_BACKUP9
-#define OPTYPE_FCOE_FW_ACTIVE  10
-#define OPTYPE_FCOE_FW_BACKUP  11
-#define OPTYPE_NCSI_FW 13
-#define OPTYPE_REDBOOT_DIR 18
-#define OPTYPE_REDBOOT_CONFIG  19
-#define OPTYPE_SH_PHY_FW   21
-#define OPTYPE_FLASHISM_JUMPVECTOR 22
-#define OPTYPE_UFI_DIR 23
-#define OPTYPE_PHY_FW  99
-
-#define FLASH_BIOS_IMAGE_MAX_SIZE_g2   262144  /* Max OPTION ROM image sz */
-#define FLASH_REDBOOT_IMAGE_MAX_SIZE_g2262144  /* Max Redboot image sz 
   */
-#define FLASH_IMAGE_MAX_SIZE_g21310720 /* Max firmware image 
size */
-
-#define FLASH_NCSI_IMAGE_MAX_SIZE_g3   262144
-#define FLASH_PHY_FW_IMAGE_MAX_SIZE_g3 262144
-#define FLASH_BIOS_IMAGE_MAX_SIZE_g3   524288  /* Max OPTION ROM image sz */
-#define FLASH_REDBOOT_IMAGE_MAX_SIZE_g31048576 /* Max Redboot image sz 
   */
-#define FLASH_IMAGE_MAX_SIZE_g32097152 /* Max firmware image 
size */
-
-/* Offsets for components on Flash. */
-#define FLASH_REDBOOT_START_g2 0
-#define FLASH_FCoE_BIOS_START_g2   524288
-#define FLASH_iSCSI_PRIMARY_IMAGE_START_g2 1048576
-#define FLASH_iSCSI_BACKUP_IMAGE_START_g2  2359296
-#define FLASH_FCoE_PRIMARY_IMAGE_START_g2  3670016
-#define FLASH_FCoE_BACKUP_IMAGE_START_g2   4980736
-#define FLASH_iSCSI_BIOS_START_g2  7340032
-#define FLASH_PXE_BIOS_START_g27864320
-
-#define FLASH_REDBOOT_START_g3 262144
-#define FLASH_PHY_FW_START_g3  1310720
-#define FLASH_iSCSI_PRIMARY_IMAGE_START_g3 2097152
-#define FLASH_iSCSI_BACKUP_IMAGE_START_g3  4194304
-#define FLASH_FCoE_PRIMARY_IMAGE_START_g3  6291456
-#define FLASH_FCoE_BACKUP_IMAGE_START_g3   8388608
-#define FLASH_iSCSI_BIOS_START_g3  12582912
-#define FLASH_PXE_BIOS_START_g313107200
-#define FLASH_FCoE_BIOS_START_g3   13631488
-#define FLASH_NCSI_START_g315990784
-
-#define IMAGE_NCSI 16
-#define IMAGE_OPTION_ROM_PXE   32
-#define IMAGE_OPTION_ROM_FCoE  33
-#define IMAGE_OPTION_ROM_ISCSI 34
-#define IMAGE_FLASHISM_JUMPVECTOR  48
-#define IMAGE_FIRMWARE_iSCSI   160
-#define IMAGE_FIRMWARE_FCoE162
-#define IMAGE_FIRMWARE_BACKUP_iSCSI176
-#define IMAGE_FIRMWARE_BACKUP_FCoE 178
-#define IMAGE_FIRMWARE_PHY 192
-#define IMAGE_REDBOOT_DIR  208
-#define IMAGE_REDBOOT_CONFIG   209
-#define IMAGE_UFI_DIR  210
-#define IMAGE_BOOT_CODE224
+/* Optypes of each component in the UFI */
+enum {
+   OPTYPE_ISCSI_ACTIVE = 0,
+   OPTYPE_REDBOOT = 1,
+   OPTYPE_BIOS = 2,
+   OPTYPE_PXE_BIOS = 3,
+   OPTYPE_OFFSET_SPECIFIED = 7,
+   OPTYPE_FCOE_BIOS = 8,
+   OPTYPE_ISCSI_BACKUP = 9,
+   OPTYPE_FCOE_FW_ACTIVE = 10,
+   OPTYPE_FCOE_FW_BACKUP = 11,
+   OPTYPE_NCSI_FW = 13,
+   OPTYPE_REDBOOT_DIR = 18,
+   OPTYPE_REDBOOT_CONFIG = 19,
+   OPTYPE_SH_PHY_FW = 21,
+   OPTYPE_FLASHISM_JUMPVECTOR = 22,
+   OPTYPE_UFI_DIR = 23,
+   OPTYPE_PHY_FW = 99
+};
+
+/* Maximum sizes of components in BE2 FW UFI */
+enum {
+   BE2_BIOS_COMP_MAX_SIZE = 0x4,
+   BE2_REDBOOT_COMP_MAX_SIZE = 0x4,
+   BE2_COMP_MAX_SIZE = 0x14
+};
+
+/* Maximum sizes of components in BE3 FW UFI */
+enum {
+   BE3_NCSI_COMP_MAX_SIZE = 0x4,
+   BE3_PHY_FW_COMP_MAX_SIZE = 0x4,
+   BE3_BIOS_COMP_MAX_SIZE = 0x8,
+   BE3_REDBOOT_COMP

[PATCH net-next v2 00/10] be2net: patch set

2015-12-27 Thread Sathya Perla
Hi David,
The following patch set contains some feature additions, code re-organization
and cleanup and a few non-critical fixes. Pls consider applying this to
the net-next tree. Thanks.

v2 changes: replaced an if/else block that checks for error values with a
switch/case statement in patch 5.

Patch 1 fixes VF link state transition from disabled to auto that did
not work due to an issue in the FW. This issue could not be fixed in FW due
to some backward compatibility issues it causes with released drivers.
The issue has been fixed by introducing a new version (v2) of the cmd
from 10.6 FW onwards. This patch adds support for v2 version of this cmd.

Patch 2 reports a EOPNOTSUPP status to ethtool when the user tries to
configure BE3/SRIOV in VEPA mode as it is not supported by the chip.

Patch 3 cleansup FW flash image related constant definitions. Many of these
definitions (such as section offset values) were defined in decimal format
rather than hexa-decimal. This makes this part of the code un-readable.
Also some defines related to BE2 are labeld "g2" and defines related to BE3
are labeled "g3".  This patch cleans up all of this to make this code more
readable.

Patch 4 moves the FW cmd code to be_cmds.c. All code relating to FW cmds
has been in be_cmds.[ch], excepting FW flash cmd related code.
This patch moves these routines from be_main.c to be_cmds.c.

Patch 5 adds a log message to report digital signature errors while
flashing a FW image. From FW version 11.0 onwards, the FW supports a new
"secure mode" feature (based on a jumper setting on the adapter.) In this
mode, the FW image when flashed is authenticated with a digital signature.

Patch 6 removes a line of code that has no effect.

Patch 7 removes some unused variables.

Patch 8 fixes port resource descriptor query via the GET_PROFILE FW cmd.
An earlier commit passed a specific pf_num while issuing this cmd as FW
returns descriptors for all functions when pf_num is zero. But, when pf_num
is set to a non-zero value, FW does not return the port resource descriptor.
This patch fixes this by setting pf_num to 0 while issuing the query cmd
and adds code to pick the correct NIC resource descriptor from the list of
descriptors returned by FW.

Patch 9 adds support for ethtool get-dump feature. In the past when this
option was not yet available, this feature was supported via the
--register-dump option as a workaround.  This patch removes support for
FW-dump via --register-dump option as it is now available via --get-dump
option. Even though the "ethtool --register-dump" cmd which used to work
earlier, will now fail with ENOTSUPP error, we feel it is not an issue as
this is used only for diagnostics purpose.

Patch 10 bumps up the driver version.
Sathya Perla (1):
  be2net: remove a line of code that has no effect

Suresh Reddy (7):
  be2net: fix VF link state transition from disabled to auto
  be2net: avoid configuring VEPA mode on BE3
  be2net: cleanup FW flash image related macro defines
  be2net: move FW flash cmd code to be_cmds.c
  be2net: log digital signature errors while flashing FW image
  be2net: fix port-res desc query of GET_PROFILE_CONFIG FW cmd
  be2net: bump up the driver version to 11.0.0.0

Venkat Duvvuru (2):
  be2net: remove unused error variables
  be2net: support ethtool get-dump option

 drivers/net/ethernet/emulex/benet/be.h |  13 +-
 drivers/net/ethernet/emulex/benet/be_cmds.c| 755 ++---
 drivers/net/ethernet/emulex/benet/be_cmds.h| 178 +++---
 drivers/net/ethernet/emulex/benet/be_ethtool.c |  82 ++-
 drivers/net/ethernet/emulex/benet/be_main.c| 588 +--
 5 files changed, 840 insertions(+), 776 deletions(-)

-- 
2.4.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-next v2 01/10] be2net: fix VF link state transition from disabled to auto

2015-12-27 Thread Sathya Perla
From: Suresh Reddy 

The VF link state setting transition from "disable" to "auto" does not work
due to a bug in SET_LOGICAL_LINK_CONFIG_V1 cmd in FW. This issue could not
be fixed in FW due to some backward compatibility issues it causes with
some released drivers. The issue has been fixed by introducing a new
version (v2) of the cmd from 10.6 FW onwards. In v2, to set the VF link
state to auto, both PLINK_ENABLE and PLINK_TRACK bits have to be set to 1.

The VF link state setting feature now works on Lancer chips too from
FW ver 10.6.315.0 onwards.

Signed-off-by: Suresh Reddy 
Signed-off-by: Sathya Perla 
---
 drivers/net/ethernet/emulex/benet/be_cmds.c | 35 +
 drivers/net/ethernet/emulex/benet/be_cmds.h |  3 ++-
 2 files changed, 28 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c 
b/drivers/net/ethernet/emulex/benet/be_cmds.c
index 1795c93..8083eca 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.c
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.c
@@ -4260,16 +4260,13 @@ err:
return status;
 }
 
-int be_cmd_set_logical_link_config(struct be_adapter *adapter,
-  int link_state, u8 domain)
+int __be_cmd_set_logical_link_config(struct be_adapter *adapter,
+int link_state, int version, u8 domain)
 {
struct be_mcc_wrb *wrb;
struct be_cmd_req_set_ll_link *req;
int status;
 
-   if (BEx_chip(adapter) || lancer_chip(adapter))
-   return -EOPNOTSUPP;
-
spin_lock_bh(&adapter->mcc_lock);
 
wrb = wrb_from_mccq(adapter);
@@ -4284,14 +4281,15 @@ int be_cmd_set_logical_link_config(struct be_adapter 
*adapter,
   OPCODE_COMMON_SET_LOGICAL_LINK_CONFIG,
   sizeof(*req), wrb, NULL);
 
-   req->hdr.version = 1;
+   req->hdr.version = version;
req->hdr.domain = domain;
 
-   if (link_state == IFLA_VF_LINK_STATE_ENABLE)
-   req->link_config |= 1;
+   if (link_state == IFLA_VF_LINK_STATE_ENABLE ||
+   link_state == IFLA_VF_LINK_STATE_AUTO)
+   req->link_config |= PLINK_ENABLE;
 
if (link_state == IFLA_VF_LINK_STATE_AUTO)
-   req->link_config |= 1 << PLINK_TRACK_SHIFT;
+   req->link_config |= PLINK_TRACK;
 
status = be_mcc_notify_wait(adapter);
 err:
@@ -4299,6 +4297,25 @@ err:
return status;
 }
 
+int be_cmd_set_logical_link_config(struct be_adapter *adapter,
+  int link_state, u8 domain)
+{
+   int status;
+
+   if (BEx_chip(adapter))
+   return -EOPNOTSUPP;
+
+   status = __be_cmd_set_logical_link_config(adapter, link_state,
+ 2, domain);
+
+   /* Version 2 of the command will not be recognized by older FW.
+* On such a failure issue version 1 of the command.
+*/
+   if (base_status(status) == MCC_STATUS_ILLEGAL_REQUEST)
+   status = __be_cmd_set_logical_link_config(adapter, link_state,
+ 1, domain);
+   return status;
+}
 int be_roce_mcc_cmd(void *netdev_handle, void *wrb_payload,
int wrb_payload_size, u16 *cmd_status, u16 *ext_status)
 {
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.h 
b/drivers/net/ethernet/emulex/benet/be_cmds.h
index 91155ea..9690c3a 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.h
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.h
@@ -2246,7 +2246,8 @@ struct be_cmd_resp_get_iface_list {
 };
 
 /*** Set logical link /
-#define PLINK_TRACK_SHIFT  8
+#define PLINK_ENABLEBIT(0)
+#define PLINK_TRACK BIT(8)
 struct be_cmd_req_set_ll_link {
struct be_cmd_req_hdr hdr;
u32 link_config; /* Bit 0: UP_DOWN, Bit 9: PLINK */
-- 
2.4.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[net-next PATCH 00/10] be2net: patch set

2015-12-24 Thread Sathya Perla
Hi David,
The following patch set contains some feature additions, code re-organization
and cleanup and a few non-critical fixes. Pls consider applying this to
the net-next tree. Thanks.

Patch 1 fixes VF link state transition from disabled to auto that did
not work due to an issue in the FW. This issue could not be fixed in FW due
to some backward compatibility issues it causes with released drivers.
The issue has been fixed by introducing a new version (v2) of the cmd
from 10.6 FW onwards. This patch adds support for v2 version of this cmd.

Patch 2 reports a EOPNOTSUPP status to ethtool when the user tries to
configure BE3/SRIOV in VEPA mode as it is not supported by the chip.

Patch 3 cleansup FW flash image related constant definitions. Many of these
definitions (such as section offset values) were defined in decimal format
rather than hexa-decimal. This makes this part of the code un-readable.
Also some defines related to BE2 are labeld "g2" and defines related to BE3
are labeled "g3".  This patch cleans up all of this to make this code more
readable.

Patch 4 moves the FW cmd code to be_cmds.c. All code relating to FW cmds
has been in be_cmds.[ch], excepting FW flash cmd related code.
This patch moves these routines from be_main.c to be_cmds.c.

Patch 5 adds a log message to report digital signature errors while
flashing a FW image. From FW version 11.0 onwards, the FW supports a new
"secure mode" feature (based on a jumper setting on the adapter.) In this
mode, the FW image when flashed is authenticated with a digital signature.

Patch 6 removes a line of code that has no effect.

Patch 7 removes some unused variables.

Patch 8 fixes port resource descriptor query via the GET_PROFILE FW cmd.
An earlier commit passed a specific pf_num while issuing this cmd as FW
returns descriptors for all functions when pf_num is zero. But, when pf_num
is set to a non-zero value, FW does not return the port resource descriptor.
This patch fixes this by setting pf_num to 0 while issuing the query cmd
and adds code to pick the correct NIC resource descriptor from the list of
descriptors returned by FW.

Patch 9 adds support for ethtool get-dump feature. In the past when this
option was not yet available, this feature was supported via the
--register-dump option as a workaround.  This patch removes support for
FW-dump via --register-dump option as it is now available via --get-dump
option. Even though the "ethtool --register-dump" cmd which used to work
earlier, will now fail with ENOTSUPP error, we feel it is not an issue as
this is used only for diagnostics purpose.

Patch 10 bumps up the driver version.

Sathya Perla (1):
  be2net: remove a line of code that has no effect

Suresh Reddy (7):
  be2net: fix VF link state transition from disabled to auto
  be2net: avoid configuring VEPA mode on BE3
  be2net: cleanup FW flash image related macro defines
  be2net: move FW flash cmd code to be_cmds.c
  be2net: log digital signature errors while flashing FW image
  be2net: fix port-res desc query of GET_PROFILE_CONFIG FW cmd
  be2net: bump up the driver version to 11.0.0.0

Venkat Duvvuru (2):
  be2net: remove unused error variables
  be2net: support ethtool get-dump option

 drivers/net/ethernet/emulex/benet/be.h |  13 +-
 drivers/net/ethernet/emulex/benet/be_cmds.c| 755 ++---
 drivers/net/ethernet/emulex/benet/be_cmds.h| 178 +++---
 drivers/net/ethernet/emulex/benet/be_ethtool.c |  82 ++-
 drivers/net/ethernet/emulex/benet/be_main.c| 588 +--
 5 files changed, 840 insertions(+), 776 deletions(-)

-- 
2.4.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[net-next PATCH 09/10] be2net: support ethtool get-dump option

2015-12-24 Thread Sathya Perla
From: Venkat Duvvuru 

This patch adds support for ethtool's --get-dump option in be2net,
to retrieve FW dump. In the past when this option was not yet available,
this feature was supported via the --register-dump option as a workaround.
This patch removes support for FW-dump via --register-dump option as it is
now available via --get-dump option. Even though the
"ethtool --register-dump" cmd which used to work earlier, will now fail
with ENOTSUPP error, we feel it is not an issue as this is used only
for diagnostics purpose.

Signed-off-by: Venkat Duvvuru 
Signed-off-by: Sathya Perla 
---
 drivers/net/ethernet/emulex/benet/be.h |  1 +
 drivers/net/ethernet/emulex/benet/be_cmds.c| 38 
 drivers/net/ethernet/emulex/benet/be_cmds.h|  4 +-
 drivers/net/ethernet/emulex/benet/be_ethtool.c | 82 --
 drivers/net/ethernet/emulex/benet/be_main.c|  3 +
 5 files changed, 71 insertions(+), 57 deletions(-)

diff --git a/drivers/net/ethernet/emulex/benet/be.h 
b/drivers/net/ethernet/emulex/benet/be.h
index 66988f4..8b8212f 100644
--- a/drivers/net/ethernet/emulex/benet/be.h
+++ b/drivers/net/ethernet/emulex/benet/be.h
@@ -592,6 +592,7 @@ struct be_adapter {
struct rss_info rss_info;
/* Filters for packets that need to be sent to BMC */
u32 bmc_filt_mask;
+   u32 fat_dump_len;
u16 serial_num[CNTL_SERIAL_NUM_WORDS];
 };
 
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c 
b/drivers/net/ethernet/emulex/benet/be_cmds.c
index 3ffe0c7..80fb981 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.c
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.c
@@ -1712,49 +1712,40 @@ err:
 }
 
 /* Uses synchronous mcc */
-int be_cmd_get_reg_len(struct be_adapter *adapter, u32 *log_size)
+int be_cmd_get_fat_dump_len(struct be_adapter *adapter, u32 *dump_size)
 {
-   struct be_mcc_wrb *wrb;
+   struct be_mcc_wrb wrb = {0};
struct be_cmd_req_get_fat *req;
int status;
 
-   spin_lock_bh(&adapter->mcc_lock);
-
-   wrb = wrb_from_mccq(adapter);
-   if (!wrb) {
-   status = -EBUSY;
-   goto err;
-   }
-   req = embedded_payload(wrb);
+   req = embedded_payload(&wrb);
 
be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON,
-  OPCODE_COMMON_MANAGE_FAT, sizeof(*req), wrb,
-  NULL);
+  OPCODE_COMMON_MANAGE_FAT, sizeof(*req),
+  &wrb, NULL);
req->fat_operation = cpu_to_le32(QUERY_FAT);
-   status = be_mcc_notify_wait(adapter);
+   status = be_cmd_notify_wait(adapter, &wrb);
if (!status) {
-   struct be_cmd_resp_get_fat *resp = embedded_payload(wrb);
+   struct be_cmd_resp_get_fat *resp = embedded_payload(&wrb);
 
-   if (log_size && resp->log_size)
-   *log_size = le32_to_cpu(resp->log_size) -
+   if (dump_size && resp->log_size)
+   *dump_size = le32_to_cpu(resp->log_size) -
sizeof(u32);
}
-err:
-   spin_unlock_bh(&adapter->mcc_lock);
return status;
 }
 
-int be_cmd_get_regs(struct be_adapter *adapter, u32 buf_len, void *buf)
+int be_cmd_get_fat_dump(struct be_adapter *adapter, u32 buf_len, void *buf)
 {
struct be_dma_mem get_fat_cmd;
struct be_mcc_wrb *wrb;
struct be_cmd_req_get_fat *req;
u32 offset = 0, total_size, buf_size,
log_offset = sizeof(u32), payload_len;
-   int status = 0;
+   int status;
 
if (buf_len == 0)
-   return -EIO;
+   return 0;
 
total_size = buf_len;
 
@@ -1762,11 +1753,8 @@ int be_cmd_get_regs(struct be_adapter *adapter, u32 
buf_len, void *buf)
get_fat_cmd.va = dma_zalloc_coherent(&adapter->pdev->dev,
 get_fat_cmd.size,
 &get_fat_cmd.dma, GFP_ATOMIC);
-   if (!get_fat_cmd.va) {
-   dev_err(&adapter->pdev->dev,
-   "Memory allocation failure while reading FAT data\n");
+   if (!get_fat_cmd.va)
return -ENOMEM;
-   }
 
spin_lock_bh(&adapter->mcc_lock);
 
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.h 
b/drivers/net/ethernet/emulex/benet/be_cmds.h
index 5098170..241819b 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.h
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.h
@@ -2365,9 +2365,9 @@ int be_cmd_config_qos(struct be_adapter *adapter, u32 
max_rate,
 void be_detect_error(struct be_adapter *adapter);
 int be_cmd_get_die_temperature(struct be_adapter *adapter);
 int be_cmd_get_cntl_attributes(struct be_adapter *adapter);
+int be_cmd_get_fat_dump_len(str

[net-next PATCH 02/10] be2net: avoid configuring VEPA mode on BE3

2015-12-24 Thread Sathya Perla
From: Suresh Reddy 

BE3 chip doesn't support VEPA mode.

Signed-off-by: Suresh Reddy 
Signed-off-by: Sathya Perla 
---
 drivers/net/ethernet/emulex/benet/be_main.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/ethernet/emulex/benet/be_main.c 
b/drivers/net/ethernet/emulex/benet/be_main.c
index 34e324f..2f76cbe 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -5108,6 +5108,9 @@ static int be_ndo_bridge_setlink(struct net_device *dev, 
struct nlmsghdr *nlh,
return -EINVAL;
 
mode = nla_get_u16(attr);
+   if (BE3_chip(adapter) && mode == BRIDGE_MODE_VEPA)
+   return -EOPNOTSUPP;
+
if (mode != BRIDGE_MODE_VEPA && mode != BRIDGE_MODE_VEB)
return -EINVAL;
 
-- 
2.4.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[net-next PATCH 07/10] be2net: remove unused error variables

2015-12-24 Thread Sathya Perla
From: Venkat Duvvuru 

eeh_error, fw_timeout, hw_error variables in the be_adapter structure are
not used anymore. An earlier patch that introduced adapter->err_flags to
store this information missed removing these variables.

Signed-off-by: Venkat Duvvuru 
Signed-off-by: Sathya Perla 
---
 drivers/net/ethernet/emulex/benet/be.h | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/net/ethernet/emulex/benet/be.h 
b/drivers/net/ethernet/emulex/benet/be.h
index 93e5eab..0af32f1 100644
--- a/drivers/net/ethernet/emulex/benet/be.h
+++ b/drivers/net/ethernet/emulex/benet/be.h
@@ -547,10 +547,6 @@ struct be_adapter {
 
u32 beacon_state;   /* for set_phys_id */
 
-   bool eeh_error;
-   bool fw_timeout;
-   bool hw_error;
-
u32 port_num;
char port_name;
u8 mc_type;
-- 
2.4.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[net-next PATCH 06/10] be2net: remove a line of code that has no effect

2015-12-24 Thread Sathya Perla
This patch removes a line of code that changes adapter->recommended_prio
value followed by yet another assignment.
Also, the variable is used to store the vlan priority value that is already
shifted to the PCP bits position in the vlan tag format. Hence, the name of
this variable is changed to recommended_prio_bits.

Signed-off-by: Sathya Perla 
---
 drivers/net/ethernet/emulex/benet/be.h  | 2 +-
 drivers/net/ethernet/emulex/benet/be_cmds.c | 3 +--
 drivers/net/ethernet/emulex/benet/be_main.c | 2 +-
 3 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/emulex/benet/be.h 
b/drivers/net/ethernet/emulex/benet/be.h
index d463563..93e5eab 100644
--- a/drivers/net/ethernet/emulex/benet/be.h
+++ b/drivers/net/ethernet/emulex/benet/be.h
@@ -521,7 +521,7 @@ struct be_adapter {
struct be_drv_stats drv_stats;
struct be_aic_obj aic_obj[MAX_EVT_QS];
u8 vlan_prio_bmap;  /* Available Priority BitMap */
-   u16 recommended_prio;   /* Recommended Priority */
+   u16 recommended_prio_bits;/* Recommended Priority bits in vlan tag */
struct be_dma_mem rx_filter; /* Cmd DMA mem for rx-filter */
 
struct be_dma_mem stats_cmd;
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c 
b/drivers/net/ethernet/emulex/benet/be_cmds.c
index 6fb7873..8de876b 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.c
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.c
@@ -308,8 +308,7 @@ static void be_async_grp5_cos_priority_process(struct 
be_adapter *adapter,
 
if (evt->valid) {
adapter->vlan_prio_bmap = evt->available_priority_bmap;
-   adapter->recommended_prio &= ~VLAN_PRIO_MASK;
-   adapter->recommended_prio =
+   adapter->recommended_prio_bits =
evt->reco_default_priority << VLAN_PRIO_SHIFT;
}
 }
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c 
b/drivers/net/ethernet/emulex/benet/be_main.c
index 646b021..c9f9d4b 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -729,7 +729,7 @@ static inline u16 be_get_tx_vlan_tag(struct be_adapter 
*adapter,
/* If vlan priority provided by OS is NOT in available bmap */
if (!(adapter->vlan_prio_bmap & (1 << vlan_prio)))
vlan_tag = (vlan_tag & ~VLAN_PRIO_MASK) |
-   adapter->recommended_prio;
+   adapter->recommended_prio_bits;
 
return vlan_tag;
 }
-- 
2.4.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[net-next PATCH 04/10] be2net: move FW flash cmd code to be_cmds.c

2015-12-24 Thread Sathya Perla
From: Suresh Reddy 

All code relating to FW cmds is in be_cmds.[ch] excepting FW flash cmd
related code. This patch moves these routines from be_main.c to be_cmds.c

Signed-off-by: Suresh Reddy 
Signed-off-by: Sathya Perla 
---
 drivers/net/ethernet/emulex/benet/be_cmds.c | 583 +++-
 drivers/net/ethernet/emulex/benet/be_cmds.h |  15 +-
 drivers/net/ethernet/emulex/benet/be_main.c | 564 ---
 3 files changed, 578 insertions(+), 584 deletions(-)

diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c 
b/drivers/net/ethernet/emulex/benet/be_cmds.c
index 8083eca..da3b398 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.c
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.c
@@ -2291,10 +2291,11 @@ err:
return status;
 }
 
-int lancer_cmd_write_object(struct be_adapter *adapter, struct be_dma_mem *cmd,
-   u32 data_size, u32 data_offset,
-   const char *obj_name, u32 *data_written,
-   u8 *change_status, u8 *addn_status)
+static int lancer_cmd_write_object(struct be_adapter *adapter,
+  struct be_dma_mem *cmd, u32 data_size,
+  u32 data_offset, const char *obj_name,
+  u32 *data_written, u8 *change_status,
+  u8 *addn_status)
 {
struct be_mcc_wrb *wrb;
struct lancer_cmd_req_write_object *req;
@@ -2410,7 +2411,8 @@ int be_cmd_query_sfp_info(struct be_adapter *adapter)
return status;
 }
 
-int lancer_cmd_delete_object(struct be_adapter *adapter, const char *obj_name)
+static int lancer_cmd_delete_object(struct be_adapter *adapter,
+   const char *obj_name)
 {
struct lancer_cmd_req_delete_object *req;
struct be_mcc_wrb *wrb;
@@ -2485,9 +2487,9 @@ err_unlock:
return status;
 }
 
-int be_cmd_write_flashrom(struct be_adapter *adapter, struct be_dma_mem *cmd,
- u32 flash_type, u32 flash_opcode, u32 img_offset,
- u32 buf_size)
+static int be_cmd_write_flashrom(struct be_adapter *adapter,
+struct be_dma_mem *cmd, u32 flash_type,
+u32 flash_opcode, u32 img_offset, u32 buf_size)
 {
struct be_mcc_wrb *wrb;
struct be_cmd_write_flashrom *req;
@@ -2533,8 +2535,8 @@ err_unlock:
return status;
 }
 
-int be_cmd_get_flash_crc(struct be_adapter *adapter, u8 *flashed_crc,
-u16 img_optype, u32 img_offset, u32 crc_offset)
+static int be_cmd_get_flash_crc(struct be_adapter *adapter, u8 *flashed_crc,
+   u16 img_optype, u32 img_offset, u32 crc_offset)
 {
struct be_cmd_read_flash_crc *req;
struct be_mcc_wrb *wrb;
@@ -2571,6 +2573,567 @@ err:
return status;
 }
 
+static char flash_cookie[2][16] = {"*** SE FLAS", "H DIRECTORY *** "};
+
+static bool phy_flashing_required(struct be_adapter *adapter)
+{
+   return (adapter->phy.phy_type == PHY_TYPE_TN_8022 &&
+   adapter->phy.interface_type == PHY_TYPE_BASET_10GB);
+}
+
+static bool is_comp_in_ufi(struct be_adapter *adapter,
+  struct flash_section_info *fsec, int type)
+{
+   int i = 0, img_type = 0;
+   struct flash_section_info_g2 *fsec_g2 = NULL;
+
+   if (BE2_chip(adapter))
+   fsec_g2 = (struct flash_section_info_g2 *)fsec;
+
+   for (i = 0; i < MAX_FLASH_COMP; i++) {
+   if (fsec_g2)
+   img_type = le32_to_cpu(fsec_g2->fsec_entry[i].type);
+   else
+   img_type = le32_to_cpu(fsec->fsec_entry[i].type);
+
+   if (img_type == type)
+   return true;
+   }
+   return false;
+}
+
+static struct flash_section_info *get_fsec_info(struct be_adapter *adapter,
+   int header_size,
+   const struct firmware *fw)
+{
+   struct flash_section_info *fsec = NULL;
+   const u8 *p = fw->data;
+
+   p += header_size;
+   while (p < (fw->data + fw->size)) {
+   fsec = (struct flash_section_info *)p;
+   if (!memcmp(flash_cookie, fsec->cookie, sizeof(flash_cookie)))
+   return fsec;
+   p += 32;
+   }
+   return NULL;
+}
+
+static int be_check_flash_crc(struct be_adapter *adapter, const u8 *p,
+ u32 img_offset, u32 img_size, int hdr_size,
+ u16 img_optype, bool *crc_match)
+{
+   u32 crc_offset;
+   int status;
+   u8 crc[4];
+
+   status = be_cmd_get_flash_crc(adapter, crc, img_optype, img_offset,
+ img_size - 4);
+   if (status)
+   return status;
+

[net-next PATCH 10/10] be2net: bump up the driver version to 11.0.0.0

2015-12-24 Thread Sathya Perla
From: Suresh Reddy 

Signed-off-by: Suresh Reddy 
Signed-off-by: Sathya Perla 
---
 drivers/net/ethernet/emulex/benet/be.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/emulex/benet/be.h 
b/drivers/net/ethernet/emulex/benet/be.h
index 8b8212f..22bf7af 100644
--- a/drivers/net/ethernet/emulex/benet/be.h
+++ b/drivers/net/ethernet/emulex/benet/be.h
@@ -37,7 +37,7 @@
 #include "be_hw.h"
 #include "be_roce.h"
 
-#define DRV_VER"10.6.0.3"
+#define DRV_VER"11.0.0.0"
 #define DRV_NAME   "be2net"
 #define BE_NAME"Emulex BladeEngine2"
 #define BE3_NAME   "Emulex BladeEngine3"
-- 
2.4.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[net-next PATCH 01/10] be2net: fix VF link state transition from disabled to auto

2015-12-24 Thread Sathya Perla
From: Suresh Reddy 

The VF link state setting transition from "disable" to "auto" does not work
due to a bug in SET_LOGICAL_LINK_CONFIG_V1 cmd in FW. This issue could not
be fixed in FW due to some backward compatibility issues it causes with
some released drivers. The issue has been fixed by introducing a new
version (v2) of the cmd from 10.6 FW onwards. In v2, to set the VF link
state to auto, both PLINK_ENABLE and PLINK_TRACK bits have to be set to 1.

The VF link state setting feature now works on Lancer chips too from
FW ver 10.6.315.0 onwards.

Signed-off-by: Suresh Reddy 
Signed-off-by: Sathya Perla 
---
 drivers/net/ethernet/emulex/benet/be_cmds.c | 35 +
 drivers/net/ethernet/emulex/benet/be_cmds.h |  3 ++-
 2 files changed, 28 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c 
b/drivers/net/ethernet/emulex/benet/be_cmds.c
index 1795c93..8083eca 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.c
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.c
@@ -4260,16 +4260,13 @@ err:
return status;
 }
 
-int be_cmd_set_logical_link_config(struct be_adapter *adapter,
-  int link_state, u8 domain)
+int __be_cmd_set_logical_link_config(struct be_adapter *adapter,
+int link_state, int version, u8 domain)
 {
struct be_mcc_wrb *wrb;
struct be_cmd_req_set_ll_link *req;
int status;
 
-   if (BEx_chip(adapter) || lancer_chip(adapter))
-   return -EOPNOTSUPP;
-
spin_lock_bh(&adapter->mcc_lock);
 
wrb = wrb_from_mccq(adapter);
@@ -4284,14 +4281,15 @@ int be_cmd_set_logical_link_config(struct be_adapter 
*adapter,
   OPCODE_COMMON_SET_LOGICAL_LINK_CONFIG,
   sizeof(*req), wrb, NULL);
 
-   req->hdr.version = 1;
+   req->hdr.version = version;
req->hdr.domain = domain;
 
-   if (link_state == IFLA_VF_LINK_STATE_ENABLE)
-   req->link_config |= 1;
+   if (link_state == IFLA_VF_LINK_STATE_ENABLE ||
+   link_state == IFLA_VF_LINK_STATE_AUTO)
+   req->link_config |= PLINK_ENABLE;
 
if (link_state == IFLA_VF_LINK_STATE_AUTO)
-   req->link_config |= 1 << PLINK_TRACK_SHIFT;
+   req->link_config |= PLINK_TRACK;
 
status = be_mcc_notify_wait(adapter);
 err:
@@ -4299,6 +4297,25 @@ err:
return status;
 }
 
+int be_cmd_set_logical_link_config(struct be_adapter *adapter,
+  int link_state, u8 domain)
+{
+   int status;
+
+   if (BEx_chip(adapter))
+   return -EOPNOTSUPP;
+
+   status = __be_cmd_set_logical_link_config(adapter, link_state,
+ 2, domain);
+
+   /* Version 2 of the command will not be recognized by older FW.
+* On such a failure issue version 1 of the command.
+*/
+   if (base_status(status) == MCC_STATUS_ILLEGAL_REQUEST)
+   status = __be_cmd_set_logical_link_config(adapter, link_state,
+ 1, domain);
+   return status;
+}
 int be_roce_mcc_cmd(void *netdev_handle, void *wrb_payload,
int wrb_payload_size, u16 *cmd_status, u16 *ext_status)
 {
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.h 
b/drivers/net/ethernet/emulex/benet/be_cmds.h
index 91155ea..9690c3a 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.h
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.h
@@ -2246,7 +2246,8 @@ struct be_cmd_resp_get_iface_list {
 };
 
 /*** Set logical link /
-#define PLINK_TRACK_SHIFT  8
+#define PLINK_ENABLEBIT(0)
+#define PLINK_TRACK BIT(8)
 struct be_cmd_req_set_ll_link {
struct be_cmd_req_hdr hdr;
u32 link_config; /* Bit 0: UP_DOWN, Bit 9: PLINK */
-- 
2.4.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[net-next PATCH 05/10] be2net: log digital signature errors while flashing FW image

2015-12-24 Thread Sathya Perla
From: Suresh Reddy 

>From FW version 11.0 onwards, the FW supports a new "secure mode" feature
(based on a jumper setting on the adapter.) In this mode, the FW image when
flashed is authenticated with a digital signature. This patch logs
appropriate error messages and return a status to ethtool when errors
relating to FW image authentication occur.

Signed-off-by: Suresh Reddy 
Signed-off-by: Sathya Perla 
---
 drivers/net/ethernet/emulex/benet/be_cmds.c | 11 +++
 drivers/net/ethernet/emulex/benet/be_cmds.h |  4 +++-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c 
b/drivers/net/ethernet/emulex/benet/be_cmds.c
index da3b398..6fb7873 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.c
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.c
@@ -2959,6 +2959,17 @@ flash:
} else if (status) {
dev_err(dev, "Flashing section type 0x%x failed\n",
img_type);
+   if (addl_status(status) ==
+   MCC_ADDL_STATUS_MISSING_SIGNATURE) {
+   dev_err(dev,
+   "Digital signature missing in FW\n");
+   return -EINVAL;
+   } else if (addl_status(status) ==
+  MCC_ADDL_STATUS_INVALID_SIGNATURE) {
+   dev_err(dev,
+   "Invalid digital signature in FW\n");
+   return -EINVAL;
+   }
return -EFAULT;
}
}
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.h 
b/drivers/net/ethernet/emulex/benet/be_cmds.h
index 4b0ca99..16415ca 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.h
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.h
@@ -66,7 +66,9 @@ enum mcc_addl_status {
MCC_ADDL_STATUS_INSUFFICIENT_RESOURCES = 0x16,
MCC_ADDL_STATUS_FLASH_IMAGE_CRC_MISMATCH = 0x4d,
MCC_ADDL_STATUS_TOO_MANY_INTERFACES = 0x4a,
-   MCC_ADDL_STATUS_INSUFFICIENT_VLANS = 0xab
+   MCC_ADDL_STATUS_INSUFFICIENT_VLANS = 0xab,
+   MCC_ADDL_STATUS_INVALID_SIGNATURE = 0x56,
+   MCC_ADDL_STATUS_MISSING_SIGNATURE = 0x57
 };
 
 #define CQE_BASE_STATUS_MASK   0x
-- 
2.4.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[net-next PATCH 08/10] be2net: fix port-res desc query of GET_PROFILE_CONFIG FW cmd

2015-12-24 Thread Sathya Perla
From: Suresh Reddy 

Commit 72ef3a88fa8e ("be2net: set pci_func_num while issuing
GET_PROFILE_CONFIG cmd") passed a specific pf_num while issuing a
GET_PROFILE_CONFIG cmd as FW returns descriptors for all functions when
pf_num is zero. But, when pf_num is set to a non-zero value, FW does not
return the Port resource descriptor.
This patch fixes this by setting pf_num to 0 while issuing the query cmd
and adds code to pick the correct NIC resource descriptor from the list of
descriptors returned by FW.

Fixes: 72ef3a88fa8e ("be2net: set pci_func_num while issuing
 GET_PROFILE_CONFIG cmd")
Signed-off-by: Suresh Reddy 

Signed-off-by: Sathya Perla 
---
 drivers/net/ethernet/emulex/benet/be.h  |  4 +-
 drivers/net/ethernet/emulex/benet/be_cmds.c | 85 -
 drivers/net/ethernet/emulex/benet/be_cmds.h | 11 +---
 drivers/net/ethernet/emulex/benet/be_main.c | 16 --
 4 files changed, 63 insertions(+), 53 deletions(-)

diff --git a/drivers/net/ethernet/emulex/benet/be.h 
b/drivers/net/ethernet/emulex/benet/be.h
index 0af32f1..66988f4 100644
--- a/drivers/net/ethernet/emulex/benet/be.h
+++ b/drivers/net/ethernet/emulex/benet/be.h
@@ -570,6 +570,8 @@ struct be_adapter {
struct be_resources pool_res;   /* resources available for the port */
struct be_resources res;/* resources available for the func */
u16 num_vfs;/* Number of VFs provisioned by PF */
+   u8 pf_num;  /* Numbering used by FW, starts at 0 */
+   u8 vf_num;  /* Numbering used by FW, starts at 1 */
u8 virtfn;
struct be_vf_cfg *vf_cfg;
bool be3_native;
@@ -587,8 +589,6 @@ struct be_adapter {
u32 msg_enable;
int be_get_temp_freq;
struct be_hwmon hwmon_info;
-   u8 pf_number;
-   u8 pci_func_num;
struct rss_info rss_info;
/* Filters for packets that need to be sent to BMC */
u32 bmc_filt_mask;
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c 
b/drivers/net/ethernet/emulex/benet/be_cmds.c
index 8de876b..3ffe0c7 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.c
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.c
@@ -3465,7 +3465,6 @@ int be_cmd_get_cntl_attributes(struct be_adapter *adapter)
if (!status) {
attribs = attribs_cmd.va + sizeof(struct be_cmd_resp_hdr);
adapter->hba_port_num = attribs->hba_attribs.phy_port;
-   adapter->pci_func_num = attribs->pci_func_num;
serial_num = attribs->hba_attribs.controller_serial_number;
for (i = 0; i < CNTL_SERIAL_NUM_WORDS; i++)
adapter->serial_num[i] = le32_to_cpu(serial_num[i]) &
@@ -4148,14 +4147,16 @@ int be_cmd_query_port_name(struct be_adapter *adapter)
return status;
 }
 
-/* Descriptor type */
-enum {
-   FUNC_DESC = 1,
-   VFT_DESC = 2
-};
-
+/* When more than 1 NIC descriptor is present in the descriptor list,
+ * the caller must specify the pf_num to obtain the NIC descriptor
+ * corresponding to its pci function.
+ * get_vft must be true when the caller wants the VF-template desc of the
+ * PF-pool.
+ * The pf_num should be set to PF_NUM_IGNORE when the caller knows
+ * that only it's NIC descriptor is present in the descriptor list.
+ */
 static struct be_nic_res_desc *be_get_nic_desc(u8 *buf, u32 desc_count,
-  int desc_type)
+  bool get_vft, u8 pf_num)
 {
struct be_res_desc_hdr *hdr = (struct be_res_desc_hdr *)buf;
struct be_nic_res_desc *nic;
@@ -4165,40 +4166,42 @@ static struct be_nic_res_desc *be_get_nic_desc(u8 *buf, 
u32 desc_count,
if (hdr->desc_type == NIC_RESOURCE_DESC_TYPE_V0 ||
hdr->desc_type == NIC_RESOURCE_DESC_TYPE_V1) {
nic = (struct be_nic_res_desc *)hdr;
-   if (desc_type == FUNC_DESC ||
-   (desc_type == VFT_DESC &&
-nic->flags & (1 << VFT_SHIFT)))
+
+   if ((pf_num == PF_NUM_IGNORE ||
+nic->pf_num == pf_num) &&
+   (!get_vft || nic->flags & BIT(VFT_SHIFT)))
return nic;
}
-
hdr->desc_len = hdr->desc_len ? : RESOURCE_DESC_SIZE_V0;
hdr = (void *)hdr + hdr->desc_len;
}
return NULL;
 }
 
-static struct be_nic_res_desc *be_get_vft_desc(u8 *buf, u32 desc_count)
+static struct be_nic_res_desc *be_get_vft_desc(u8 *buf, u32 desc_count,
+  u8 pf_num)
 {
-   return be_get_nic_desc(buf, desc_count, VFT_DESC);
+   return be_get_nic_desc(buf, desc_count, true, pf_num);
 }
 
-sta

[net-next PATCH 03/10] be2net: cleanup FW flash image related macro defines

2015-12-24 Thread Sathya Perla
From: Suresh Reddy 

Many constant definitions relating to the FW-image layout
(such as section offset values) were defined in decimal format rather than
hexa-decimal. This makes this part of the code un-readable. Also some
defines related to BE2 are labeld "g2" and defines related to BE3 are
labeled "g3".  This patch cleans up all of this to make this code more
readable.

Signed-off-by: Suresh Reddy 
Signed-off-by: Sathya Perla 
---
 drivers/net/ethernet/emulex/benet/be_cmds.h | 141 
 drivers/net/ethernet/emulex/benet/be_main.c |  78 +++
 2 files changed, 118 insertions(+), 101 deletions(-)

diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.h 
b/drivers/net/ethernet/emulex/benet/be_cmds.h
index 9690c3a..8c6b606 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.h
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.h
@@ -1207,68 +1207,85 @@ struct be_cmd_resp_get_beacon_state {
 /* Flashrom related descriptors */
 #define MAX_FLASH_COMP 32
 
-#define OPTYPE_ISCSI_ACTIVE0
-#define OPTYPE_REDBOOT 1
-#define OPTYPE_BIOS2
-#define OPTYPE_PXE_BIOS3
-#define OPTYPE_OFFSET_SPECIFIED7
-#define OPTYPE_FCOE_BIOS   8
-#define OPTYPE_ISCSI_BACKUP9
-#define OPTYPE_FCOE_FW_ACTIVE  10
-#define OPTYPE_FCOE_FW_BACKUP  11
-#define OPTYPE_NCSI_FW 13
-#define OPTYPE_REDBOOT_DIR 18
-#define OPTYPE_REDBOOT_CONFIG  19
-#define OPTYPE_SH_PHY_FW   21
-#define OPTYPE_FLASHISM_JUMPVECTOR 22
-#define OPTYPE_UFI_DIR 23
-#define OPTYPE_PHY_FW  99
-
-#define FLASH_BIOS_IMAGE_MAX_SIZE_g2   262144  /* Max OPTION ROM image sz */
-#define FLASH_REDBOOT_IMAGE_MAX_SIZE_g2262144  /* Max Redboot image sz 
   */
-#define FLASH_IMAGE_MAX_SIZE_g21310720 /* Max firmware image 
size */
-
-#define FLASH_NCSI_IMAGE_MAX_SIZE_g3   262144
-#define FLASH_PHY_FW_IMAGE_MAX_SIZE_g3 262144
-#define FLASH_BIOS_IMAGE_MAX_SIZE_g3   524288  /* Max OPTION ROM image sz */
-#define FLASH_REDBOOT_IMAGE_MAX_SIZE_g31048576 /* Max Redboot image sz 
   */
-#define FLASH_IMAGE_MAX_SIZE_g32097152 /* Max firmware image 
size */
-
-/* Offsets for components on Flash. */
-#define FLASH_REDBOOT_START_g2 0
-#define FLASH_FCoE_BIOS_START_g2   524288
-#define FLASH_iSCSI_PRIMARY_IMAGE_START_g2 1048576
-#define FLASH_iSCSI_BACKUP_IMAGE_START_g2  2359296
-#define FLASH_FCoE_PRIMARY_IMAGE_START_g2  3670016
-#define FLASH_FCoE_BACKUP_IMAGE_START_g2   4980736
-#define FLASH_iSCSI_BIOS_START_g2  7340032
-#define FLASH_PXE_BIOS_START_g27864320
-
-#define FLASH_REDBOOT_START_g3 262144
-#define FLASH_PHY_FW_START_g3  1310720
-#define FLASH_iSCSI_PRIMARY_IMAGE_START_g3 2097152
-#define FLASH_iSCSI_BACKUP_IMAGE_START_g3  4194304
-#define FLASH_FCoE_PRIMARY_IMAGE_START_g3  6291456
-#define FLASH_FCoE_BACKUP_IMAGE_START_g3   8388608
-#define FLASH_iSCSI_BIOS_START_g3  12582912
-#define FLASH_PXE_BIOS_START_g313107200
-#define FLASH_FCoE_BIOS_START_g3   13631488
-#define FLASH_NCSI_START_g315990784
-
-#define IMAGE_NCSI 16
-#define IMAGE_OPTION_ROM_PXE   32
-#define IMAGE_OPTION_ROM_FCoE  33
-#define IMAGE_OPTION_ROM_ISCSI 34
-#define IMAGE_FLASHISM_JUMPVECTOR  48
-#define IMAGE_FIRMWARE_iSCSI   160
-#define IMAGE_FIRMWARE_FCoE162
-#define IMAGE_FIRMWARE_BACKUP_iSCSI176
-#define IMAGE_FIRMWARE_BACKUP_FCoE 178
-#define IMAGE_FIRMWARE_PHY 192
-#define IMAGE_REDBOOT_DIR  208
-#define IMAGE_REDBOOT_CONFIG   209
-#define IMAGE_UFI_DIR  210
-#define IMAGE_BOOT_CODE224
+/* Optypes of each component in the UFI */
+enum {
+   OPTYPE_ISCSI_ACTIVE = 0,
+   OPTYPE_REDBOOT = 1,
+   OPTYPE_BIOS = 2,
+   OPTYPE_PXE_BIOS = 3,
+   OPTYPE_OFFSET_SPECIFIED = 7,
+   OPTYPE_FCOE_BIOS = 8,
+   OPTYPE_ISCSI_BACKUP = 9,
+   OPTYPE_FCOE_FW_ACTIVE = 10,
+   OPTYPE_FCOE_FW_BACKUP = 11,
+   OPTYPE_NCSI_FW = 13,
+   OPTYPE_REDBOOT_DIR = 18,
+   OPTYPE_REDBOOT_CONFIG = 19,
+   OPTYPE_SH_PHY_FW = 21,
+   OPTYPE_FLASHISM_JUMPVECTOR = 22,
+   OPTYPE_UFI_DIR = 23,
+   OPTYPE_PHY_FW = 99
+};
+
+/* Maximum sizes of components in BE2 FW UFI */
+enum {
+   BE2_BIOS_COMP_MAX_SIZE = 0x4,
+   BE2_REDBOOT_COMP_MAX_SIZE = 0x4,
+   BE2_COMP_MAX_SIZE = 0x14
+};
+
+/* Maximum sizes of components in BE3 FW UFI */
+enum {
+   BE3_NCSI_COMP_MAX_SIZE = 0x4,
+   BE3_PHY_FW_COMP_MAX_SIZE = 0x4,
+   BE3_BIOS_COMP_MAX_SIZE = 0x8,
+   BE3_REDBOOT_COMP

Re: [PATCH net] be2net: check properly status in lancer_cmd_get_file_len()

2015-11-16 Thread Sathya Perla
On Fri, Nov 13, 2015 at 3:22 PM, Ivan Vecera  wrote:
> The lancer_cmd_get_file_len() calls lancer_cmd_read_object() to get
> the current size of registers for ethtool registers dump. The size
> is stored in data_read but only when the returned status is 0 otherwise
> it is uninitialized thus random.
>
> Signed-off-by: Ivan Vecera 
> ---
>  drivers/net/ethernet/emulex/benet/be_ethtool.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/net/ethernet/emulex/benet/be_ethtool.c 
> b/drivers/net/ethernet/emulex/benet/be_ethtool.c
> index f4cb8e4..26b6192 100644
> --- a/drivers/net/ethernet/emulex/benet/be_ethtool.c
> +++ b/drivers/net/ethernet/emulex/benet/be_ethtool.c
> @@ -248,6 +248,8 @@ static u32 lancer_cmd_get_file_len(struct be_adapter 
> *adapter, u8 *file_name)
> status = lancer_cmd_read_object(adapter, &data_len_cmd, 0, 0,
> file_name, &data_read, &eof,
> &addn_status);
> +   if (status)
> +   return 0;
>
> return data_read;

Ivan, unless I'm missing something...I see that "data_read" is
initialized to 0 in this routine. So, this routine will return 0 when
lancer_cmd_read_object() returns a non-zero status.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH net-next 1/2] be2net: remove unused local rsstable array

2015-11-16 Thread Sathya Perla
On Fri, Nov 13, 2015 at 4:06 PM, Ivan Vecera  wrote:
>
> Remove rsstable array and its initialization from be_set_rss_hash_opts().
> The array became unused after "e255787 be2net: Support for configurable
> RSS hash key". The initial RSS table is now filled and stored for later
> usage during Rx queue creation.
>
> Signed-off-by: Ivan Vecera 

Acked-by: Sathya Perla 
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 5/5] be2net: remove vlan promisc capability from VF's profile descriptors

2015-10-12 Thread Sathya Perla
From: Kalesh AP 

The commit 435452aa8847 ("Prevent VFs from enabling VLAN promiscuous mode")
fixed the PF driver to not include the VLAN promisc capability while
provisioning the interface for a VF. But the fix did not remove this
capability from the profile descriptor of the VF. This causes the VF
driver to request this capability when it tries to create it's interface
at probe time.  This could potentailly cause the VF probe to fail if the
FW enforces strict checking of the flags based on what was provisoned
by the PF.  This strict checking is not being done by FW currently but
will be fixed in a future version. This patch fixes this issue by updating
the VF's profile descriptor so that they match the interface capability
flags provisioned by the PF.

Fixes: 435452aa8847 ("Prevent VFs from enabling VLAN promiscuous mode")
Signed-off-by: Kalesh AP 
Signed-off-by: Sathya Perla 
---
 drivers/net/ethernet/emulex/benet/be_cmds.c | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c 
b/drivers/net/ethernet/emulex/benet/be_cmds.c
index 790284d..1795c93 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.c
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.c
@@ -1987,6 +1987,8 @@ int be_cmd_rx_filter(struct be_adapter *adapter, u32 
flags, u32 value)
 be_if_cap_flags(adapter));
}
flags &= be_if_cap_flags(adapter);
+   if (!flags)
+   return -ENOTSUPP;
 
return __be_cmd_rx_filter(adapter, flags, value);
 }
@@ -3932,12 +3934,16 @@ static void be_fill_vf_res_template(struct be_adapter 
*adapter,
vf_if_cap_flags &= ~(BE_IF_FLAGS_RSS |
 BE_IF_FLAGS_DEFQ_RSS);
}
-
-   nic_vft->cap_flags = cpu_to_le32(vf_if_cap_flags);
} else {
num_vf_qs = 1;
}
 
+   if (res_mod.vf_if_cap_flags & BE_IF_FLAGS_VLAN_PROMISCUOUS) {
+   nic_vft->flags |= BIT(IF_CAPS_FLAGS_VALID_SHIFT);
+   vf_if_cap_flags &= ~BE_IF_FLAGS_VLAN_PROMISCUOUS;
+   }
+
+   nic_vft->cap_flags = cpu_to_le32(vf_if_cap_flags);
nic_vft->rq_count = cpu_to_le16(num_vf_qs);
nic_vft->txq_count = cpu_to_le16(num_vf_qs);
nic_vft->rssq_count = cpu_to_le16(num_vf_qs);
-- 
2.4.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/5] be2net: pad skb to meet minimum TX pkt size in BE3

2015-10-12 Thread Sathya Perla
From: Suresh Reddy 

On BE3 chips in SRIOV configs, the TX path stalls when a packet less
than 32B is received from the host. A workaround to pad such packets
already exists for the Skyhawk and Lancer chips. Use the same workaround
for BE3 chips too.

Signed-off-by: Suresh Reddy 
Signed-off-by: Sathya Perla 
---
 drivers/net/ethernet/emulex/benet/be_main.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/emulex/benet/be_main.c 
b/drivers/net/ethernet/emulex/benet/be_main.c
index 86eed47..821e014 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -1123,11 +1123,12 @@ static struct sk_buff *be_xmit_workarounds(struct 
be_adapter *adapter,
   struct sk_buff *skb,
   struct be_wrb_params *wrb_params)
 {
-   /* Lancer, SH-R ASICs have a bug wherein Packets that are 32 bytes or
-* less may cause a transmit stall on that port. So the work-around is
-* to pad short packets (<= 32 bytes) to a 36-byte length.
+   /* Lancer, SH and BE3 in SRIOV mode have a bug wherein
+* packets that are 32b or less may cause a transmit stall
+* on that port. The workaround is to pad such packets
+* (len <= 32 bytes) to a minimum length of 36b.
 */
-   if (unlikely(!BEx_chip(adapter) && skb->len <= 32)) {
+   if (skb->len <= 32) {
if (skb_put_padto(skb, 36))
return NULL;
}
-- 
2.4.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/5] be2net: fix BE3-R FW download compatibility check

2015-10-12 Thread Sathya Perla
From: Kalesh AP 

In the BE3 FW image, unlike Skyhawk's, the "asic_type_rev" field doesn't
track the asic_rev of chip it is compatible with. When asic_type_rev
is 0 the image is compatible only with pre-BE3-R chips (asic_rev < 0x10).
Fix the current compatibility check to take care of this.
We hit this issue when we try to flash old BE3 images (used prior to the
release of BE3-R) on pre-BE3-R adapters.

Fixes: a6e6ff6eee12f3e ("be2net: simplify UFI compatibility checking")
Signed-off-by: Kalesh AP 
Signed-off-by: Sathya Perla 
---
 drivers/net/ethernet/emulex/benet/be_main.c | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/emulex/benet/be_main.c 
b/drivers/net/ethernet/emulex/benet/be_main.c
index 7bf51a1..86eed47 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -4999,7 +4999,15 @@ static bool be_check_ufi_compatibility(struct be_adapter 
*adapter,
return false;
}
 
-   return (fhdr->asic_type_rev >= adapter->asic_rev);
+   /* In BE3 FW images the "asic_type_rev" field doesn't track the
+* asic_rev of the chips it is compatible with.
+* When asic_type_rev is 0 the image is compatible only with
+* pre-BE3-R chips (asic_rev < 0x10)
+*/
+   if (BEx_chip(adapter) && fhdr->asic_type_rev == 0)
+   return adapter->asic_rev < 0x10;
+   else
+   return (fhdr->asic_type_rev >= adapter->asic_rev);
 }
 
 static int be_fw_download(struct be_adapter *adapter, const struct firmware* 
fw)
-- 
2.4.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/5] be2net: set pci_func_num while issuing GET_PROFILE_CONFIG cmd

2015-10-12 Thread Sathya Perla
From: Somnath Kotur 

The FW requires the pf_num field in the cmd hdr to be set for it to return
the specific function's descriptors in the GET_PROFILE_CONFIG cmd. If not
set, the FW returns the descriptors of all the functions on the device.
If the first descriptor is not what is being queried for, the driver will
read wrong data. This patch fixes this issue by using the GET_CNTL_ATTRIB
cmd to query the real pci_func_num of a function and then uses it in the
GET_PROFILE_CONFIG cmd.

Signed-off-by: Somnath Kotur 
Signed-off-by: Sathya Perla 
---
 drivers/net/ethernet/emulex/benet/be.h  |  1 +
 drivers/net/ethernet/emulex/benet/be_cmds.c | 14 +++---
 drivers/net/ethernet/emulex/benet/be_cmds.h | 10 --
 drivers/net/ethernet/emulex/benet/be_main.c |  9 +
 4 files changed, 25 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ethernet/emulex/benet/be.h 
b/drivers/net/ethernet/emulex/benet/be.h
index 8215409..d463563 100644
--- a/drivers/net/ethernet/emulex/benet/be.h
+++ b/drivers/net/ethernet/emulex/benet/be.h
@@ -592,6 +592,7 @@ struct be_adapter {
int be_get_temp_freq;
struct be_hwmon hwmon_info;
u8 pf_number;
+   u8 pci_func_num;
struct rss_info rss_info;
/* Filters for packets that need to be sent to BMC */
u32 bmc_filt_mask;
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c 
b/drivers/net/ethernet/emulex/benet/be_cmds.c
index 9dc5ce1..790284d 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.c
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.c
@@ -2890,6 +2890,7 @@ int be_cmd_get_cntl_attributes(struct be_adapter *adapter)
if (!status) {
attribs = attribs_cmd.va + sizeof(struct be_cmd_resp_hdr);
adapter->hba_port_num = attribs->hba_attribs.phy_port;
+   adapter->pci_func_num = attribs->pci_func_num;
serial_num = attribs->hba_attribs.controller_serial_number;
for (i = 0; i < CNTL_SERIAL_NUM_WORDS; i++)
adapter->serial_num[i] = le32_to_cpu(serial_num[i]) &
@@ -3712,7 +3713,6 @@ int be_cmd_get_func_config(struct be_adapter *adapter, 
struct be_resources *res)
status = -EINVAL;
goto err;
}
-
adapter->pf_number = desc->pf_num;
be_copy_nic_desc(res, desc);
}
@@ -3724,7 +3724,10 @@ err:
return status;
 }
 
-/* Will use MBOX only if MCCQ has not been created */
+/* Will use MBOX only if MCCQ has not been created
+ * non-zero domain => a PF is querying this on behalf of a VF
+ * zero domain => a PF or a VF is querying this for itself
+ */
 int be_cmd_get_profile_config(struct be_adapter *adapter,
  struct be_resources *res, u8 query, u8 domain)
 {
@@ -3751,10 +3754,15 @@ int be_cmd_get_profile_config(struct be_adapter 
*adapter,
   OPCODE_COMMON_GET_PROFILE_CONFIG,
   cmd.size, &wrb, &cmd);
 
-   req->hdr.domain = domain;
if (!lancer_chip(adapter))
req->hdr.version = 1;
req->type = ACTIVE_PROFILE_TYPE;
+   /* When a function is querying profile information relating to
+* itself hdr.pf_number must be set to it's pci_func_num + 1
+*/
+   req->hdr.domain = domain;
+   if (domain == 0)
+   req->hdr.pf_num = adapter->pci_func_num + 1;
 
/* When QUERY_MODIFIABLE_FIELDS_TYPE bit is set, cmd returns the
 * descriptors with all bits set to "1" for the fields which can be
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.h 
b/drivers/net/ethernet/emulex/benet/be_cmds.h
index 7d178bd..91155ea 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.h
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.h
@@ -289,7 +289,9 @@ struct be_cmd_req_hdr {
u32 timeout;/* dword 1 */
u32 request_length; /* dword 2 */
u8 version; /* dword 3 */
-   u8 rsvd[3]; /* dword 3 */
+   u8 rsvd1;   /* dword 3 */
+   u8 pf_num;  /* dword 3 */
+   u8 rsvd2;   /* dword 3 */
 };
 
 #define RESP_HDR_INFO_OPCODE_SHIFT 0   /* bits 0 - 7 */
@@ -1652,7 +1654,11 @@ struct mgmt_hba_attribs {
 
 struct mgmt_controller_attrib {
struct mgmt_hba_attribs hba_attribs;
-   u32 rsvd0[10];
+   u32 rsvd0[2];
+   u16 rsvd1;
+   u8 pci_func_num;
+   u8 rsvd2;
+   u32 rsvd3[7];
 } __packed;
 
 struct be_cmd_req_cntl_attribs {
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c 
b/drivers/net/ethernet/emulex/benet/be_main.c
index 821e014..eb48a97 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -4206,10 +4206,6 @@ static int be_get_config(struct be_adapter *adapter)
int status, l

[PATCH 0/5] be2net: patch set

2015-10-12 Thread Sathya Perla
Patch 1 fixes a FW image compatibility check in the driver that
prevents certain FW images from being flashed on BE3 (not BE3-R)
adapters.

Patch 2 fixes a spin_lock not being released in a failure case in
be_cmd_notify_wait().

Patch 3 includes a workaround to pad packets that are only 32b long or less
to be applicabe to BE3 too. This workaround was currently applied only to
Skyhawk and Lancer chips. Such packets are causing BE3's TX path to stall
on a SR-IOV config.

Patch 4 fixes the be_cmd_get_profile_config() routine to set the pf_num
field in the cmd request. The FW requires this field to be set for it to
return the specific function's descriptors. If not set, the FW returns
the descriptors of all the functions on the device. If the first descriptor
is not what is being queried for, the driver will read wrong data.
This patch fixes this issue by using the GET_CNTL_ATTRIB cmd to query the
real pci_func_num of a function and then uses it in the GET_PROFILE_CONFIG
cmd.

Patch 5 completes an earlier fix that removed the vlan promisc capability
for VFs. The earlier fix did not update the removal of this capability from
the profile descriptor of the VF. This causes the VF driver to request this
capability when it tries to create it's interface at probe time. This could
potentailly cause the VF probe to fail if the FW enforces strict checking of
the flags based on what was provisoned by the PF.  This strict checking is
not being done by FW currently but will be fixed in a future version. This
patch fixes this issue by updating the VF's profile descriptor so that they
match the interface capability flags provisioned by the PF.

Pls consider adding these patches to the net tree. Thanks!

Kalesh AP (2):
  be2net: fix BE3-R FW download compatibility check
  be2net: remove vlan promisc capability from VF's profile descriptors

Somnath Kotur (1):
  be2net: set pci_func_num while issuing GET_PROFILE_CONFIG cmd

Suresh Reddy (2):
  be2net: release mcc-lock in a failure case in be_cmd_notify_wait()
  be2net: pad skb to meet minimum TX pkt size in BE3

 drivers/net/ethernet/emulex/benet/be.h  |  1 +
 drivers/net/ethernet/emulex/benet/be_cmds.c | 31 ++---
 drivers/net/ethernet/emulex/benet/be_cmds.h | 10 --
 drivers/net/ethernet/emulex/benet/be_main.c | 28 +-
 4 files changed, 52 insertions(+), 18 deletions(-)

-- 
2.4.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/5] be2net: release mcc-lock in a failure case in be_cmd_notify_wait()

2015-10-12 Thread Sathya Perla
From: Suresh Reddy 

The mcc/mbox lock is not being released when be_cmd_copy() returns
an error.

Signed-off-by: Suresh Reddy 
Signed-off-by: Sathya Perla 
---
 drivers/net/ethernet/emulex/benet/be_cmds.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c 
b/drivers/net/ethernet/emulex/benet/be_cmds.c
index eb32391..9dc5ce1 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.c
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.c
@@ -851,8 +851,10 @@ static int be_cmd_notify_wait(struct be_adapter *adapter,
return status;
 
dest_wrb = be_cmd_copy(adapter, wrb);
-   if (!dest_wrb)
-   return -EBUSY;
+   if (!dest_wrb) {
+   status = -EBUSY;
+   goto unlock;
+   }
 
if (use_mcc(adapter))
status = be_mcc_notify_wait(adapter);
@@ -862,6 +864,7 @@ static int be_cmd_notify_wait(struct be_adapter *adapter,
if (!status)
memcpy(wrb, dest_wrb, sizeof(*wrb));
 
+unlock:
be_cmd_unlock(adapter);
return status;
 }
-- 
2.4.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH net 4/5] be2net: allow offloading with the same port for IPv4 and IPv6

2015-09-17 Thread Sathya Perla
On Thu, Sep 17, 2015 at 7:41 PM, Jiri Benc  wrote:
> The callback for adding vxlan port can be called with the same port for both
> IPv4 and IPv6. Do not disable the offloading if this occurs.
>
> Signed-off-by: Jiri Benc 
> ---
>  drivers/net/ethernet/emulex/benet/be.h  |  1 +
>  drivers/net/ethernet/emulex/benet/be_main.c | 10 ++
>  2 files changed, 11 insertions(+)

Acked-by: Sathya Perla 

Thanks!
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] be2net: Revert "make the RX_FILTER command asynchronous" commit

2015-09-03 Thread Sathya Perla
The be_cmd_rx_filter() routine sends a non-embedded cmd to the FW and used
a pre-allocated dma memory to hold the cmd payload. This worked fine when
this cmd was synchronous. This cmd was changed to asynchronous mode by the
commit 8af65c2f4("make the RX_FILTER command asynchronous"). So now when
there are two quick invocations of this cmd, the 2nd request may end up
overwriting the first request, causing FW cmd corruption.

This patch reverts the offending commit and hence fixes the regression.

Fixes: 8af65c2f4("be2net: make the RX_FILTER command asynchronous")
Signed-off-by: Sathya Perla 
---
David, the culprit commit that this patch is reverting was applied on
the net-next tree. As net-next tree is closed now, I'm assuming you've
merged the net-next tree onto the net tree. Thanks!

 drivers/net/ethernet/emulex/benet/be_cmds.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c 
b/drivers/net/ethernet/emulex/benet/be_cmds.c
index 3be1fbd..eb32391 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.c
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.c
@@ -1968,7 +1968,7 @@ static int __be_cmd_rx_filter(struct be_adapter *adapter, 
u32 flags, u32 value)
memcpy(req->mcast_mac[i++].byte, ha->addr, ETH_ALEN);
}
 
-   status = be_mcc_notify(adapter);
+   status = be_mcc_notify_wait(adapter);
 err:
spin_unlock_bh(&adapter->mcc_lock);
return status;
-- 
2.4.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/3] be2net: protect eqo->affinity_mask from getting freed twice

2015-08-05 Thread Sathya Perla
From: Kalesh AP 

There are paths in the driver such as an unrecoverable error (UE) detection
followed by a driver unload wherein be_clear() is invoked twice.
Individual data structures are reset so that they are not cleaned/freed
twice. This patch does the same for eqo->affinity_mask. It is freed only
if EQs haven't yet been destroyed. This fixes a possible crash when
affinity_mask is freed twice.

Signed-off-by: Kalesh AP 
Signed-off-by: Sathya Perla 
---
 drivers/net/ethernet/emulex/benet/be_main.c | 18 ++
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/emulex/benet/be_main.c 
b/drivers/net/ethernet/emulex/benet/be_main.c
index 14ae67a..c28e3bf 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -2584,8 +2584,8 @@ static void be_evt_queues_destroy(struct be_adapter 
*adapter)
be_cmd_q_destroy(adapter, &eqo->q, QTYPE_EQ);
napi_hash_del(&eqo->napi);
netif_napi_del(&eqo->napi);
+   free_cpumask_var(eqo->affinity_mask);
}
-   free_cpumask_var(eqo->affinity_mask);
be_queue_free(adapter, &eqo->q);
}
 }
@@ -2602,13 +2602,7 @@ static int be_evt_queues_create(struct be_adapter 
*adapter)
 
for_all_evt_queues(adapter, eqo, i) {
int numa_node = dev_to_node(&adapter->pdev->dev);
-   if (!zalloc_cpumask_var(&eqo->affinity_mask, GFP_KERNEL))
-   return -ENOMEM;
-   cpumask_set_cpu(cpumask_local_spread(i, numa_node),
-   eqo->affinity_mask);
-   netif_napi_add(adapter->netdev, &eqo->napi, be_poll,
-  BE_NAPI_WEIGHT);
-   napi_hash_add(&eqo->napi);
+
aic = &adapter->aic_obj[i];
eqo->adapter = adapter;
eqo->idx = i;
@@ -2624,6 +2618,14 @@ static int be_evt_queues_create(struct be_adapter 
*adapter)
rc = be_cmd_eq_create(adapter, eqo);
if (rc)
return rc;
+
+   if (!zalloc_cpumask_var(&eqo->affinity_mask, GFP_KERNEL))
+   return -ENOMEM;
+   cpumask_set_cpu(cpumask_local_spread(i, numa_node),
+   eqo->affinity_mask);
+   netif_napi_add(adapter->netdev, &eqo->napi, be_poll,
+  BE_NAPI_WEIGHT);
+   napi_hash_add(&eqo->napi);
}
return 0;
 }
-- 
2.4.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/3] be2net: enable IFACE filters only after creating RXQs

2015-08-05 Thread Sathya Perla
From: Kalesh AP 

HW issues were observed on Lancer adapters if IFACE filters
(flags, mac addrs etc) are enabled *before* creating RXQs.  This patch
changes the driver design by enabling filters in be_open() --
instead of be_setup() -- after RXQs are created and buffers posted.
Two new wrapper functions, be_enable_if_filters() and
be_disable_if_filters() are introduced to enable/disable IFACE filters in
be_open()/be_close() respectively. In be_setup() the IFACE is now created
only with the RSS flag.

Signed-off-by: Kalesh AP 
Signed-off-by: Sathya Perla 
---
 drivers/net/ethernet/emulex/benet/be_cmds.h |   5 ++
 drivers/net/ethernet/emulex/benet/be_main.c | 127 ++--
 2 files changed, 85 insertions(+), 47 deletions(-)

diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.h 
b/drivers/net/ethernet/emulex/benet/be_cmds.h
index 2716e6f..00e3a6b 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.h
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.h
@@ -620,6 +620,11 @@ enum be_if_flags {
 BE_IF_FLAGS_VLAN_PROMISCUOUS |\
 BE_IF_FLAGS_MCAST_PROMISCUOUS)
 
+#define BE_IF_EN_FLAGS (BE_IF_FLAGS_BROADCAST | BE_IF_FLAGS_PASS_L3L4_ERRORS |\
+   BE_IF_FLAGS_MULTICAST | BE_IF_FLAGS_UNTAGGED)
+
+#define BE_IF_ALL_FILT_FLAGS   (BE_IF_EN_FLAGS | BE_IF_FLAGS_ALL_PROMISCUOUS)
+
 /* An RX interface is an object with one or more MAC addresses and
  * filtering capabilities. */
 struct be_cmd_req_if_create {
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c 
b/drivers/net/ethernet/emulex/benet/be_main.c
index 6f64242..7730f21 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -273,6 +273,10 @@ static int be_mac_addr_set(struct net_device *netdev, void 
*p)
if (ether_addr_equal(addr->sa_data, netdev->dev_addr))
return 0;
 
+   /* if device is not running, copy MAC to netdev->dev_addr */
+   if (!netif_running(netdev))
+   goto done;
+
/* The PMAC_ADD cmd may fail if the VF doesn't have FILTMGMT
 * privilege or if PF did not provision the new MAC address.
 * On BE3, this cmd will always fail if the VF doesn't have the
@@ -307,9 +311,9 @@ static int be_mac_addr_set(struct net_device *netdev, void 
*p)
status = -EPERM;
goto err;
}
-
-   memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
-   dev_info(dev, "MAC address changed to %pM\n", mac);
+done:
+   ether_addr_copy(netdev->dev_addr, addr->sa_data);
+   dev_info(dev, "MAC address changed to %pM\n", addr->sa_data);
return 0;
 err:
dev_warn(dev, "MAC address change to %pM failed\n", addr->sa_data);
@@ -3361,6 +3365,33 @@ static void be_rx_qs_destroy(struct be_adapter *adapter)
}
 }
 
+static void be_disable_if_filters(struct be_adapter *adapter)
+{
+   be_cmd_pmac_del(adapter, adapter->if_handle,
+   adapter->pmac_id[0], 0);
+
+   be_clear_uc_list(adapter);
+
+   /* The IFACE flags are enabled in the open path and cleared
+* in the close path. When a VF gets detached from the host and
+* assigned to a VM the following happens:
+*  - VF's IFACE flags get cleared in the detach path
+*  - IFACE create is issued by the VF in the attach path
+* Due to a bug in the BE3/Skyhawk-R FW
+* (Lancer FW doesn't have the bug), the IFACE capability flags
+* specified along with the IFACE create cmd issued by a VF are not
+* honoured by FW.  As a consequence, if a *new* driver
+* (that enables/disables IFACE flags in open/close)
+* is loaded in the host and an *old* driver is * used by a VM/VF,
+* the IFACE gets created *without* the needed flags.
+* To avoid this, disable RX-filter flags only for Lancer.
+*/
+   if (lancer_chip(adapter)) {
+   be_cmd_rx_filter(adapter, BE_IF_ALL_FILT_FLAGS, OFF);
+   adapter->if_flags &= ~BE_IF_ALL_FILT_FLAGS;
+   }
+}
+
 static int be_close(struct net_device *netdev)
 {
struct be_adapter *adapter = netdev_priv(netdev);
@@ -3373,6 +3404,8 @@ static int be_close(struct net_device *netdev)
if (!(adapter->flags & BE_FLAGS_SETUP_DONE))
return 0;
 
+   be_disable_if_filters(adapter);
+
be_roce_dev_close(adapter);
 
if (adapter->flags & BE_FLAGS_NAPI_ENABLED) {
@@ -3392,7 +3425,6 @@ static int be_close(struct net_device *netdev)
be_tx_compl_clean(adapter);
 
be_rx_qs_destroy(adapter);
-   be_clear_uc_list(adapter);
 
for_all_evt_queues(adapter, eqo, i) {
if (msix_enabled(adapter))
@@ -3477,6 +3509,31 @@ static int be_rx_qs_create(struct be_adapter *

[PATCH 0/3] be2net: patch set

2015-08-05 Thread Sathya Perla
Hi David,

This patch set contains 2 driver fixes to a Lancer HW issue and a fix
to a double free bug. Pls apply to the "net" tree. Thanks!

Patch 1 now enables filters only after creating RXQs. This is done as 
HW issues were observed on Lancer adapters if filters
(flags, mac addrs etc) are enabled *before* creating RXQs. This patch
changes the driver design by enabling filters in be_open() --
instead of be_setup() -- after RXQs are created and buffers posted.

Patch 2 fixes an RX stall issue that was seen on Lancer adapters when
RXQs are destroyed while they are in an "out of buffer" state.
This patch fixes this issue by posting 64 buffers to each RXQ before
destroying them in the close path. This is done after ensuring that no
more new packets are selected for transfer to the RXQs by disabling
interface filters.

Patch 3 protects eqo->affinity_mask variable from being freed twice and
resulting in a crash.  It's now freed only when EQs haven't yet been
destroyed.

Kalesh AP (3):
  be2net: enable IFACE filters only after creating RXQs
  be2net: post buffers before destroying RXQs in Lancer
  be2net: protect eqo->affinity_mask from getting freed twice

 drivers/net/ethernet/emulex/benet/be_cmds.h |   5 +
 drivers/net/ethernet/emulex/benet/be_main.c | 187 ++--
 2 files changed, 125 insertions(+), 67 deletions(-)

-- 
2.4.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/3] be2net: post buffers before destroying RXQs in Lancer

2015-08-05 Thread Sathya Perla
From: Kalesh AP 

An RX stall issue was seen on Lancer adapters, when RXQs are destroyed
while they are in an "out of buffer" state. This patch fixes this issue
by posting 64 buffers to each RXQ before destroying them in the close path.
This is done after ensuring that no more new packets are selected for
transfer to the RXQs by disabling interface filters.

Signed-off-by: Kalesh AP 
Signed-off-by: Sathya Perla 
---
 drivers/net/ethernet/emulex/benet/be_main.c | 42 -
 1 file changed, 30 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/emulex/benet/be_main.c 
b/drivers/net/ethernet/emulex/benet/be_main.c
index 7730f21..14ae67a 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -2451,10 +2451,24 @@ static void be_eq_clean(struct be_eq_obj *eqo)
be_eq_notify(eqo->adapter, eqo->q.id, false, true, num, 0);
 }
 
+/* Free posted rx buffers that were not used */
+static void be_rxq_clean(struct be_rx_obj *rxo)
+{
+   struct be_queue_info *rxq = &rxo->q;
+   struct be_rx_page_info *page_info;
+
+   while (atomic_read(&rxq->used) > 0) {
+   page_info = get_rx_page_info(rxo);
+   put_page(page_info->page);
+   memset(page_info, 0, sizeof(*page_info));
+   }
+   BUG_ON(atomic_read(&rxq->used));
+   rxq->tail = 0;
+   rxq->head = 0;
+}
+
 static void be_rx_cq_clean(struct be_rx_obj *rxo)
 {
-   struct be_rx_page_info *page_info;
-   struct be_queue_info *rxq = &rxo->q;
struct be_queue_info *rx_cq = &rxo->cq;
struct be_rx_compl_info *rxcp;
struct be_adapter *adapter = rxo->adapter;
@@ -2491,16 +2505,6 @@ static void be_rx_cq_clean(struct be_rx_obj *rxo)
 
/* After cleanup, leave the CQ in unarmed state */
be_cq_notify(adapter, rx_cq->id, false, 0);
-
-   /* Then free posted rx buffers that were not used */
-   while (atomic_read(&rxq->used) > 0) {
-   page_info = get_rx_page_info(rxo);
-   put_page(page_info->page);
-   memset(page_info, 0, sizeof(*page_info));
-   }
-   BUG_ON(atomic_read(&rxq->used));
-   rxq->tail = 0;
-   rxq->head = 0;
 }
 
 static void be_tx_compl_clean(struct be_adapter *adapter)
@@ -3358,8 +3362,22 @@ static void be_rx_qs_destroy(struct be_adapter *adapter)
for_all_rx_queues(adapter, rxo, i) {
q = &rxo->q;
if (q->created) {
+   /* If RXQs are destroyed while in an "out of buffer"
+* state, there is a possibility of an HW stall on
+* Lancer. So, post 64 buffers to each queue to relieve
+* the "out of buffer" condition.
+* Make sure there's space in the RXQ before posting.
+*/
+   if (lancer_chip(adapter)) {
+   be_rx_cq_clean(rxo);
+   if (atomic_read(&q->used) == 0)
+   be_post_rx_frags(rxo, GFP_KERNEL,
+MAX_RX_POST);
+   }
+
be_cmd_rxq_destroy(adapter, q);
be_rx_cq_clean(rxo);
+   be_rxq_clean(rxo);
}
be_queue_free(adapter, q);
}
-- 
2.4.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


  1   2   >