linux_dsm_epyc7002/drivers/net/ethernet
Jacob Keller 3ee7b3a3b9 fm10k: use a BITMAP for flags to avoid race conditions
Replace bitwise operators and #defines with a BITMAP and enumeration
values. This is similar to how we handle the "state" values as well.

This has two distinct advantages over the old method. First, we ensure
correctness of operations which are currently problematic due to race
conditions. Suppose that two kernel threads are running, such as the
watchdog and an ethtool ioctl, and both modify flags. We'll say that the
watchdog is CPU A, and the ethtool ioctl is CPU B.

CPU A sets FLAG_1, which can be seen as
  CPU A read FLAGS
  CPU A write FLAGS | FLAG_1

CPU B sets FLAG_2, which can be seen as
  CPU B read FLAGS
  CPU A write FLAGS | FLAG_2

However, "|=" and "&=" operators are not actually atomic. So this could
be ordered like the following:

CPU A read FLAGS -> variable
CPU B read FLAGS -> variable
CPU A write FLAGS (variable | FLAG_1)
CPU B write FLAGS (variable | FLAG_2)

Notice how the 2nd write from CPU B could actually undo the write from
CPU A because it isn't guaranteed that the |= operation is atomic.

In practice the race windows for most flag writes is incredibly narrow
so it is not easy to isolate issues. However, the more flags we have,
the more likely they will cause problems. Additionally, if such
a problem were to arise, it would be incredibly difficult to track down.

Second, there is an additional advantage beyond code correctness. We can
now automatically size the BITMAP if more flags were added, so that we
do not need to remember that flags is u32 and thus if we added too many
flags we would over-run the variable. This is not a likely occurrence
for fm10k driver, but this patch can serve as an example for other
drivers which have many more flags.

This particular change does have a bit of trouble converting some of the
idioms previously used with the #defines for flags. Specifically, when
converting FM10K_FLAG_RSS_FIELD_IPV[46]_UDP flags. This whole operation
was actually quite problematic, because we actually stored flags
separately. This could more easily show the problem of the above
re-ordering issue.

This is really difficult to test whether atomics make a difference in
practical scenarios, but you can ensure that basic functionality remains
the same. This patch has a lot of code coverage, but most of it is
relatively simple.

While we are modifying these files, update their copyright year.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Tested-by: Krishneil Singh <krishneil.k.singh@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
2017-04-05 22:47:30 -07:00
..
3com
8390
adaptec
adi net: bfin_mac: Remove unused stats member from struct bfin_mac_local 2017-03-27 16:01:59 -07:00
aeroflex net: greth: Utilize of_get_mac_address() 2017-03-22 12:00:39 -07:00
agere
alacritech
allwinner
alteon
altera
amazon
amd drivers: add explicit interrupt.h includes 2017-03-30 11:05:34 -07:00
apm drivers: net: xgene-v2: misc fixes 2017-03-22 19:17:14 -07:00
apple
aquantia net:ethernet:aquantia: Fix for RX checksum offload. 2017-03-22 19:40:52 -07:00
arc
atheros
aurora
broadcom bnxt_en: Cap the msix vector with the max completion rings. 2017-04-05 06:24:26 -07:00
brocade bna: integer overflow bug in debugfs 2017-03-21 17:43:16 -07:00
cadence lib/vsprintf.c: remove %Z support 2017-02-27 18:43:47 -08:00
calxeda
cavium liquidio: clear the correct memory 2017-04-05 06:53:42 -07:00
chelsio cxgb4: Update IngPad and IngPack values 2017-03-22 10:53:49 -07:00
cirrus
cisco
davicom
dec
dlink
emulex
ezchip drivers: add explicit interrupt.h includes 2017-03-30 11:05:34 -07:00
faraday net/faraday: Add missing include of of.h 2017-04-03 18:58:08 -07:00
freescale dpaa_eth: use AVOIDBLOCK for Tx confirmation queues 2017-04-01 12:03:31 -07:00
fujitsu
hisilicon net: hns: Some checkpatch.pl script & warning fixes 2017-04-03 14:48:43 -07:00
hp
i825xx
ibm net: ibm: emac: remove unused sysrq handler for 'c' key 2017-04-05 07:26:18 -07:00
intel fm10k: use a BITMAP for flags to avoid race conditions 2017-04-05 22:47:30 -07:00
marvell net: mvneta: set rx mode during resume if interface is running 2017-03-29 14:08:57 -07:00
mediatek net: mediatek: Use eth_hw_addr_random() 2017-03-09 13:16:34 -08:00
mellanox drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c: fix build with gcc-4.4.4 2017-04-02 19:32:57 -07:00
micrel net: ks8851: Added support for half-duplex SPI 2017-03-09 18:18:37 -08:00
microchip
moxa
myricom
natsemi
neterion net: s2io: fix typo argumnet argument 2017-02-26 11:57:58 -05:00
netronome nfp: add support for .set_link_ksettings() 2017-04-05 10:49:12 -07:00
nuvoton
nvidia
nxp
oki-semi
packetengines
pasemi
qlogic qed: Add a missing error code 2017-04-05 06:53:42 -07:00
qualcomm drivers: add explicit interrupt.h includes 2017-03-30 11:05:34 -07:00
rdc
realtek r8169: replace init_timer with setup_timer 2017-03-12 23:55:03 -07:00
renesas
rocker ipv4: fib_rules: Dump FIB rules when registering FIB notifier 2017-03-16 10:18:34 -07:00
samsung
seeq drivers: net: ethernet: remove incorrect __exit markups 2017-03-02 14:33:49 -08:00
sfc sfc: don't insert mc_list on low-latency firmware if it's too long 2017-04-05 18:35:21 -07:00
sgi net: sgi: ioc3-eth: use new api ethtool_{get|set}_link_ksettings 2017-03-06 17:05:39 -08:00
silan net: silan: sc92031: use new api ethtool_{get|set}_link_ksettings 2017-03-06 17:05:39 -08:00
sis net: sis: sis900: use new api ethtool_{get|set}_link_ksettings 2017-03-06 17:05:39 -08:00
smsc net: smsc: smc91x: use new api ethtool_{get|set}_link_ksettings 2017-03-08 22:18:05 -08:00
stmicro net: stmmac: rx queue to dma channel mapping fix 2017-04-05 06:47:26 -07:00
sun net: sun: sungem: rix a possible null dereference 2017-03-21 17:44:46 -07:00
synopsys net: dwc-xlgmac: use dual license 2017-03-23 17:04:14 -07:00
tehuti net: tehuti: use new api ethtool_{get|set}_link_ksettings 2017-03-27 16:00:07 -07:00
ti Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2017-03-23 16:41:27 -07:00
tile
toshiba net: toshiba: spider_net: use new api ethtool_{get|set}_link_ksettings 2017-03-08 22:18:05 -08:00
tundra net: tundra: tsi108: use new api ethtool_{get|set}_link_ksettings 2017-03-12 19:28:07 -07:00
via net: via: via-velocity: use new api ethtool_{get|set}_link_ksettings 2017-03-12 19:28:07 -07:00
wiznet
xilinx net: axienet: use eth_hw_addr_random() 2017-03-06 17:15:41 -08:00
xircom
xscale
dnet.c
dnet.h
ec_bhf.c
ethoc.c net: ethoc: Use ether_addr_copy() 2017-03-21 17:16:56 -07:00
fealnx.c
jme.c
jme.h
Kconfig net: dwc-xlgmac: Initial driver for DesignWare Enterprise Ethernet 2017-03-09 13:29:27 -08:00
korina.c
lantiq_etop.c
Makefile net: dwc-xlgmac: Initial driver for DesignWare Enterprise Ethernet 2017-03-09 13:29:27 -08:00
netx-eth.c