From c29e94c004c19541efabb0a3dc8e66b021d91606 Mon Sep 17 00:00:00 2001 From: Sepherosa Ziehau Date: Wed, 4 Sep 2013 16:30:29 +0800 Subject: [PATCH] em: Move max_frame_size from softc to HAL data struct It is needed to make I217 link status detection work --- sys/dev/netif/em/if_em.c | 21 ++++++++++++--------- sys/dev/netif/em/if_em.h | 1 - 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/sys/dev/netif/em/if_em.c b/sys/dev/netif/em/if_em.c index 1ad135d7a3..fe9a1d0fbc 100644 --- a/sys/dev/netif/em/if_em.c +++ b/sys/dev/netif/em/if_em.c @@ -573,7 +573,8 @@ em_attach(device_t dev) } /* Set the frame limits assuming standard ethernet sized frames. */ - adapter->max_frame_size = ETHERMTU + ETHER_HDR_LEN + ETHER_CRC_LEN; + adapter->hw.mac.max_frame_size = + ETHERMTU + ETHER_HDR_LEN + ETHER_CRC_LEN; adapter->min_frame_size = ETH_ZLEN + ETHER_CRC_LEN; /* This controls when hardware reports transmit completion status. */ @@ -1099,7 +1100,7 @@ em_ioctl(struct ifnet *ifp, u_long command, caddr_t data, struct ucred *cr) } ifp->if_mtu = ifr->ifr_mtu; - adapter->max_frame_size = + adapter->hw.mac.max_frame_size = ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN; if (ifp->if_flags & IFF_RUNNING) @@ -2332,7 +2333,7 @@ em_reset(struct adapter *adapter) switch (adapter->hw.mac.type) { case e1000_82547: case e1000_82547_rev_2: /* 82547: Total Packet Buffer is 40K */ - if (adapter->max_frame_size > 8192) + if (adapter->hw.mac.max_frame_size > 8192) pba = E1000_PBA_22K; /* 22K for Rx, 18K for Tx */ else pba = E1000_PBA_30K; /* 30K for Rx, 10K for Tx */ @@ -2376,7 +2377,7 @@ em_reset(struct adapter *adapter) default: /* Devices before 82547 had a Packet Buffer of 64K. */ - if (adapter->max_frame_size > 8192) + if (adapter->hw.mac.max_frame_size > 8192) pba = E1000_PBA_40K; /* 40K for Rx, 24K for Tx */ else pba = E1000_PBA_48K; /* 48K for Rx, 16K for Tx */ @@ -2401,7 +2402,7 @@ em_reset(struct adapter *adapter) (E1000_READ_REG(&adapter->hw, E1000_PBA) & 0xffff) << 10; adapter->hw.fc.high_water = rx_buffer_size - - roundup2(adapter->max_frame_size, 1024); + roundup2(adapter->hw.mac.max_frame_size, 1024); adapter->hw.fc.low_water = adapter->hw.fc.high_water - 1500; if (adapter->hw.mac.type == e1000_80003es2lan) @@ -3083,7 +3084,7 @@ em_newbuf(struct adapter *adapter, int i, int init) } m->m_len = m->m_pkthdr.len = MCLBYTES; - if (adapter->max_frame_size <= MCLBYTES - ETHER_ALIGN) + if (adapter->hw.mac.max_frame_size <= MCLBYTES - ETHER_ALIGN) m_adj(m, ETHER_ALIGN); error = bus_dmamap_load_mbuf_segment(adapter->rxtag, @@ -3410,11 +3411,12 @@ em_rxeof(struct adapter *adapter, int count) last_byte = *(mtod(mp, caddr_t) + desc_len - 1); if (TBI_ACCEPT(&adapter->hw, status, current_desc->errors, pkt_len, last_byte, - adapter->min_frame_size, adapter->max_frame_size)) { + adapter->min_frame_size, + adapter->hw.mac.max_frame_size)) { e1000_tbi_adjust_stats_82543(&adapter->hw, &adapter->stats, pkt_len, adapter->hw.mac.addr, - adapter->max_frame_size); + adapter->hw.mac.max_frame_size); if (len > 0) len--; } else { @@ -3483,7 +3485,8 @@ discard: mp->m_len = mp->m_pkthdr.len = MCLBYTES; mp->m_data = mp->m_ext.ext_buf; mp->m_next = NULL; - if (adapter->max_frame_size <= (MCLBYTES - ETHER_ALIGN)) + if (adapter->hw.mac.max_frame_size <= + (MCLBYTES - ETHER_ALIGN)) m_adj(mp, ETHER_ALIGN); #endif if (adapter->fmp != NULL) { diff --git a/sys/dev/netif/em/if_em.h b/sys/dev/netif/em/if_em.h index b4dff954c1..a453142ceb 100644 --- a/sys/dev/netif/em/if_em.h +++ b/sys/dev/netif/em/if_em.h @@ -279,7 +279,6 @@ struct adapter { struct callout timer; struct callout tx_fifo_timer; int if_flags; - int max_frame_size; int min_frame_size; /* WOL register value */ -- 2.41.0