From 88219a2b96ba392631f207e0fb194c88127ff764 Mon Sep 17 00:00:00 2001 From: Chong Qiao Date: Wed, 8 Apr 2020 15:17:54 +0800 Subject: [PATCH] fix ngbe, free iob after packet sent. Change-Id: I70e826d8782b8697fdcbcec5dd04366021d185d6 Signed-off-by: Chong Qiao --- sys/dev/pci/ngbe/ngbe_pmon_head.h | 13 ++++++++----- sys/dev/pci/ngbe/ngbe_pmon_tail.h | 5 +++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/sys/dev/pci/ngbe/ngbe_pmon_head.h b/sys/dev/pci/ngbe/ngbe_pmon_head.h index 366a3009..18208368 100644 --- a/sys/dev/pci/ngbe/ngbe_pmon_head.h +++ b/sys/dev/pci/ngbe/ngbe_pmon_head.h @@ -200,6 +200,7 @@ struct net_device int (*open)(struct net_device *ndev); int (*stop)(struct net_device *ndev); int (*hard_start_xmit)(struct sk_buff *skb, struct net_device *ndev); + struct io_buffer *iob_tx[EMERALD_NUM_TX_DESC]; }; #define alloc_etherdev(len) container_of(pci, struct net_device, pcidev) @@ -246,12 +247,12 @@ int len; char *data; }; -int iob_len(struct io_buffer *iob) +static int iob_len(struct io_buffer *iob) { return iob->len; } -struct io_buffer *alloc_iob(int len) +static struct io_buffer *alloc_iob(int len) { struct io_buffer *iobuf = malloc(sizeof(struct io_buffer), M_DEVBUF, M_DONTWAIT); iobuf->data = malloc(len, M_DEVBUF, M_DONTWAIT); @@ -259,13 +260,13 @@ struct io_buffer *alloc_iob(int len) return iobuf; } -int iob_put(struct io_buffer *iob, int len) +static int iob_put(struct io_buffer *iob, int len) { iob->len = len; return 0; } -int free_iob(struct io_buffer *iob) +static int free_iob(struct io_buffer *iob) { free(iob->data, M_DEVBUF); free(iob,M_DEVBUF); @@ -407,7 +408,9 @@ static void *malloc_dma(size_t size, size_t size1) buf = malloc(size, M_DEVBUF, M_DONTWAIT); return (void *)buf; } -#define netdev_tx_complete_next(...) +#define netdev_tx_complete_next(netdev) do { \ + free_iob(netdev->iob_tx[tx_idx]); \ +} while(0) #define cpu_to_le64(x) (x) #define cpu_to_le16(x) (x) static inline netdev_link_up( struct net_device *netdev) diff --git a/sys/dev/pci/ngbe/ngbe_pmon_tail.h b/sys/dev/pci/ngbe/ngbe_pmon_tail.h index 721c2c44..c45347e8 100644 --- a/sys/dev/pci/ngbe/ngbe_pmon_tail.h +++ b/sys/dev/pci/ngbe/ngbe_pmon_tail.h @@ -155,6 +155,11 @@ static void ngbe_start(struct ifnet *ifp) iob->len = mb_head->m_pkthdr.len; if (emerald_transmit (sc, iob) < 0) free_iob(iob); + else { + struct emerald_nic *emerald = sc->priv; + int tx_idx = ( (emerald->tx.prod - 1) % EMERALD_NUM_TX_DESC ); + sc->iob_tx[tx_idx] = iob; + } m_freem(mb_head); }