aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHuang, Xiong <xiong@qca.qualcomm.com>2012-04-17 15:32:30 -0400
committerDavid S. Miller <davem@davemloft.net>2012-04-18 15:35:31 -0400
commit0af48336704e5b3870e03699b3acf5dd7d7cb8ab (patch)
tree13ccccec483031b1336b92dc43a529a25c69321f
parent8d5c68362f7d77cdffdf12ab7516a6eb77a5dd90 (diff)
atl1c: split 2 32bit registers of TPD to 4 16bit registers
TPD producer/consumer index is 16bit wide. 16bit read/write reduce the dependency of the 2 tpd rings (hi and lo) rename reg(157C/1580) to keep name coninsistency. Signed-off-by: xiong <xiong@qca.qualcomm.com> Tested-by: Liu David <dwliu@qca.qualcomm.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/atheros/atl1c/atl1c.h10
-rw-r--r--drivers/net/ethernet/atheros/atl1c/atl1c_hw.h17
-rw-r--r--drivers/net/ethernet/atheros/atl1c/atl1c_main.c34
3 files changed, 22 insertions, 39 deletions
diff --git a/drivers/net/ethernet/atheros/atl1c/atl1c.h b/drivers/net/ethernet/atheros/atl1c/atl1c.h
index 93b59915ec56..973c5681c70a 100644
--- a/drivers/net/ethernet/atheros/atl1c/atl1c.h
+++ b/drivers/net/ethernet/atheros/atl1c/atl1c.h
@@ -583,8 +583,14 @@ struct atl1c_adapter {
583#define AT_WRITE_REGW(a, reg, value) (\ 583#define AT_WRITE_REGW(a, reg, value) (\
584 writew((value), ((a)->hw_addr + reg))) 584 writew((value), ((a)->hw_addr + reg)))
585 585
586#define AT_READ_REGW(a, reg) (\ 586#define AT_READ_REGW(a, reg, pdata) do { \
587 readw((a)->hw_addr + reg)) 587 if (unlikely((a)->hibernate)) { \
588 readw((a)->hw_addr + reg); \
589 *(u16 *)pdata = readw((a)->hw_addr + reg); \
590 } else { \
591 *(u16 *)pdata = readw((a)->hw_addr + reg); \
592 } \
593 } while (0)
588 594
589#define AT_WRITE_REG_ARRAY(a, reg, offset, value) ( \ 595#define AT_WRITE_REG_ARRAY(a, reg, offset, value) ( \
590 writel((value), (((a)->hw_addr + reg) + ((offset) << 2)))) 596 writel((value), (((a)->hw_addr + reg) + ((offset) << 2))))
diff --git a/drivers/net/ethernet/atheros/atl1c/atl1c_hw.h b/drivers/net/ethernet/atheros/atl1c/atl1c_hw.h
index caff2ae20a6c..ca45fadb2d55 100644
--- a/drivers/net/ethernet/atheros/atl1c/atl1c_hw.h
+++ b/drivers/net/ethernet/atheros/atl1c/atl1c_hw.h
@@ -455,8 +455,8 @@ int atl1c_phy_power_saving(struct atl1c_hw *hw);
455#define REG_RRD0_HEAD_ADDR_LO 0x1568 455#define REG_RRD0_HEAD_ADDR_LO 0x1568
456#define REG_RRD_RING_SIZE 0x1578 456#define REG_RRD_RING_SIZE 0x1578
457#define RRD_RING_SIZE_MASK 0x0FFF 457#define RRD_RING_SIZE_MASK 0x0FFF
458#define REG_HTPD_HEAD_ADDR_LO 0x157C 458#define REG_TPD_PRI1_ADDR_LO 0x157C
459#define REG_NTPD_HEAD_ADDR_LO 0x1580 459#define REG_TPD_PRI0_ADDR_LO 0x1580
460#define REG_TPD_RING_SIZE 0x1584 460#define REG_TPD_RING_SIZE 0x1584
461#define TPD_RING_SIZE_MASK 0xFFFF 461#define TPD_RING_SIZE_MASK 0xFFFF
462 462
@@ -562,15 +562,10 @@ int atl1c_phy_power_saving(struct atl1c_hw *hw);
562#define MB_RFDX_PROD_IDX_MASK 0xFFFF 562#define MB_RFDX_PROD_IDX_MASK 0xFFFF
563#define REG_MB_RFD0_PROD_IDX 0x15E0 563#define REG_MB_RFD0_PROD_IDX 0x15E0
564 564
565#define MB_PRIO_PROD_IDX_MASK 0xFFFF 565#define REG_TPD_PRI1_PIDX 0x15F0 /* 16bit,hi-tpd producer idx */
566#define REG_MB_PRIO_PROD_IDX 0x15F0 566#define REG_TPD_PRI0_PIDX 0x15F2 /* 16bit,lo-tpd producer idx */
567#define MB_HTPD_PROD_IDX_SHIFT 0 567#define REG_TPD_PRI1_CIDX 0x15F4 /* 16bit,hi-tpd consumer idx */
568#define MB_NTPD_PROD_IDX_SHIFT 16 568#define REG_TPD_PRI0_CIDX 0x15F6 /* 16bit,lo-tpd consumer idx */
569
570#define MB_PRIO_CONS_IDX_MASK 0xFFFF
571#define REG_MB_PRIO_CONS_IDX 0x15F4
572#define MB_HTPD_CONS_IDX_SHIFT 0
573#define MB_NTPD_CONS_IDX_SHIFT 16
574 569
575#define REG_MB_RFD01_CONS_IDX 0x15F8 570#define REG_MB_RFD01_CONS_IDX 0x15F8
576#define MB_RFD0_CONS_IDX_MASK 0x0000FFFF 571#define MB_RFD0_CONS_IDX_MASK 0x0000FFFF
diff --git a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
index c4d5929f7022..74203ea9ae18 100644
--- a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
+++ b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
@@ -995,10 +995,10 @@ static void atl1c_configure_des_ring(struct atl1c_adapter *adapter)
995 (u32)((tpd_ring[atl1c_trans_normal].dma & 995 (u32)((tpd_ring[atl1c_trans_normal].dma &
996 AT_DMA_HI_ADDR_MASK) >> 32)); 996 AT_DMA_HI_ADDR_MASK) >> 32));
997 /* just enable normal priority TX queue */ 997 /* just enable normal priority TX queue */
998 AT_WRITE_REG(hw, REG_NTPD_HEAD_ADDR_LO, 998 AT_WRITE_REG(hw, REG_TPD_PRI0_ADDR_LO,
999 (u32)(tpd_ring[atl1c_trans_normal].dma & 999 (u32)(tpd_ring[atl1c_trans_normal].dma &
1000 AT_DMA_LO_ADDR_MASK)); 1000 AT_DMA_LO_ADDR_MASK));
1001 AT_WRITE_REG(hw, REG_HTPD_HEAD_ADDR_LO, 1001 AT_WRITE_REG(hw, REG_TPD_PRI1_ADDR_LO,
1002 (u32)(tpd_ring[atl1c_trans_high].dma & 1002 (u32)(tpd_ring[atl1c_trans_high].dma &
1003 AT_DMA_LO_ADDR_MASK)); 1003 AT_DMA_LO_ADDR_MASK));
1004 AT_WRITE_REG(hw, REG_TPD_RING_SIZE, 1004 AT_WRITE_REG(hw, REG_TPD_RING_SIZE,
@@ -1519,16 +1519,11 @@ static bool atl1c_clean_tx_irq(struct atl1c_adapter *adapter,
1519 struct pci_dev *pdev = adapter->pdev; 1519 struct pci_dev *pdev = adapter->pdev;
1520 u16 next_to_clean = atomic_read(&tpd_ring->next_to_clean); 1520 u16 next_to_clean = atomic_read(&tpd_ring->next_to_clean);
1521 u16 hw_next_to_clean; 1521 u16 hw_next_to_clean;
1522 u16 shift; 1522 u16 reg;
1523 u32 data;
1524 1523
1525 if (type == atl1c_trans_high) 1524 reg = type == atl1c_trans_high ? REG_TPD_PRI1_CIDX : REG_TPD_PRI0_CIDX;
1526 shift = MB_HTPD_CONS_IDX_SHIFT;
1527 else
1528 shift = MB_NTPD_CONS_IDX_SHIFT;
1529 1525
1530 AT_READ_REG(&adapter->hw, REG_MB_PRIO_CONS_IDX, &data); 1526 AT_READ_REGW(&adapter->hw, reg, &hw_next_to_clean);
1531 hw_next_to_clean = (data >> shift) & MB_PRIO_PROD_IDX_MASK;
1532 1527
1533 while (next_to_clean != hw_next_to_clean) { 1528 while (next_to_clean != hw_next_to_clean) {
1534 buffer_info = &tpd_ring->buffer_info[next_to_clean]; 1529 buffer_info = &tpd_ring->buffer_info[next_to_clean];
@@ -2090,23 +2085,10 @@ static void atl1c_tx_queue(struct atl1c_adapter *adapter, struct sk_buff *skb,
2090 struct atl1c_tpd_desc *tpd, enum atl1c_trans_queue type) 2085 struct atl1c_tpd_desc *tpd, enum atl1c_trans_queue type)
2091{ 2086{
2092 struct atl1c_tpd_ring *tpd_ring = &adapter->tpd_ring[type]; 2087 struct atl1c_tpd_ring *tpd_ring = &adapter->tpd_ring[type];
2093 u32 prod_data; 2088 u16 reg;
2094 2089
2095 AT_READ_REG(&adapter->hw, REG_MB_PRIO_PROD_IDX, &prod_data); 2090 reg = type == atl1c_trans_high ? REG_TPD_PRI1_PIDX : REG_TPD_PRI0_PIDX;
2096 switch (type) { 2091 AT_WRITE_REGW(&adapter->hw, reg, tpd_ring->next_to_use);
2097 case atl1c_trans_high:
2098 prod_data &= 0xFFFF0000;
2099 prod_data |= tpd_ring->next_to_use & 0xFFFF;
2100 break;
2101 case atl1c_trans_normal:
2102 prod_data &= 0x0000FFFF;
2103 prod_data |= (tpd_ring->next_to_use & 0xFFFF) << 16;
2104 break;
2105 default:
2106 break;
2107 }
2108 wmb();
2109 AT_WRITE_REG(&adapter->hw, REG_MB_PRIO_PROD_IDX, prod_data);
2110} 2092}
2111 2093
2112static netdev_tx_t atl1c_xmit_frame(struct sk_buff *skb, 2094static netdev_tx_t atl1c_xmit_frame(struct sk_buff *skb,