[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CACna6rxeBNuSq8OJTBH1Yr75o79q9CDqc2JTW4=kEk+HQt5JRg@mail.gmail.com>
Date: Mon, 13 Apr 2015 16:21:48 +0200
From: Rafał Miłecki <zajec5@...il.com>
To: Felix Fietkau <nbd@...nwrt.org>
Cc: Network Development <netdev@...r.kernel.org>,
Hauke Mehrtens <hauke@...ke-m.de>
Subject: Re: [PATCH v4 1/9] bgmac: simplify tx ring index handling
On 13 April 2015 at 15:52, Felix Fietkau <nbd@...nwrt.org> wrote:
> Keep incrementing ring->start and ring->end instead of pointing it to
> the actual ring slot entry. This simplifies the calculation of the
> number of free slots.
You're much more experienced in network stuff, so it's likely me not
understanding some stuff & needing help.
> @@ -158,13 +157,7 @@ static netdev_tx_t bgmac_dma_tx_add(struct bgmac *bgmac,
> skb_checksum_help(skb);
>
> nr_frags = skb_shinfo(skb)->nr_frags;
> -
> - if (ring->start <= ring->end)
> - free_slots = ring->start - ring->end + BGMAC_TX_RING_SLOTS;
> - else
> - free_slots = ring->start - ring->end;
> -
> - if (free_slots <= nr_frags + 1) {
> + if (ring->end - ring->start + nr_frags + 1 >= BGMAC_TX_RING_SLOTS) {
> bgmac_err(bgmac, "TX ring is full, queue should be stopped!\n");
> netif_stop_queue(net_dev);
> return NETDEV_TX_BUSY;
How is this going to work with ring->end lower than ring->start? Let's
say you have 2 empty slots at the end of ring and 2 empty slots at the
beginning. In total 4 free slots. Doing ring->end - ring->start will
give you some big negative number (depending on the ring size), won't
it?
> @@ -284,10 +276,8 @@ static void bgmac_dma_tx_free(struct bgmac *bgmac, struct bgmac_dma_ring *ring)
> slot->skb = NULL;
> }
>
> -next:
> slot->dma_addr = 0;
> - if (++ring->start >= BGMAC_TX_RING_SLOTS)
> - ring->start = 0;
> + ring->start++;
> freed = true;
> }
>
Do I understand correctly you're using u32 overflow here? Is this
OK/allowed in kernel to knowingly use overflows?
> diff --git a/drivers/net/ethernet/broadcom/bgmac.h b/drivers/net/ethernet/broadcom/bgmac.h
> index 3ad965f..5a198d5 100644
> --- a/drivers/net/ethernet/broadcom/bgmac.h
> +++ b/drivers/net/ethernet/broadcom/bgmac.h
> @@ -414,10 +414,10 @@ enum bgmac_dma_ring_type {
> * empty.
> */
> struct bgmac_dma_ring {
> - u16 num_slots;
> - u16 start;
> - u16 end;
> + u32 start;
> + u32 end;
>
> + u16 num_slots;
> u16 mmio_base;
> struct bgmac_dma_desc *cpu_base;
> dma_addr_t dma_base;
Any reason for u32 instead of u16?
--
Rafał
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists