summaryrefslogtreecommitdiffstats
path: root/sys/dev/ti/if_tireg.h
diff options
context:
space:
mode:
authoryongari <yongari@FreeBSD.org>2005-12-28 02:57:19 +0000
committeryongari <yongari@FreeBSD.org>2005-12-28 02:57:19 +0000
commit89a31d4bdccfaa17a3c67fa682c19a9fe923b711 (patch)
tree1f05bd3ead51f2c76b45e3036fbe14ecba5ec933 /sys/dev/ti/if_tireg.h
parent6617f46a01d366707c3dd0b9e728808b755b5fc2 (diff)
downloadFreeBSD-src-89a31d4bdccfaa17a3c67fa682c19a9fe923b711.zip
FreeBSD-src-89a31d4bdccfaa17a3c67fa682c19a9fe923b711.tar.gz
Bring big-endian architecture support for ti(4).
. remove unnecessay header files after Scott's bus_dma(9) commit. . remove global variable tis which was introduced at the time of zero_copy(9) changes. The variable tis was not used at all. The same applyes to ti_links in softc so axe it. . deregister variables. . axe ti_vhandle and switch to use explicit register access for accessing NIC local memory. Creates three variants of ti_mem to read/write NIC local memory(ti_mem_read, ti_mem_write) and clearing NIC local memory(ti_mem_zero). This greatly enhances code readability and have ti(4) drop using shared memory scheme for Tigon 1. As Tigon 1 switched to use explicit register access for Tx, axe ti_tx_ring_nic/ti_cmd_ring in softc.(Tigon 2 used to host ring scheme which means there is no need to access NIC local memory via register access for Tx and NIC would DMA the modified Tx rings into its local memory.) [1] . introduce new macro TI_EVENT_*/TI_CMD_* to handle NIC envent/command. Instead of using bit fields assginment for accessing the event, use shift operations to set/get it. [1] . add additional check for valid DMA tags in ti_free_dmamaps(). . add missing bus_dmamap_sync/bus_dmamap_unload in ti_free_*_ring_*. . fix locking nits(MTX_RECURSE mutex) and make ti(4) MPSAFE. . change data type of ti_rdata_phys to bus_addr_t and don't blindly cast to uint32_t. . rearrange detach path and make ti(4) survive during device detach. . for Tigon 1, use explicit register access for checking Tx descriptors in ti_encap()/ti_txeof(). [1] . properly call bus_dmamap_sync(9) for updating statistics. . remove extra semicolon in ti_encap() . rewrite loading MAC address to work on strict-alignment architectures. . move TI_RD_OFF macro to if_tireg.h . axe ETHER_ALIGN as it's already defined in <net/ethernet.h>. . make macros immuine from expansion by adding parenthesis and do-while. . remove alpha specific hack as vtophys(9) is no longer used in ti(4) after Scott's bus_dma(9) fix. Reviewed by: scottl Obtained from: OpenBSD [1]
Diffstat (limited to 'sys/dev/ti/if_tireg.h')
-rw-r--r--sys/dev/ti/if_tireg.h113
1 files changed, 47 insertions, 66 deletions
diff --git a/sys/dev/ti/if_tireg.h b/sys/dev/ti/if_tireg.h
index bbb67b4..2fb441e 100644
--- a/sys/dev/ti/if_tireg.h
+++ b/sys/dev/ti/if_tireg.h
@@ -319,7 +319,7 @@
#define TI_GCR_RXRETURNCONS_IDX 0x680
#define TI_GCR_CMDRING 0x700
-#define TI_GCR_NIC_ADDR(x) (x - TI_GCR_BASE);
+#define TI_GCR_NIC_ADDR(x) (x - TI_GCR_BASE)
/*
* Local memory window. The local memory window is a 2K shared
@@ -683,8 +683,6 @@ struct ti_tx_desc {
* boundary.
*/
-#define ETHER_ALIGN 2
-
#define TI_FRAMELEN 1518
#define TI_JUMBO_FRAMELEN 9018
#define TI_JUMBO_MTU (TI_JUMBO_FRAMELEN-ETHER_HDR_LEN-ETHER_CRC_LEN)
@@ -755,17 +753,13 @@ struct ti_tx_desc {
* Tigon command structure.
*/
struct ti_cmd_desc {
-#if BYTE_ORDER == BIG_ENDIAN
- u_int32_t ti_cmd:8;
- u_int32_t ti_code:12;
- u_int32_t ti_idx:12;
-#else
- u_int32_t ti_idx:12;
- u_int32_t ti_code:12;
- u_int32_t ti_cmd:8;
-#endif
+ u_int32_t ti_cmdx;
};
+#define TI_CMD_CMD(cmd) (((((cmd)->ti_cmdx)) >> 24) & 0xff)
+#define TI_CMD_CODE(cmd) (((((cmd)->ti_cmdx)) >> 12) & 0xfff)
+#define TI_CMD_IDX(cmd) ((((cmd)->ti_cmdx)) & 0xfff)
+
#define TI_CMD_HOST_STATE 0x01
#define TI_CMD_CODE_STACK_UP 0x01
#define TI_CMD_CODE_STACK_DOWN 0x02
@@ -812,57 +806,50 @@ struct ti_cmd_desc {
* Utility macros to make issuing commands a little simpler. Assumes
* that 'sc' and 'cmd' are in local scope.
*/
-#define TI_DO_CMD(x, y, z) \
- cmd.ti_cmd = (x); \
- cmd.ti_code = (y); \
- cmd.ti_idx = (z); \
- ti_cmd(sc, &cmd);
-
-#define TI_DO_CMD_EXT(x, y, z, v, w) \
- cmd.ti_cmd = (x); \
- cmd.ti_code = (y); \
- cmd.ti_idx = (z); \
- ti_cmd_ext(sc, &cmd, (v), (w));
+#define TI_DO_CMD(x, y, z) do { \
+ cmd.ti_cmdx = (((x) << 24) | ((y) << 12) | ((z))); \
+ ti_cmd(sc, &cmd); \
+} while(0)
+
+#define TI_DO_CMD_EXT(x, y, z, v, w) do { \
+ cmd.ti_cmdx = (((x) << 24) | ((y) << 12) | ((z))); \
+ ti_cmd_ext(sc, &cmd, (v), (w)); \
+} while(0)
/*
* Other utility macros.
*/
-#define TI_INC(x, y) (x) = (x + 1) % y
+#define TI_INC(x, y) (x) = ((x) + 1) % y
-#define TI_UPDATE_JUMBOPROD(x, y) \
- if (x->ti_hwrev == TI_HWREV_TIGON) { \
- TI_DO_CMD(TI_CMD_SET_RX_JUMBO_PROD_IDX, 0, y); \
- } else { \
- CSR_WRITE_4(x, TI_MB_JUMBORXPROD_IDX, y); \
- }
+#define TI_UPDATE_JUMBOPROD(x, y) do { \
+ if ((x)->ti_hwrev == TI_HWREV_TIGON) \
+ TI_DO_CMD(TI_CMD_SET_RX_JUMBO_PROD_IDX, 0, (y)); \
+ else \
+ CSR_WRITE_4((x), TI_MB_JUMBORXPROD_IDX, (y)); \
+} while(0)
#define TI_UPDATE_MINIPROD(x, y) \
- CSR_WRITE_4(x, TI_MB_MINIRXPROD_IDX, y);
-
-#define TI_UPDATE_STDPROD(x, y) \
- if (x->ti_hwrev == TI_HWREV_TIGON) { \
- TI_DO_CMD(TI_CMD_SET_RX_PROD_IDX, 0, y); \
- } else { \
- CSR_WRITE_4(x, TI_MB_STDRXPROD_IDX, y); \
- }
+ CSR_WRITE_4((x), TI_MB_MINIRXPROD_IDX, (y))
+#define TI_UPDATE_STDPROD(x, y) do { \
+ if ((x)->ti_hwrev == TI_HWREV_TIGON) \
+ TI_DO_CMD(TI_CMD_SET_RX_PROD_IDX, 0, (y)); \
+ else \
+ CSR_WRITE_4((x), TI_MB_STDRXPROD_IDX, (y)); \
+} while(0)
/*
* Tigon event structure.
*/
struct ti_event_desc {
-#if BYTE_ORDER == BIG_ENDIAN
- u_int32_t ti_event:8;
- u_int32_t ti_code:12;
- u_int32_t ti_idx:12;
-#else
- u_int32_t ti_idx:12;
- u_int32_t ti_code:12;
- u_int32_t ti_event:8;
-#endif
+ u_int32_t ti_eventx;
u_int32_t ti_rsvd;
};
+#define TI_EVENT_EVENT(e) (((((e)->ti_eventx)) >> 24) & 0xff)
+#define TI_EVENT_CODE(e) (((((e)->ti_eventx)) >> 12) & 0xfff)
+#define TI_EVENT_IDX(e) (((((e)->ti_eventx))) & 0xfff)
+
/*
* Tigon events.
*/
@@ -890,15 +877,15 @@ struct ti_event_desc {
*/
#define CSR_WRITE_4(sc, reg, val) \
- bus_space_write_4(sc->ti_btag, sc->ti_bhandle, reg, val)
+ bus_space_write_4((sc)->ti_btag, (sc)->ti_bhandle, (reg), (val))
#define CSR_READ_4(sc, reg) \
- bus_space_read_4(sc->ti_btag, sc->ti_bhandle, reg)
+ bus_space_read_4((sc)->ti_btag, (sc)->ti_bhandle, (reg))
#define TI_SETBIT(sc, reg, x) \
- CSR_WRITE_4(sc, reg, (CSR_READ_4(sc, reg) | x))
+ CSR_WRITE_4((sc), (reg), (CSR_READ_4((sc), (reg)) | (x)))
#define TI_CLRBIT(sc, reg, x) \
- CSR_WRITE_4(sc, reg, (CSR_READ_4(sc, reg) & ~x))
+ CSR_WRITE_4((sc), (reg), (CSR_READ_4((sc), (reg)) & ~(x)))
/*
* Memory management stuff. Note: the SSLOTS, MSLOTS and JSLOTS
@@ -944,11 +931,11 @@ struct ti_ring_data {
u_int32_t ti_pad1[6];
struct ti_producer ti_tx_considx_r;
u_int32_t ti_pad2[6];
- struct ti_tx_desc *ti_tx_ring_nic;/* pointer to shared mem */
- struct ti_cmd_desc *ti_cmd_ring; /* pointer to shared mem */
struct ti_gib ti_info;
};
+#define TI_RD_OFF(x) offsetof(struct ti_ring_data, x)
+
/*
* Mbuf pointers. We need these to keep track of the virtual addresses
* of our mbuf chains since we can only convert from physical to virtual,
@@ -996,11 +983,9 @@ typedef enum {
} ti_flag_vals;
struct ti_softc {
- STAILQ_ENTRY(ti_softc) ti_links;
device_t ti_dev;
struct ifnet *ti_ifp;
bus_space_handle_t ti_bhandle;
- vm_offset_t ti_vhandle;
bus_space_tag_t ti_btag;
void *ti_intrhand;
struct resource *ti_irq;
@@ -1018,7 +1003,7 @@ struct ti_softc {
bus_dma_tag_t ti_mbufrx_dmat;
bus_dma_tag_t ti_rdata_dmat;
bus_dmamap_t ti_rdata_dmamap;
- uint32_t ti_rdata_phys;
+ bus_addr_t ti_rdata_phys;
struct ti_ring_data *ti_rdata; /* rings */
struct ti_chain_data ti_cdata; /* mbufs */
#define ti_ev_prodidx ti_rdata->ti_ev_prodidx_r
@@ -1060,28 +1045,24 @@ struct ti_softc {
/*
* Note that EEPROM_START leaves transmission enabled.
*/
-#define EEPROM_START \
+#define EEPROM_START do { \
TI_SETBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_CLK); /* Pull clock pin high */\
TI_SETBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_DOUT); /* Set DATA bit to 1 */ \
TI_SETBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_TXEN); /* Enable xmit to write bit */\
TI_CLRBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_DOUT); /* Pull DATA bit to 0 again */\
- TI_CLRBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_CLK); /* Pull clock low again */
+ TI_CLRBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_CLK); /* Pull clock low again */ \
+} while(0)
/*
* EEPROM_STOP ends access to the EEPROM and clears the ETXEN bit so
* that no further data can be written to the EEPROM I/O pin.
*/
-#define EEPROM_STOP \
+#define EEPROM_STOP do { \
TI_CLRBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_TXEN); /* Disable xmit */ \
TI_CLRBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_DOUT); /* Pull DATA to 0 */ \
TI_SETBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_CLK); /* Pull clock high */ \
TI_SETBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_TXEN); /* Enable xmit */ \
TI_SETBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_DOUT); /* Toggle DATA to 1 */ \
TI_CLRBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_TXEN); /* Disable xmit. */ \
- TI_CLRBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_CLK); /* Pull clock low again */
-
-
-#ifdef __alpha__
-#undef vtophys
-#define vtophys(va) alpha_XXX_dmamap((vm_offset_t)va)
-#endif
+ TI_CLRBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_CLK); /* Pull clock low again */ \
+} while(0)
OpenPOWER on IntegriCloud