Skip to content

Commit

Permalink
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Browse files Browse the repository at this point in the history
Pull networking fixes from David Miller:

 1) Must teardown SR-IOV before unregistering netdev in igb driver, from
    Alex Williamson.

 2) Fix ipv6 route unreachable crash in IPVS, from Alex Gartrell.

 3) Default route selection in ipv4 should take the prefix length, table
    ID, and TOS into account, from Julian Anastasov.

 4) sch_plug must have a reset method in order to purge all buffered
    packets when the qdisc is reset, likewise for sch_choke, from WANG
    Cong.

 5) Fix deadlock and races in slave_changelink/br_setport in bridging.
    From Nikolay Aleksandrov.

 6) mlx4 bug fixes (wrong index in port even propagation to VFs,
    overzealous BUG_ON assertion, etc.) from Ido Shamay, Jack
    Morgenstein, and Or Gerlitz.

 7) Turn off klog message about SCTP userspace interface compat that
    makes no sense at all, from Daniel Borkmann.

 8) Fix unbounded restarts of inet frag eviction process, causing NMI
    watchdog soft lockup messages, from Florian Westphal.

 9) Suspend/resume fixes for r8152 from Hayes Wang.

10) Fix busy loop when MSG_WAITALL|MSG_PEEK is used in TCP recv, from
    Sabrina Dubroca.

11) Fix performance regression when removing a lot of routes from the
    ipv4 routing tables, from Alexander Duyck.

12) Fix device leak in AF_PACKET, from Lars Westerhoff.

13) AF_PACKET also has a header length comparison bug due to signedness,
    from Alexander Drozdov.

14) Fix bug in EBPF tail call generation on x86, from Daniel Borkmann.

15) Memory leaks, TSO stats, watchdog timeout and other fixes to
    thunderx driver from Sunil Goutham and Thanneeru Srinivasulu.

16) act_bpf can leak memory when replacing programs, from Daniel
    Borkmann.

17) WOL packet fixes in gianfar driver, from Claudiu Manoil.

* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (79 commits)
  stmmac: fix missing MODULE_LICENSE in stmmac_platform
  gianfar: Enable device wakeup when appropriate
  gianfar: Fix suspend/resume for wol magic packet
  gianfar: Fix warning when CONFIG_PM off
  act_pedit: check binding before calling tcf_hash_release()
  net: sk_clone_lock() should only do get_net() if the parent is not a kernel socket
  net: sched: fix refcount imbalance in actions
  r8152: reset device when tx timeout
  r8152: add pre_reset and post_reset
  qlcnic: Fix corruption while copying
  act_bpf: fix memory leaks when replacing bpf programs
  net: thunderx: Fix for crash while BGX teardown
  net: thunderx: Add PCI driver shutdown routine
  net: thunderx: Fix crash when changing rss with mutliple traffic flows
  net: thunderx: Set watchdog timeout value
  net: thunderx: Wakeup TXQ only if CQE_TX are processed
  net: thunderx: Suppress alloc_pages() failure warnings
  net: thunderx: Fix TSO packet statistic
  net: thunderx: Fix memory leak when changing queue count
  net: thunderx: Fix RQ_DROP miscalculation
  ...
  • Loading branch information
Linus Torvalds committed Aug 1, 2015
2 parents acea568 + ea11154 commit 7c764ce
Show file tree
Hide file tree
Showing 78 changed files with 1,000 additions and 539 deletions.
8 changes: 4 additions & 4 deletions arch/x86/net/bpf_jit_comp.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ static void emit_bpf_tail_call(u8 **pprog)
EMIT4(0x48, 0x8B, 0x46, /* mov rax, qword ptr [rsi + 16] */
offsetof(struct bpf_array, map.max_entries));
EMIT3(0x48, 0x39, 0xD0); /* cmp rax, rdx */
#define OFFSET1 44 /* number of bytes to jump */
#define OFFSET1 47 /* number of bytes to jump */
EMIT2(X86_JBE, OFFSET1); /* jbe out */
label1 = cnt;

Expand All @@ -278,15 +278,15 @@ static void emit_bpf_tail_call(u8 **pprog)
*/
EMIT2_off32(0x8B, 0x85, -STACKSIZE + 36); /* mov eax, dword ptr [rbp - 516] */
EMIT3(0x83, 0xF8, MAX_TAIL_CALL_CNT); /* cmp eax, MAX_TAIL_CALL_CNT */
#define OFFSET2 33
#define OFFSET2 36
EMIT2(X86_JA, OFFSET2); /* ja out */
label2 = cnt;
EMIT3(0x83, 0xC0, 0x01); /* add eax, 1 */
EMIT2_off32(0x89, 0x85, -STACKSIZE + 36); /* mov dword ptr [rbp - 516], eax */

/* prog = array->prog[index]; */
EMIT4(0x48, 0x8D, 0x44, 0xD6); /* lea rax, [rsi + rdx * 8 + 0x50] */
EMIT1(offsetof(struct bpf_array, prog));
EMIT4_off32(0x48, 0x8D, 0x84, 0xD6, /* lea rax, [rsi + rdx * 8 + offsetof(...)] */
offsetof(struct bpf_array, prog));
EMIT3(0x48, 0x8B, 0x00); /* mov rax, qword ptr [rax] */

/* if (prog == NULL)
Expand Down
125 changes: 83 additions & 42 deletions drivers/net/ethernet/cadence/macb.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,57 @@ static void *macb_rx_buffer(struct macb *bp, unsigned int index)
return bp->rx_buffers + bp->rx_buffer_size * macb_rx_ring_wrap(index);
}

/* I/O accessors */
static u32 hw_readl_native(struct macb *bp, int offset)
{
return __raw_readl(bp->regs + offset);
}

static void hw_writel_native(struct macb *bp, int offset, u32 value)
{
__raw_writel(value, bp->regs + offset);
}

static u32 hw_readl(struct macb *bp, int offset)
{
return readl_relaxed(bp->regs + offset);
}

static void hw_writel(struct macb *bp, int offset, u32 value)
{
writel_relaxed(value, bp->regs + offset);
}

/*
* Find the CPU endianness by using the loopback bit of NCR register. When the
* CPU is in big endian we need to program swaped mode for management
* descriptor access.
*/
static bool hw_is_native_io(void __iomem *addr)
{
u32 value = MACB_BIT(LLB);

__raw_writel(value, addr + MACB_NCR);
value = __raw_readl(addr + MACB_NCR);

/* Write 0 back to disable everything */
__raw_writel(0, addr + MACB_NCR);

return value == MACB_BIT(LLB);
}

static bool hw_is_gem(void __iomem *addr, bool native_io)
{
u32 id;

if (native_io)
id = __raw_readl(addr + MACB_MID);
else
id = readl_relaxed(addr + MACB_MID);

return MACB_BFEXT(IDNUM, id) >= 0x2;
}

static void macb_set_hwaddr(struct macb *bp)
{
u32 bottom;
Expand Down Expand Up @@ -160,7 +211,7 @@ static void macb_get_hwaddr(struct macb *bp)
}
}

netdev_info(bp->dev, "invalid hw address, using random\n");
dev_info(&bp->pdev->dev, "invalid hw address, using random\n");
eth_hw_addr_random(bp->dev);
}

Expand Down Expand Up @@ -252,7 +303,6 @@ static void macb_handle_link_change(struct net_device *dev)
struct macb *bp = netdev_priv(dev);
struct phy_device *phydev = bp->phy_dev;
unsigned long flags;

int status_change = 0;

spin_lock_irqsave(&bp->lock, flags);
Expand Down Expand Up @@ -449,14 +499,14 @@ static int macb_mii_init(struct macb *bp)

static void macb_update_stats(struct macb *bp)
{
u32 __iomem *reg = bp->regs + MACB_PFR;
u32 *p = &bp->hw_stats.macb.rx_pause_frames;
u32 *end = &bp->hw_stats.macb.tx_pause_frames + 1;
int offset = MACB_PFR;

WARN_ON((unsigned long)(end - p - 1) != (MACB_TPF - MACB_PFR) / 4);

for(; p < end; p++, reg++)
*p += readl_relaxed(reg);
for(; p < end; p++, offset += 4)
*p += bp->macb_reg_readl(bp, offset);
}

static int macb_halt_tx(struct macb *bp)
Expand Down Expand Up @@ -1107,12 +1157,6 @@ static void macb_poll_controller(struct net_device *dev)
}
#endif

static inline unsigned int macb_count_tx_descriptors(struct macb *bp,
unsigned int len)
{
return (len + bp->max_tx_length - 1) / bp->max_tx_length;
}

static unsigned int macb_tx_map(struct macb *bp,
struct macb_queue *queue,
struct sk_buff *skb)
Expand Down Expand Up @@ -1263,11 +1307,11 @@ static int macb_start_xmit(struct sk_buff *skb, struct net_device *dev)
* socket buffer: skb fragments of jumbo frames may need to be
* splitted into many buffer descriptors.
*/
count = macb_count_tx_descriptors(bp, skb_headlen(skb));
count = DIV_ROUND_UP(skb_headlen(skb), bp->max_tx_length);
nr_frags = skb_shinfo(skb)->nr_frags;
for (f = 0; f < nr_frags; f++) {
frag_size = skb_frag_size(&skb_shinfo(skb)->frags[f]);
count += macb_count_tx_descriptors(bp, frag_size);
count += DIV_ROUND_UP(frag_size, bp->max_tx_length);
}

spin_lock_irqsave(&bp->lock, flags);
Expand Down Expand Up @@ -1603,7 +1647,6 @@ static u32 macb_dbw(struct macb *bp)
static void macb_configure_dma(struct macb *bp)
{
u32 dmacfg;
u32 tmp, ncr;

if (macb_is_gem(bp)) {
dmacfg = gem_readl(bp, DMACFG) & ~GEM_BF(RXBS, -1L);
Expand All @@ -1613,22 +1656,11 @@ static void macb_configure_dma(struct macb *bp)
dmacfg |= GEM_BIT(TXPBMS) | GEM_BF(RXBMS, -1L);
dmacfg &= ~GEM_BIT(ENDIA_PKT);

/* Find the CPU endianness by using the loopback bit of net_ctrl
* register. save it first. When the CPU is in big endian we
* need to program swaped mode for management descriptor access.
*/
ncr = macb_readl(bp, NCR);
__raw_writel(MACB_BIT(LLB), bp->regs + MACB_NCR);
tmp = __raw_readl(bp->regs + MACB_NCR);

if (tmp == MACB_BIT(LLB))
if (bp->native_io)
dmacfg &= ~GEM_BIT(ENDIA_DESC);
else
dmacfg |= GEM_BIT(ENDIA_DESC); /* CPU in big endian */

/* Restore net_ctrl */
macb_writel(bp, NCR, ncr);

if (bp->dev->features & NETIF_F_HW_CSUM)
dmacfg |= GEM_BIT(TXCOEN);
else
Expand Down Expand Up @@ -1897,19 +1929,19 @@ static int macb_change_mtu(struct net_device *dev, int new_mtu)

static void gem_update_stats(struct macb *bp)
{
int i;
unsigned int i;
u32 *p = &bp->hw_stats.gem.tx_octets_31_0;

for (i = 0; i < GEM_STATS_LEN; ++i, ++p) {
u32 offset = gem_statistics[i].offset;
u64 val = readl_relaxed(bp->regs + offset);
u64 val = bp->macb_reg_readl(bp, offset);

bp->ethtool_stats[i] += val;
*p += val;

if (offset == GEM_OCTTXL || offset == GEM_OCTRXL) {
/* Add GEM_OCTTXH, GEM_OCTRXH */
val = readl_relaxed(bp->regs + offset + 4);
val = bp->macb_reg_readl(bp, offset + 4);
bp->ethtool_stats[i] += ((u64)val) << 32;
*(++p) += val;
}
Expand Down Expand Up @@ -1976,7 +2008,7 @@ static int gem_get_sset_count(struct net_device *dev, int sset)

static void gem_get_ethtool_strings(struct net_device *dev, u32 sset, u8 *p)
{
int i;
unsigned int i;

switch (sset) {
case ETH_SS_STATS:
Expand Down Expand Up @@ -2190,7 +2222,7 @@ static void macb_configure_caps(struct macb *bp, const struct macb_config *dt_co
if (dt_conf)
bp->caps = dt_conf->caps;

if (macb_is_gem_hw(bp->regs)) {
if (hw_is_gem(bp->regs, bp->native_io)) {
bp->caps |= MACB_CAPS_MACB_IS_GEM;

dcfg = gem_readl(bp, DCFG1);
Expand All @@ -2201,10 +2233,11 @@ static void macb_configure_caps(struct macb *bp, const struct macb_config *dt_co
bp->caps |= MACB_CAPS_FIFO_MODE;
}

netdev_dbg(bp->dev, "Cadence caps 0x%08x\n", bp->caps);
dev_dbg(&bp->pdev->dev, "Cadence caps 0x%08x\n", bp->caps);
}

static void macb_probe_queues(void __iomem *mem,
bool native_io,
unsigned int *queue_mask,
unsigned int *num_queues)
{
Expand All @@ -2219,7 +2252,7 @@ static void macb_probe_queues(void __iomem *mem,
* we are early in the probe process and don't have the
* MACB_CAPS_MACB_IS_GEM flag positioned
*/
if (!macb_is_gem_hw(mem))
if (!hw_is_gem(mem, native_io))
return;

/* bit 0 is never set but queue 0 always exists */
Expand Down Expand Up @@ -2786,6 +2819,7 @@ static int macb_probe(struct platform_device *pdev)
struct clk *pclk, *hclk, *tx_clk;
unsigned int queue_mask, num_queues;
struct macb_platform_data *pdata;
bool native_io;
struct phy_device *phydev;
struct net_device *dev;
struct resource *regs;
Expand All @@ -2794,6 +2828,11 @@ static int macb_probe(struct platform_device *pdev)
struct macb *bp;
int err;

regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
mem = devm_ioremap_resource(&pdev->dev, regs);
if (IS_ERR(mem))
return PTR_ERR(mem);

if (np) {
const struct of_device_id *match;

Expand All @@ -2809,14 +2848,9 @@ static int macb_probe(struct platform_device *pdev)
if (err)
return err;

regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
mem = devm_ioremap_resource(&pdev->dev, regs);
if (IS_ERR(mem)) {
err = PTR_ERR(mem);
goto err_disable_clocks;
}
native_io = hw_is_native_io(mem);

macb_probe_queues(mem, &queue_mask, &num_queues);
macb_probe_queues(mem, native_io, &queue_mask, &num_queues);
dev = alloc_etherdev_mq(sizeof(*bp), num_queues);
if (!dev) {
err = -ENOMEM;
Expand All @@ -2831,16 +2865,23 @@ static int macb_probe(struct platform_device *pdev)
bp->pdev = pdev;
bp->dev = dev;
bp->regs = mem;
bp->native_io = native_io;
if (native_io) {
bp->macb_reg_readl = hw_readl_native;
bp->macb_reg_writel = hw_writel_native;
} else {
bp->macb_reg_readl = hw_readl;
bp->macb_reg_writel = hw_writel;
}
bp->num_queues = num_queues;
bp->queue_mask = queue_mask;
if (macb_config)
bp->dma_burst_length = macb_config->dma_burst_length;
bp->pclk = pclk;
bp->hclk = hclk;
bp->tx_clk = tx_clk;
if (macb_config->jumbo_max_len) {
if (macb_config)
bp->jumbo_max_len = macb_config->jumbo_max_len;
}

spin_lock_init(&bp->lock);

Expand Down
34 changes: 14 additions & 20 deletions drivers/net/ethernet/cadence/macb.h
Original file line number Diff line number Diff line change
Expand Up @@ -429,18 +429,12 @@
| GEM_BF(name, value))

/* Register access macros */
#define macb_readl(port,reg) \
readl_relaxed((port)->regs + MACB_##reg)
#define macb_writel(port,reg,value) \
writel_relaxed((value), (port)->regs + MACB_##reg)
#define gem_readl(port, reg) \
readl_relaxed((port)->regs + GEM_##reg)
#define gem_writel(port, reg, value) \
writel_relaxed((value), (port)->regs + GEM_##reg)
#define queue_readl(queue, reg) \
readl_relaxed((queue)->bp->regs + (queue)->reg)
#define queue_writel(queue, reg, value) \
writel_relaxed((value), (queue)->bp->regs + (queue)->reg)
#define macb_readl(port, reg) (port)->macb_reg_readl((port), MACB_##reg)
#define macb_writel(port, reg, value) (port)->macb_reg_writel((port), MACB_##reg, (value))
#define gem_readl(port, reg) (port)->macb_reg_readl((port), GEM_##reg)
#define gem_writel(port, reg, value) (port)->macb_reg_writel((port), GEM_##reg, (value))
#define queue_readl(queue, reg) (queue)->bp->macb_reg_readl((queue)->bp, (queue)->reg)
#define queue_writel(queue, reg, value) (queue)->bp->macb_reg_writel((queue)->bp, (queue)->reg, (value))

/* Conditional GEM/MACB macros. These perform the operation to the correct
* register dependent on whether the device is a GEM or a MACB. For registers
Expand Down Expand Up @@ -785,6 +779,11 @@ struct macb_queue {

struct macb {
void __iomem *regs;
bool native_io;

/* hardware IO accessors */
u32 (*macb_reg_readl)(struct macb *bp, int offset);
void (*macb_reg_writel)(struct macb *bp, int offset, u32 value);

unsigned int rx_tail;
unsigned int rx_prepared_head;
Expand Down Expand Up @@ -817,9 +816,9 @@ struct macb {

struct mii_bus *mii_bus;
struct phy_device *phy_dev;
unsigned int link;
unsigned int speed;
unsigned int duplex;
int link;
int speed;
int duplex;

u32 caps;
unsigned int dma_burst_length;
Expand All @@ -843,9 +842,4 @@ static inline bool macb_is_gem(struct macb *bp)
return !!(bp->caps & MACB_CAPS_MACB_IS_GEM);
}

static inline bool macb_is_gem_hw(void __iomem *addr)
{
return !!(MACB_BFEXT(IDNUM, readl_relaxed(addr + MACB_MID)) >= 0x2);
}

#endif /* _MACB_H */
12 changes: 11 additions & 1 deletion drivers/net/ethernet/cavium/thunder/nic.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,15 @@
*/
#define NICPF_CLK_PER_INT_TICK 2

/* Time to wait before we decide that a SQ is stuck.
*
* Since both pkt rx and tx notifications are done with same CQ,
* when packets are being received at very high rate (eg: L2 forwarding)
* then freeing transmitted skbs will be delayed and watchdog
* will kick in, resetting interface. Hence keeping this value high.
*/
#define NICVF_TX_TIMEOUT (50 * HZ)

struct nicvf_cq_poll {
u8 cq_idx; /* Completion queue index */
struct napi_struct napi;
Expand Down Expand Up @@ -216,8 +225,9 @@ struct nicvf_drv_stats {
/* Tx */
u64 tx_frames_ok;
u64 tx_drops;
u64 tx_busy;
u64 tx_tso;
u64 txq_stop;
u64 txq_wake;
};

struct nicvf {
Expand Down
Loading

0 comments on commit 7c764ce

Please sign in to comment.