From da4fe422997acc2e874db7db528aa6856b00c9fb Mon Sep 17 00:00:00 2001 From: Sepherosa Ziehau Date: Sun, 8 Jul 2012 13:28:43 +0800 Subject: [PATCH] bge: Cosmetic cleanup --- sys/dev/netif/bge/if_bge.c | 17 +++++---- sys/dev/netif/bge/if_bgereg.h | 72 ++++++++++++++--------------------- 2 files changed, 39 insertions(+), 50 deletions(-) diff --git a/sys/dev/netif/bge/if_bge.c b/sys/dev/netif/bge/if_bge.c index 0e53bf26a1..9f2c49e244 100644 --- a/sys/dev/netif/bge/if_bge.c +++ b/sys/dev/netif/bge/if_bge.c @@ -112,9 +112,12 @@ #include "miibus_if.h" #define BGE_CSUM_FEATURES (CSUM_IP | CSUM_TCP) -#define BGE_MIN_FRAME 60 -static const struct bge_type bge_devs[] = { +static const struct bge_type { + uint16_t bge_vid; + uint16_t bge_did; + char *bge_name; +} bge_devs[] = { { PCI_VENDOR_3COM, PCI_PRODUCT_3COM_3C996, "3COM 3C996 Gigabit Ethernet" }, @@ -2865,7 +2868,7 @@ bge_rxeof(struct bge_softc *sc, uint16_t rx_prod) m->m_pkthdr.csum_flags |= CSUM_IP_VALID; } if ((cur_rx->bge_flags & BGE_RXBDFLAG_TCP_UDP_CSUM) && - m->m_pkthdr.len >= BGE_MIN_FRAME) { + m->m_pkthdr.len >= BGE_MIN_FRAMELEN) { m->m_pkthdr.csum_data = cur_rx->bge_tcp_udp_csum; m->m_pkthdr.csum_flags |= @@ -3212,8 +3215,8 @@ bge_encap(struct bge_softc *sc, struct mbuf **m_head0, uint32_t *txidx) maxsegs = BGE_NSEG_NEW; /* - * Pad outbound frame to BGE_MIN_FRAME for an unusual reason. - * The bge hardware will pad out Tx runts to BGE_MIN_FRAME, + * Pad outbound frame to BGE_MIN_FRAMELEN for an unusual reason. + * The bge hardware will pad out Tx runts to BGE_MIN_FRAMELEN, * but when such padded frames employ the bge IP/TCP checksum * offload, the hardware checksum assist gives incorrect results * (possibly from incorporating its own padding into the UDP/TCP @@ -3221,8 +3224,8 @@ bge_encap(struct bge_softc *sc, struct mbuf **m_head0, uint32_t *txidx) * onboard checksum comes out correct. */ if ((csum_flags & BGE_TXBDFLAG_TCP_UDP_CSUM) && - m_head->m_pkthdr.len < BGE_MIN_FRAME) { - error = m_devpad(m_head, BGE_MIN_FRAME); + m_head->m_pkthdr.len < BGE_MIN_FRAMELEN) { + error = m_devpad(m_head, BGE_MIN_FRAMELEN); if (error) goto back; } diff --git a/sys/dev/netif/bge/if_bgereg.h b/sys/dev/netif/bge/if_bgereg.h index cd081a85ac..fc70507ed8 100644 --- a/sys/dev/netif/bge/if_bgereg.h +++ b/sys/dev/netif/bge/if_bgereg.h @@ -1931,19 +1931,19 @@ #define BGE_MEMWIN_END 0x0000FFFF -#define BGE_MEMWIN_READ(sc, x, val) \ - do { \ - pci_write_config(sc->bge_dev, BGE_PCI_MEMWIN_BASEADDR, \ - (0xFFFF0000 & x), 4); \ - val = CSR_READ_4(sc, BGE_MEMWIN_START + (x & 0xFFFF)); \ - } while(0) - -#define BGE_MEMWIN_WRITE(sc, x, val) \ - do { \ - pci_write_config(sc->bge_dev, BGE_PCI_MEMWIN_BASEADDR, \ - (0xFFFF0000 & x), 4); \ - CSR_WRITE_4(sc, BGE_MEMWIN_START + (x & 0xFFFF), val); \ - } while(0) +#define BGE_MEMWIN_READ(sc, x, val) \ +do { \ + pci_write_config(sc->bge_dev, BGE_PCI_MEMWIN_BASEADDR, \ + (0xFFFF0000 & x), 4); \ + val = CSR_READ_4(sc, BGE_MEMWIN_START + (x & 0xFFFF)); \ +} while(0) + +#define BGE_MEMWIN_WRITE(sc, x, val) \ +do { \ + pci_write_config(sc->bge_dev, BGE_PCI_MEMWIN_BASEADDR, \ + (0xFFFF0000 & x), 4); \ + CSR_WRITE_4(sc, BGE_MEMWIN_START + (x & 0xFFFF), val); \ +} while(0) /* * This magic number is written to the firmware mailbox at 0xb50 @@ -1959,14 +1959,14 @@ typedef struct { uint32_t bge_addr_lo; } bge_hostaddr; -#define BGE_HOSTADDR(x, y) \ - do { \ - (x).bge_addr_lo = ((uint64_t) (y) & 0xffffffff); \ - (x).bge_addr_hi = ((uint64_t) (y) >> 32); \ - } while(0) +#define BGE_HOSTADDR(x, y) \ +do { \ + (x).bge_addr_lo = ((uint64_t)(y) & 0xffffffff); \ + (x).bge_addr_hi = ((uint64_t)(y) >> 32); \ +} while(0) -#define BGE_ADDR_LO(y) ((uint64_t) (y) & 0xFFFFFFFF) -#define BGE_ADDR_HI(y) ((uint64_t) (y) >> 32) +#define BGE_ADDR_LO(y) ((uint64_t)(y) & 0xFFFFFFFF) +#define BGE_ADDR_HI(y) ((uint64_t)(y) >> 32) /* Ring control block structure */ struct bge_rcb { @@ -2084,9 +2084,6 @@ struct bge_status_block { struct bge_sts_idx bge_idx[16]; }; -#define BGE_TX_CONSIDX(x, i) x->bge_idx[i].bge_tx_considx -#define BGE_RX_PRODIDX(x, i) x->bge_idx[i].bge_rx_prodidx - #define BGE_STATFLAG_UPDATED 0x00000001 #define BGE_STATFLAG_LINKSTATE_CHANGED 0x00000002 #define BGE_STATFLAG_ERROR 0x00000004 @@ -2322,19 +2319,19 @@ struct bge_gib { * boundary. */ -#define ETHER_ALIGN 2 - -#define BGE_FRAMELEN 1518 +#define BGE_MIN_FRAMELEN 60 #define BGE_MAX_FRAMELEN 1536 #define BGE_JUMBO_FRAMELEN 9018 #define BGE_JUMBO_MTU (BGE_JUMBO_FRAMELEN-ETHER_HDR_LEN-ETHER_CRC_LEN) -#define BGE_PAGE_SIZE PAGE_SIZE -#define BGE_MIN_FRAMELEN 60 + +#define BGE_TIMEOUT 5000 +#define BGE_FIRMWARE_TIMEOUT 20000 +#define BGE_TXCONS_UNSET 0xFFFF /* impossible value */ /* * Other utility macros. */ -#define BGE_INC(x, y) (x) = (x + 1) % y +#define BGE_INC(x, y) (x) = ((x) + 1) % (y) /* * Register access macros. The Tigon always uses memory mapped register @@ -2423,11 +2420,10 @@ struct bge_ring_data { #define BGE_TX_RING_SZ \ (sizeof(struct bge_tx_bd) * BGE_TX_RING_CNT) #define BGE_RX_RTN_RING_SZ(x) \ - (sizeof(struct bge_rx_bd) * x->bge_return_ring_cnt) + (sizeof(struct bge_rx_bd) * (x)->bge_return_ring_cnt) -#define BGE_STATUS_BLK_SZ sizeof (struct bge_status_block) - -#define BGE_STATS_SZ sizeof (struct bge_stats) +#define BGE_STATUS_BLK_SZ sizeof(struct bge_status_block) +#define BGE_STATS_SZ sizeof(struct bge_stats) struct bge_rxchain { struct mbuf *bge_mbuf; @@ -2467,16 +2463,6 @@ struct bge_chain_data { struct bge_jslot bge_jslots[BGE_JSLOTS]; }; -struct bge_type { - uint16_t bge_vid; - uint16_t bge_did; - char *bge_name; -}; - -#define BGE_TIMEOUT 5000 -#define BGE_FIRMWARE_TIMEOUT 20000 -#define BGE_TXCONS_UNSET 0xFFFF /* impossible value */ - struct bge_softc { struct arpcom arpcom; /* interface info */ device_t bge_dev; -- 2.41.0