aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/tehuti/tehuti.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/ethernet/tehuti/tehuti.c')
-rw-r--r--drivers/net/ethernet/tehuti/tehuti.c177
1 files changed, 103 insertions, 74 deletions
diff --git a/drivers/net/ethernet/tehuti/tehuti.c b/drivers/net/ethernet/tehuti/tehuti.c
index 447a6932cab3..6ce9edd95c04 100644
--- a/drivers/net/ethernet/tehuti/tehuti.c
+++ b/drivers/net/ethernet/tehuti/tehuti.c
@@ -137,14 +137,15 @@ static void print_eth_id(struct net_device *ndev)
137#define bdx_disable_interrupts(priv) \ 137#define bdx_disable_interrupts(priv) \
138 do { WRITE_REG(priv, regIMR, 0); } while (0) 138 do { WRITE_REG(priv, regIMR, 0); } while (0)
139 139
140/* bdx_fifo_init 140/**
141 * create TX/RX descriptor fifo for host-NIC communication. 141 * bdx_fifo_init - create TX/RX descriptor fifo for host-NIC communication.
142 * @priv: NIC private structure
143 * @f: fifo to initialize
144 * @fsz_type: fifo size type: 0-4KB, 1-8KB, 2-16KB, 3-32KB
145 * @reg_XXX: offsets of registers relative to base address
146 *
142 * 1K extra space is allocated at the end of the fifo to simplify 147 * 1K extra space is allocated at the end of the fifo to simplify
143 * processing of descriptors that wraps around fifo's end 148 * processing of descriptors that wraps around fifo's end
144 * @priv - NIC private structure
145 * @f - fifo to initialize
146 * @fsz_type - fifo size type: 0-4KB, 1-8KB, 2-16KB, 3-32KB
147 * @reg_XXX - offsets of registers relative to base address
148 * 149 *
149 * Returns 0 on success, negative value on failure 150 * Returns 0 on success, negative value on failure
150 * 151 *
@@ -177,9 +178,10 @@ bdx_fifo_init(struct bdx_priv *priv, struct fifo *f, int fsz_type,
177 RET(0); 178 RET(0);
178} 179}
179 180
180/* bdx_fifo_free - free all resources used by fifo 181/**
181 * @priv - NIC private structure 182 * bdx_fifo_free - free all resources used by fifo
182 * @f - fifo to release 183 * @priv: NIC private structure
184 * @f: fifo to release
183 */ 185 */
184static void bdx_fifo_free(struct bdx_priv *priv, struct fifo *f) 186static void bdx_fifo_free(struct bdx_priv *priv, struct fifo *f)
185{ 187{
@@ -192,9 +194,9 @@ static void bdx_fifo_free(struct bdx_priv *priv, struct fifo *f)
192 RET(); 194 RET();
193} 195}
194 196
195/* 197/**
196 * bdx_link_changed - notifies OS about hw link state. 198 * bdx_link_changed - notifies OS about hw link state.
197 * @bdx_priv - hw adapter structure 199 * @priv: hw adapter structure
198 */ 200 */
199static void bdx_link_changed(struct bdx_priv *priv) 201static void bdx_link_changed(struct bdx_priv *priv)
200{ 202{
@@ -233,10 +235,10 @@ static void bdx_isr_extra(struct bdx_priv *priv, u32 isr)
233 235
234} 236}
235 237
236/* bdx_isr - Interrupt Service Routine for Bordeaux NIC 238/**
237 * @irq - interrupt number 239 * bdx_isr_napi - Interrupt Service Routine for Bordeaux NIC
238 * @ndev - network device 240 * @irq: interrupt number
239 * @regs - CPU registers 241 * @dev: network device
240 * 242 *
241 * Return IRQ_NONE if it was not our interrupt, IRQ_HANDLED - otherwise 243 * Return IRQ_NONE if it was not our interrupt, IRQ_HANDLED - otherwise
242 * 244 *
@@ -307,8 +309,10 @@ static int bdx_poll(struct napi_struct *napi, int budget)
307 return work_done; 309 return work_done;
308} 310}
309 311
310/* bdx_fw_load - loads firmware to NIC 312/**
311 * @priv - NIC private structure 313 * bdx_fw_load - loads firmware to NIC
314 * @priv: NIC private structure
315 *
312 * Firmware is loaded via TXD fifo, so it must be initialized first. 316 * Firmware is loaded via TXD fifo, so it must be initialized first.
313 * Firware must be loaded once per NIC not per PCI device provided by NIC (NIC 317 * Firware must be loaded once per NIC not per PCI device provided by NIC (NIC
314 * can have few of them). So all drivers use semaphore register to choose one 318 * can have few of them). So all drivers use semaphore register to choose one
@@ -380,8 +384,9 @@ static void bdx_restore_mac(struct net_device *ndev, struct bdx_priv *priv)
380 RET(); 384 RET();
381} 385}
382 386
383/* bdx_hw_start - inits registers and starts HW's Rx and Tx engines 387/**
384 * @priv - NIC private structure 388 * bdx_hw_start - inits registers and starts HW's Rx and Tx engines
389 * @priv: NIC private structure
385 */ 390 */
386static int bdx_hw_start(struct bdx_priv *priv) 391static int bdx_hw_start(struct bdx_priv *priv)
387{ 392{
@@ -691,12 +696,13 @@ static int bdx_ioctl(struct net_device *ndev, struct ifreq *ifr, int cmd)
691 RET(-EOPNOTSUPP); 696 RET(-EOPNOTSUPP);
692} 697}
693 698
694/* 699/**
695 * __bdx_vlan_rx_vid - private helper for adding/killing VLAN vid 700 * __bdx_vlan_rx_vid - private helper for adding/killing VLAN vid
696 * by passing VLAN filter table to hardware 701 * @ndev: network device
697 * @ndev network device 702 * @vid: VLAN vid
698 * @vid VLAN vid 703 * @op: add or kill operation
699 * @op add or kill operation 704 *
705 * Passes VLAN filter table to hardware
700 */ 706 */
701static void __bdx_vlan_rx_vid(struct net_device *ndev, uint16_t vid, int enable) 707static void __bdx_vlan_rx_vid(struct net_device *ndev, uint16_t vid, int enable)
702{ 708{
@@ -722,10 +728,10 @@ static void __bdx_vlan_rx_vid(struct net_device *ndev, uint16_t vid, int enable)
722 RET(); 728 RET();
723} 729}
724 730
725/* 731/**
726 * bdx_vlan_rx_add_vid - kernel hook for adding VLAN vid to hw filtering table 732 * bdx_vlan_rx_add_vid - kernel hook for adding VLAN vid to hw filtering table
727 * @ndev network device 733 * @ndev: network device
728 * @vid VLAN vid to add 734 * @vid: VLAN vid to add
729 */ 735 */
730static int bdx_vlan_rx_add_vid(struct net_device *ndev, uint16_t vid) 736static int bdx_vlan_rx_add_vid(struct net_device *ndev, uint16_t vid)
731{ 737{
@@ -733,10 +739,10 @@ static int bdx_vlan_rx_add_vid(struct net_device *ndev, uint16_t vid)
733 return 0; 739 return 0;
734} 740}
735 741
736/* 742/**
737 * bdx_vlan_rx_kill_vid - kernel hook for killing VLAN vid in hw filtering table 743 * bdx_vlan_rx_kill_vid - kernel hook for killing VLAN vid in hw filtering table
738 * @ndev network device 744 * @ndev: network device
739 * @vid VLAN vid to kill 745 * @vid: VLAN vid to kill
740 */ 746 */
741static int bdx_vlan_rx_kill_vid(struct net_device *ndev, unsigned short vid) 747static int bdx_vlan_rx_kill_vid(struct net_device *ndev, unsigned short vid)
742{ 748{
@@ -974,8 +980,9 @@ static inline void bdx_rxdb_free_elem(struct rxdb *db, int n)
974 * Rx Init * 980 * Rx Init *
975 *************************************************************************/ 981 *************************************************************************/
976 982
977/* bdx_rx_init - initialize RX all related HW and SW resources 983/**
978 * @priv - NIC private structure 984 * bdx_rx_init - initialize RX all related HW and SW resources
985 * @priv: NIC private structure
979 * 986 *
980 * Returns 0 on success, negative value on failure 987 * Returns 0 on success, negative value on failure
981 * 988 *
@@ -1016,9 +1023,10 @@ err_mem:
1016 return -ENOMEM; 1023 return -ENOMEM;
1017} 1024}
1018 1025
1019/* bdx_rx_free_skbs - frees and unmaps all skbs allocated for the fifo 1026/**
1020 * @priv - NIC private structure 1027 * bdx_rx_free_skbs - frees and unmaps all skbs allocated for the fifo
1021 * @f - RXF fifo 1028 * @priv: NIC private structure
1029 * @f: RXF fifo
1022 */ 1030 */
1023static void bdx_rx_free_skbs(struct bdx_priv *priv, struct rxf_fifo *f) 1031static void bdx_rx_free_skbs(struct bdx_priv *priv, struct rxf_fifo *f)
1024{ 1032{
@@ -1045,8 +1053,10 @@ static void bdx_rx_free_skbs(struct bdx_priv *priv, struct rxf_fifo *f)
1045 } 1053 }
1046} 1054}
1047 1055
1048/* bdx_rx_free - release all Rx resources 1056/**
1049 * @priv - NIC private structure 1057 * bdx_rx_free - release all Rx resources
1058 * @priv: NIC private structure
1059 *
1050 * It assumes that Rx is desabled in HW 1060 * It assumes that Rx is desabled in HW
1051 */ 1061 */
1052static void bdx_rx_free(struct bdx_priv *priv) 1062static void bdx_rx_free(struct bdx_priv *priv)
@@ -1067,9 +1077,11 @@ static void bdx_rx_free(struct bdx_priv *priv)
1067 * Rx Engine * 1077 * Rx Engine *
1068 *************************************************************************/ 1078 *************************************************************************/
1069 1079
1070/* bdx_rx_alloc_skbs - fill rxf fifo with new skbs 1080/**
1071 * @priv - nic's private structure 1081 * bdx_rx_alloc_skbs - fill rxf fifo with new skbs
1072 * @f - RXF fifo that needs skbs 1082 * @priv: nic's private structure
1083 * @f: RXF fifo that needs skbs
1084 *
1073 * It allocates skbs, build rxf descs and push it (rxf descr) into rxf fifo. 1085 * It allocates skbs, build rxf descs and push it (rxf descr) into rxf fifo.
1074 * skb's virtual and physical addresses are stored in skb db. 1086 * skb's virtual and physical addresses are stored in skb db.
1075 * To calculate free space, func uses cached values of RPTR and WPTR 1087 * To calculate free space, func uses cached values of RPTR and WPTR
@@ -1179,13 +1191,15 @@ static void bdx_recycle_skb(struct bdx_priv *priv, struct rxd_desc *rxdd)
1179 RET(); 1191 RET();
1180} 1192}
1181 1193
1182/* bdx_rx_receive - receives full packets from RXD fifo and pass them to OS 1194/**
1195 * bdx_rx_receive - receives full packets from RXD fifo and pass them to OS
1183 * NOTE: a special treatment is given to non-continuous descriptors 1196 * NOTE: a special treatment is given to non-continuous descriptors
1184 * that start near the end, wraps around and continue at the beginning. a second 1197 * that start near the end, wraps around and continue at the beginning. a second
1185 * part is copied right after the first, and then descriptor is interpreted as 1198 * part is copied right after the first, and then descriptor is interpreted as
1186 * normal. fifo has an extra space to allow such operations 1199 * normal. fifo has an extra space to allow such operations
1187 * @priv - nic's private structure 1200 * @priv: nic's private structure
1188 * @f - RXF fifo that needs skbs 1201 * @f: RXF fifo that needs skbs
1202 * @budget: maximum number of packets to receive
1189 */ 1203 */
1190 1204
1191/* TBD: replace memcpy func call by explicite inline asm */ 1205/* TBD: replace memcpy func call by explicite inline asm */
@@ -1375,9 +1389,10 @@ static inline int bdx_tx_db_size(struct txdb *db)
1375 return db->size - taken; 1389 return db->size - taken;
1376} 1390}
1377 1391
1378/* __bdx_tx_ptr_next - helper function, increment read/write pointer + wrap 1392/**
1379 * @d - tx data base 1393 * __bdx_tx_db_ptr_next - helper function, increment read/write pointer + wrap
1380 * @ptr - read or write pointer 1394 * @db: tx data base
1395 * @pptr: read or write pointer
1381 */ 1396 */
1382static inline void __bdx_tx_db_ptr_next(struct txdb *db, struct tx_map **pptr) 1397static inline void __bdx_tx_db_ptr_next(struct txdb *db, struct tx_map **pptr)
1383{ 1398{
@@ -1394,8 +1409,9 @@ static inline void __bdx_tx_db_ptr_next(struct txdb *db, struct tx_map **pptr)
1394 *pptr = db->start; 1409 *pptr = db->start;
1395} 1410}
1396 1411
1397/* bdx_tx_db_inc_rptr - increment read pointer 1412/**
1398 * @d - tx data base 1413 * bdx_tx_db_inc_rptr - increment read pointer
1414 * @db: tx data base
1399 */ 1415 */
1400static inline void bdx_tx_db_inc_rptr(struct txdb *db) 1416static inline void bdx_tx_db_inc_rptr(struct txdb *db)
1401{ 1417{
@@ -1403,8 +1419,9 @@ static inline void bdx_tx_db_inc_rptr(struct txdb *db)
1403 __bdx_tx_db_ptr_next(db, &db->rptr); 1419 __bdx_tx_db_ptr_next(db, &db->rptr);
1404} 1420}
1405 1421
1406/* bdx_tx_db_inc_rptr - increment write pointer 1422/**
1407 * @d - tx data base 1423 * bdx_tx_db_inc_wptr - increment write pointer
1424 * @db: tx data base
1408 */ 1425 */
1409static inline void bdx_tx_db_inc_wptr(struct txdb *db) 1426static inline void bdx_tx_db_inc_wptr(struct txdb *db)
1410{ 1427{
@@ -1413,9 +1430,11 @@ static inline void bdx_tx_db_inc_wptr(struct txdb *db)
1413 a result of write */ 1430 a result of write */
1414} 1431}
1415 1432
1416/* bdx_tx_db_init - creates and initializes tx db 1433/**
1417 * @d - tx data base 1434 * bdx_tx_db_init - creates and initializes tx db
1418 * @sz_type - size of tx fifo 1435 * @d: tx data base
1436 * @sz_type: size of tx fifo
1437 *
1419 * Returns 0 on success, error code otherwise 1438 * Returns 0 on success, error code otherwise
1420 */ 1439 */
1421static int bdx_tx_db_init(struct txdb *d, int sz_type) 1440static int bdx_tx_db_init(struct txdb *d, int sz_type)
@@ -1441,8 +1460,9 @@ static int bdx_tx_db_init(struct txdb *d, int sz_type)
1441 return 0; 1460 return 0;
1442} 1461}
1443 1462
1444/* bdx_tx_db_close - closes tx db and frees all memory 1463/**
1445 * @d - tx data base 1464 * bdx_tx_db_close - closes tx db and frees all memory
1465 * @d: tx data base
1446 */ 1466 */
1447static void bdx_tx_db_close(struct txdb *d) 1467static void bdx_tx_db_close(struct txdb *d)
1448{ 1468{
@@ -1463,9 +1483,11 @@ static struct {
1463 u16 qwords; /* qword = 64 bit */ 1483 u16 qwords; /* qword = 64 bit */
1464} txd_sizes[MAX_SKB_FRAGS + 1]; 1484} txd_sizes[MAX_SKB_FRAGS + 1];
1465 1485
1466/* txdb_map_skb - creates and stores dma mappings for skb's data blocks 1486/**
1467 * @priv - NIC private structure 1487 * bdx_tx_map_skb - creates and stores dma mappings for skb's data blocks
1468 * @skb - socket buffer to map 1488 * @priv: NIC private structure
1489 * @skb: socket buffer to map
1490 * @txdd: TX descriptor to use
1469 * 1491 *
1470 * It makes dma mappings for skb's data blocks and writes them to PBL of 1492 * It makes dma mappings for skb's data blocks and writes them to PBL of
1471 * new tx descriptor. It also stores them in the tx db, so they could be 1493 * new tx descriptor. It also stores them in the tx db, so they could be
@@ -1562,9 +1584,10 @@ err_mem:
1562 return -ENOMEM; 1584 return -ENOMEM;
1563} 1585}
1564 1586
1565/* 1587/**
1566 * bdx_tx_space - calculates available space in TX fifo 1588 * bdx_tx_space - calculates available space in TX fifo
1567 * @priv - NIC private structure 1589 * @priv: NIC private structure
1590 *
1568 * Returns available space in TX fifo in bytes 1591 * Returns available space in TX fifo in bytes
1569 */ 1592 */
1570static inline int bdx_tx_space(struct bdx_priv *priv) 1593static inline int bdx_tx_space(struct bdx_priv *priv)
@@ -1579,9 +1602,10 @@ static inline int bdx_tx_space(struct bdx_priv *priv)
1579 return fsize; 1602 return fsize;
1580} 1603}
1581 1604
1582/* bdx_tx_transmit - send packet to NIC 1605/**
1583 * @skb - packet to send 1606 * bdx_tx_transmit - send packet to NIC
1584 * ndev - network device assigned to NIC 1607 * @skb: packet to send
1608 * @ndev: network device assigned to NIC
1585 * Return codes: 1609 * Return codes:
1586 * o NETDEV_TX_OK everything ok. 1610 * o NETDEV_TX_OK everything ok.
1587 * o NETDEV_TX_BUSY Cannot transmit packet, try later 1611 * o NETDEV_TX_BUSY Cannot transmit packet, try later
@@ -1699,8 +1723,10 @@ static netdev_tx_t bdx_tx_transmit(struct sk_buff *skb,
1699 return NETDEV_TX_OK; 1723 return NETDEV_TX_OK;
1700} 1724}
1701 1725
1702/* bdx_tx_cleanup - clean TXF fifo, run in the context of IRQ. 1726/**
1703 * @priv - bdx adapter 1727 * bdx_tx_cleanup - clean TXF fifo, run in the context of IRQ.
1728 * @priv: bdx adapter
1729 *
1704 * It scans TXF fifo for descriptors, frees DMA mappings and reports to OS 1730 * It scans TXF fifo for descriptors, frees DMA mappings and reports to OS
1705 * that those packets were sent 1731 * that those packets were sent
1706 */ 1732 */
@@ -1761,7 +1787,8 @@ static void bdx_tx_cleanup(struct bdx_priv *priv)
1761 spin_unlock(&priv->tx_lock); 1787 spin_unlock(&priv->tx_lock);
1762} 1788}
1763 1789
1764/* bdx_tx_free_skbs - frees all skbs from TXD fifo. 1790/**
1791 * bdx_tx_free_skbs - frees all skbs from TXD fifo.
1765 * It gets called when OS stops this dev, eg upon "ifconfig down" or rmmod 1792 * It gets called when OS stops this dev, eg upon "ifconfig down" or rmmod
1766 */ 1793 */
1767static void bdx_tx_free_skbs(struct bdx_priv *priv) 1794static void bdx_tx_free_skbs(struct bdx_priv *priv)
@@ -1790,10 +1817,11 @@ static void bdx_tx_free(struct bdx_priv *priv)
1790 bdx_tx_db_close(&priv->txdb); 1817 bdx_tx_db_close(&priv->txdb);
1791} 1818}
1792 1819
1793/* bdx_tx_push_desc - push descriptor to TxD fifo 1820/**
1794 * @priv - NIC private structure 1821 * bdx_tx_push_desc - push descriptor to TxD fifo
1795 * @data - desc's data 1822 * @priv: NIC private structure
1796 * @size - desc's size 1823 * @data: desc's data
1824 * @size: desc's size
1797 * 1825 *
1798 * Pushes desc to TxD fifo and overlaps it if needed. 1826 * Pushes desc to TxD fifo and overlaps it if needed.
1799 * NOTE: this func does not check for available space. this is responsibility 1827 * NOTE: this func does not check for available space. this is responsibility
@@ -1819,10 +1847,11 @@ static void bdx_tx_push_desc(struct bdx_priv *priv, void *data, int size)
1819 WRITE_REG(priv, f->m.reg_WPTR, f->m.wptr & TXF_WPTR_WR_PTR); 1847 WRITE_REG(priv, f->m.reg_WPTR, f->m.wptr & TXF_WPTR_WR_PTR);
1820} 1848}
1821 1849
1822/* bdx_tx_push_desc_safe - push descriptor to TxD fifo in a safe way 1850/**
1823 * @priv - NIC private structure 1851 * bdx_tx_push_desc_safe - push descriptor to TxD fifo in a safe way
1824 * @data - desc's data 1852 * @priv: NIC private structure
1825 * @size - desc's size 1853 * @data: desc's data
1854 * @size: desc's size
1826 * 1855 *
1827 * NOTE: this func does check for available space and, if necessary, waits for 1856 * NOTE: this func does check for available space and, if necessary, waits for
1828 * NIC to read existing data before writing new one. 1857 * NIC to read existing data before writing new one.