Commit Graph

39 Commits

Author SHA1 Message Date
Michael Chan 035a1539ab bnxt_en: Poll link at the end of __bnxt_open_nic().
When shutting down the NIC, we shutdown async event processing before
freeing all the rings.  If there is a link change event during reset, the
driver may miss it and the link state may be incorrect after the NIC is
re-opened.  Poll the link at the end of __bnxt_open_nic() to get the
correct link status.

Signed-off-by Michael Chan <michael.chan@broadcom.com>

Signed-off-by: David S. Miller <davem@davemloft.net>
2016-02-19 23:39:32 -05:00
Michael Chan 4419dbe6a0 bnxt_en: Fix implementation of tx push operation.
tx push is supported for small packets to reduce DMA latency.  The
following bugs are fixed in this patch:

1. Fix the definition of the push BD which is different from the DMA BD.
2. The push buffer has to be zero padded to the next 64-bit word boundary
or tx checksum won't be correct.
3. Increase the tx push packet threshold to 164 bytes (192 bytes with the BD)
so that small tunneled packets are within the threshold.

Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-02-16 15:50:02 -05:00
Michael Chan 0d8abf0201 bnxt_en: Cleanup and Fix flow control setup logic
Cleanup bnxt_probe_phy() to cleanly separate 2 code blocks for autoneg
on and off.  Autoneg flow control is possible only if autoneg is enabled.

In bnxt_get_settings(), Pause and Asym_Pause are always supported.
Only the advertisement bits change depending on the ethtool -A setting
in auto mode.

Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-02-16 15:50:01 -05:00
Michael Chan d612a57977 bnxt_en: Fix crash in bnxt_free_tx_skbs() during tx timeout.
The ring index j is not wrapped properly at the end of the ring, causing
it to reference pointers past the end of the ring.  For proper loop
termination and to access the ring properly, we need to increment j and
mask it before referencing the ring entry.

Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-01-29 17:28:39 -08:00
Michael Chan 8a4d4c8dde bnxt_en: Exclude rx_drop_pkts hw counter from the stack's rx_dropped counter.
This hardware counter is misleading as it counts dropped packets that
don't match the hardware filters for unicast/broadcast/multicast.  We
will still report this counter in ethtool -S for diagnostics purposes.

Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-01-29 17:28:39 -08:00
Prashant Sreedharan 74608fc98d bnxt_en: Ring free response from close path should use completion ring
Use completion ring for ring free response from firmware.  The response
will be the last entry in the ring and we can free the ring after getting
the response.  This will guarantee no spurious DMA to freed memory.

Signed-off-by: Prashant Sreedharan <prashant@broadcom.com>
Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-01-29 17:28:39 -08:00
Arnd Bergmann 415b6f19e8 net: bnxt: always return values from _bnxt_get_max_rings
Newly added code in the bnxt driver uses a couple of variables that
are never initialized when CONFIG_BNXT_SRIOV is not set, and gcc
correctly warns about that:

In file included from include/linux/list.h:8:0,
                 from include/linux/module.h:9,
                 from drivers/net/ethernet/broadcom/bnxt/bnxt.c:10:
drivers/net/ethernet/broadcom/bnxt/bnxt.c: In function 'bnxt_get_max_rings':
include/linux/kernel.h:794:26: warning: 'cp' may be used uninitialized in this function [-Wmaybe-uninitialized]
include/linux/kernel.h:794:26: warning: 'tx' may be used uninitialized in this function [-Wmaybe-uninitialized]
drivers/net/ethernet/broadcom/bnxt/bnxt.c:5730:11: warning: 'rx' may be used uninitialized in this function [-Wmaybe-uninitialized]
drivers/net/ethernet/broadcom/bnxt/bnxt.c:5736:6: note: 'rx' was declared here

This changes the condition so that we fall back to using the PF
data if VF is not available, and always initialize the variables
to something useful.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Fixes: 6e6c5a57fb ("bnxt_en: Modify bnxt_get_max_rings() to support shared or non shared rings.")
Acked-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-01-12 17:06:56 -05:00
Michael Chan d79979a103 bnxt_en: Zero pad firmware messages to 128 bytes.
For future compatibility, zero pad all messages that the driver sends
to the firmware to 128 bytes.  If these messages are extended in the
future with new byte enables, zero padding these messages now will
guarantee future compatibility.

Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-01-10 22:19:19 -05:00
Michael Chan 01657bcd07 bnxt_en: Modify init sequence to support shared or non shared rings.
Modify ring memory allocation and MSIX setup to support shared or
non shared rings and do the proper mapping.  Default is still to
use shared rings.

Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-01-04 15:54:40 -05:00
Michael Chan 6e6c5a57fb bnxt_en: Modify bnxt_get_max_rings() to support shared or non shared rings.
Add logic to calculate how many shared or non shared rings can be
supported.  Default is to use shared rings.

Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-01-04 15:54:40 -05:00
Michael Chan b81a90d302 bnxt_en: Re-structure ring indexing and mapping.
In order to support dedicated or shared completion rings, the ring
indexing and mapping are re-structured as below:

1. bp->grp_info[] array index is 1:1 with bp->bnapi[] array index and
completion ring index.

2. rx rings 0 to n will be mapped to completion rings 0 to n.

3. If tx and rx rings share completion rings, then tx rings 0 to m will
be mapped to completion rings 0 to m.

4. If tx and rx rings use dedicated completion rings, then tx rings 0 to
m will be mapped to completion rings n + 1 to n + m.

5. Each tx or rx ring will use the corresponding completion ring index
for doorbell mapping and MSIX mapping.

Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-01-04 15:54:39 -05:00
Michael Chan 3b2b7d9db7 bnxt_en: Check for NULL rx or tx ring.
Each bnxt_napi structure may no longer be having both an rx ring and
a tx ring.  Check for a valid ring before using it.

Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-01-04 15:54:39 -05:00
Michael Chan b6ab4b01f5 bnxt_en: Separate bnxt_{rx|tx}_ring_info structs from bnxt_napi struct.
Currently, an rx and a tx ring are always paired with a completion ring.
We want to restructure it so that it is possible to have a dedicated
completion ring for tx or rx only.

The bnxt hardware uses a completion ring for rx and tx events.  The driver
has to process the completion ring entries sequentially for the rx and tx
events.  Using a dedicated completion ring for rx only or tx only has these
benefits:

1. A burst of rx packets can cause delay in processing tx events if the
completion ring is shared.  If tx queue is stopped by BQL, this can cause
delay in re-starting the tx queue.

2. A completion ring is sized according to the rx and tx ring size rounded
up to the nearest power of 2.  When the completion ring is shared, it is
sized by adding the rx and tx ring sizes and then rounded to the next power
of 2, often with a lot of wasted space.

3. Using dedicated completion ring, we can adjust the tx and rx coalescing
parameters independently for rx and tx.

The first step is to separate the rx and tx ring structures from the
bnxt_napi struct.

In this patch, an rx ring and a tx ring will point to the same bnxt_napi
struct to share the same completion ring.  No change in ring assignment
and mapping yet.

Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-01-04 15:54:39 -05:00
Michael Chan 9f5545905f bnxt_en: Refactor bnxt_dbg_dump_states().
By adding 3 separate functions to dump the different ring states.

Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-01-04 15:54:39 -05:00
David Christensen fbc9a5237a bnxt_en: Add BCM57301 & BCM57402 devices.
Added the PCI IDs for the BCM57301 and BCM57402 controllers.

Signed-off-by: David Christensen <davidch@broadcom.com>
Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-12-28 00:57:29 -05:00
Michael Chan c193554ecd bnxt_en: Update to Firmware interface spec 1.0.0.
This interface will be forward compatible with future changes.

Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-12-28 00:57:29 -05:00
Michael Chan b72d4a68c4 bnxt_en: Keep track of the ring group resource.
Newer firmware will return the ring group resource when we call
hwrm_func_qcaps().  To be compatible with older firmware, use the
number of tx rings as the number of ring groups if the older firmware
returns 0.  When determining how many rx rings we can support, take
the ring group resource in account as well in _bnxt_get_max_rings().
Divide and assign the ring groups to VFs.

Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-12-28 00:57:28 -05:00
Michael Chan 4a21b49b34 bnxt_en: Improve VF resource accounting.
We need to keep track of all resources, such as rx rings, tx rings,
cmpl rings, rss contexts, stats contexts, vnics, after we have
divided them for the VFs.  Otherwise, subsequent ring changes on
the PF may not work correctly.

We adjust all max resources in struct bnxt_pf_info after they have been
assigned to the VFs.  There is no need to keep the separate
max_pf_tx_rings and max_pf_rx_rings.

When SR-IOV is disabled, we call bnxt_hwrm_func_qcaps() to restore the
max resources for the PF.

Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-12-28 00:57:28 -05:00
Michael Chan 2bcfa6f6e7 bnxt_en: Check hardware resources before enabling NTUPLE.
The hardware resources required to enable NTUPLE varies depending on
how many rx channels are configured.  We need to make sure we have the
resources before we enable NTUPLE.  Add bnxt_rfs_capable() to do the
checking.

In addition, we need to do the same checking in ndo_fix_features().  As
the rx channels are changed using ethtool -L, we call
netdev_update_features() to make the necessary adjustment for NTUPLE.

Calling netdev_update_features() in netif_running() state but before
calling bnxt_open_nic() would be a problem.  To make this work,
bnxt_set_features() has to be modified to test for BNXT_STATE_OPEN for
the true hardware state instead of checking netif_running().

Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-12-28 00:57:28 -05:00
Michael Chan 27e241896f bnxt_en: Don't treat single segment rx frames as GRO frames.
If hardware completes single segment rx frames, don't bother setting
up all the GRO related fields.  Pass the SKB up as a normal frame.

Reviewed-by: vasundhara volam <vvolam@broadcom.com>
Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-12-28 00:57:28 -05:00
Michael Chan 45019a1803 bnxt_en: Allocate rx_cpu_rmap only if Accelerated RFS is enabled.
Also, no need to check for bp->rx_nr_rings as it is always >= 1.  If the
allocation fails, it is not a fatal error and we can still proceed.

Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-12-28 00:57:28 -05:00
Satish Baddipadige 665e350ddb bnxt_en: Increment checksum error counter only if NETIF_F_RXCSUM is set.
rx_l4_csum_error is now incremented only when offload is enabled

Signed-off-by: Satish Baddipadige <sbaddipa@broadcom.com>
Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-12-28 00:57:28 -05:00
Michael Chan edd0c2cc2b bnxt_en: Optimize ring alloc and ring free functions.
Remove the unnecessary "if" statement before the "for" statement:

if (x) {
        for (i = 0; i < x; i++)
...
}

Also, change the ring free function to return void as it only returns 0.

Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-12-28 00:57:28 -05:00
Jeffrey Huang be58a0da16 bnxt_en: support hwrm_func_drv_unrgtr command
During remove_one, the driver should issue hwrm_func_drv_unrgtr
command to inform firmware that this function has been unloaded.
This is to let firmware keep track of driver present/absent state
when driver is gracefully unloaded. A keep alive timer is needed
later to keep track of driver state during abnormal shutdown.

Signed-off-by: Jeffrey Huang <huangjw@broadcom.com>
Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-12-28 00:57:27 -05:00
David S. Miller b3e0d3d7ba Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Conflicts:
	drivers/net/geneve.c

Here we had an overlapping change, where in 'net' the extraneous stats
bump was being removed whilst in 'net-next' the final argument to
udp_tunnel6_xmit_skb() was being changed.

Signed-off-by: David S. Miller <davem@davemloft.net>
2015-12-17 22:08:28 -05:00
Michael Chan 028de140ff bnxt_en: Implement missing tx timeout reset logic.
The reset logic calls bnxt_close_nic() and bnxt_open_nic() under rtnl_lock
from bnxt_sp_task.  BNXT_STATE_IN_SP_TASK must be cleared before calling
bnxt_close_nic() to avoid deadlock.

v2: Fixed white space error.  Thanks Dave.

Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-12-11 23:34:06 -05:00
Michael Chan 4cebdcec09 bnxt_en: Don't cancel sp_task from bnxt_close_nic().
When implementing driver reset from tx_timeout in the next patch,
bnxt_close_nic() will be called from the sp_task workqueue.  Calling
cancel_work() on sp_task will hang the workqueue.

Instead, set a new bit BNXT_STATE_IN_SP_TASK when bnxt_sp_task() is running.
bnxt_close_nic() will wait for BNXT_STATE_IN_SP_TASK to clear before
proceeding.

Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-12-11 23:34:06 -05:00
Michael Chan caefe526d7 bnxt_en: Change bp->state to bitmap.
This allows multiple independent bits to be set for various states.
Subsequent patches to implement tx timeout reset will require this.

Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-12-11 23:34:06 -05:00
Michael Chan de68f5de56 bnxt_en: Fix bitmap declaration to work on 32-bit arches.
The declaration of the bitmap vf_req_snif_bmap using fixed array of
unsigned long will only work on 64-bit archs.  Use DECLARE_BITMAP instead
which will work on all archs.

Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-12-11 23:34:05 -05:00
David S. Miller f188b951f3 Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Conflicts:
	drivers/net/ethernet/renesas/ravb_main.c
	kernel/bpf/syscall.c
	net/ipv4/ipmr.c

All three conflicts were cases of overlapping changes.

Signed-off-by: David S. Miller <davem@davemloft.net>
2015-12-03 21:09:12 -05:00
Michael Chan b664f008b0 bnxt_en: Setup uc_list mac filters after resetting the chip.
Call bnxt_cfg_rx_mode() in bnxt_init_chip() to setup uc_list and
mc_list mac address filters.  Before the patch, uc_list is not
setup again after chip reset (such as ethtool ring size change)
and macvlans don't work any more after that.

Modify bnxt_cfg_rx_mode() to return error codes appropriately so
that the init chip sequence can detect any failures.

Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-12-03 15:07:13 -05:00
Jeffrey Huang bdd4347b33 bnxt_en: enforce proper storing of MAC address
For PF, the bp->pf.mac_addr always holds the permanent MAC
addr assigned by the HW.  For VF, the bp->vf.mac_addr always
holds the administrator assigned VF MAC addr. The random
generated VF MAC addr should never get stored to bp->vf.mac_addr.
This way, when the VF wants to change the MAC address, we can tell
if the adminstrator has already set it and disallow the VF from
changing it.

v2: Fix compile error if CONFIG_BNXT_SRIOV is not set.

Signed-off-by: Jeffrey Huang <huangjw@broadcom.com>
Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-12-03 15:07:13 -05:00
Jeffrey Huang 1fc2cfd03b bnxt_en: Fixed incorrect implementation of ndo_set_mac_address
The existing ndo_set_mac_address only copies the new MAC addr
and didn't set the new MAC addr to the HW. The correct way is
to delete the existing default MAC filter from HW and add
the new one. Because of RFS filters are also dependent on the
default mac filter l2 context, the driver must go thru
close_nic() to delete the default MAC and RFS filters, then
open_nic() to set the default MAC address to HW.

Signed-off-by: Jeffrey Huang <huangjw@broadcom.com>
Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-12-03 15:07:13 -05:00
Eric Dumazet 93d05d4a32 net: provide generic busy polling to all NAPI drivers
NAPI drivers no longer need to observe a particular protocol
to benefit from busy polling (CONFIG_NET_RX_BUSY_POLL=y)

napi_hash_add() and napi_hash_del() are automatically called
from core networking stack, respectively from
netif_napi_add() and netif_napi_del()

This patch depends on free_netdev() and netif_napi_del() being
called from process context, which seems to be the norm.

Drivers might still prefer to call napi_hash_del() on their
own, since they might combine all the rcu grace periods into
a single one, knowing their NAPI structures lifetime, while
core networking stack has no idea of a possible combining.

Once this patch proves to not bring serious regressions,
we will cleanup drivers to either remove napi_hash_del()
or provide appropriate rcu grace periods combining.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-11-18 16:17:42 -05:00
Michael Chan 84e86b98f6 bnxt_en: Fix comparison of u16 sw_id against negative value.
Assign the return value from bitmap_find_free_region() to an integer
variable and check for negative error codes first, before assigning
the bit ID to the unsigned sw_id field.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-11-05 16:33:09 -05:00
Jeffrey Huang 11809490ac bnxt_en: map CAG_REG_LEGACY_INT_STATUS_MASK to GRC window #4
In order to use offset 0x4014 for reading CAG interrupt status,
the actual CAG register must be mapped to GRC bar0 window #4.
Otherwise, the driver is reading garbage. This patch corrects
this issue.

Signed-off-by: Jeffrey Huang <huangjw@broadcom.com>
Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-11-05 16:33:08 -05:00
Michael Chan d1611c3aba bnxt_en: Fix compile warnings when CONFIG_INET is not set.
bnxt_gro_skb() has unused variables when CONFIG_INET is not set.  We
really cannot support hardware GRO if CONFIG_INET is not set, so
compile out bnxt_gro_skb() completely and define BNXT_FLAG_GRO to be 0
if CONFIG_INET is not set.  This will effectively always disable
hardware GRO if CONFIG_INET is not set.

Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-10-25 22:36:15 -07:00
Michael Chan 379a80a1d0 bnxt_en: Fix compile errors when CONFIG_BNXT_SRIOV is not set.
struct bnxt_pf_info needs to be always defined.  Move bnxt_update_vf_mac()
to bnxt_sriov.c and add some missing #ifdef CONFIG_BNXT_SRIOV.

Reported-by: Jim Hull <jim.hull@hpe.com>
Tested-by: Jim Hull <jim.hull@hpe.com>
Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-10-23 17:34:34 -07:00
Michael Chan c0c050c58d bnxt_en: New Broadcom ethernet driver.
Broadcom ethernet driver for the new family of NetXtreme-C/E
ethernet devices.

v5:
  - Removed empty blank lines at end of files (noted by David Miller).
  - Moved busy poll helper functions to bnxt.h to at least make the
    .c file look less cluttered with #ifdef (noted by Stephen Hemminger).

v4:
  - Broke up 2 long message strings with "\n" (suggested by John Linville)
  - Constify an array of strings (suggested by Stephen Hemminger)
  - Improve bnxt_vf_pciid() (suggested by Stephen Hemminger)
  - Use PCI_VDEVICE() to populate pci_device_id table for more compact
    source.

v3:
  - Fixed 2 more sparse warnings.
  - Removed some unused structures in .h files.

v2:
  - Fixed all kbuild test robot reported warnings.
  - Fixed many of the checkpatch.pl errors and warnings.
  - Fixed the Kconfig description (noted by Dmitry Kravkov).

Acked-by: Eddie Wai <eddie.wai@broadcom.com>
Acked-by: Jeffrey Huang <huangjw@broadcom.com>
Signed-off-by: Prashant Sreedharan <prashant@broadcom.com>
Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-10-22 19:30:33 -07:00