aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/bnx2x/bnx2x_cmn.h
diff options
context:
space:
mode:
authorDmitry Kravkov <dmitry@broadcom.com>2010-10-05 23:23:26 -0400
committerDavid S. Miller <davem@davemloft.net>2010-10-06 17:10:35 -0400
commit523224a3b3cd407ce4e6731a087194e13a90db18 (patch)
treebb0fda289682e4259c401b8a5763ba4cc4d41659 /drivers/net/bnx2x/bnx2x_cmn.h
parent0c5b77152e736d23a23eb2546eab323e27a37f52 (diff)
bnx2x, cnic, bnx2i: use new FW/HSI
This is the new FW HSI blob and the relevant definitions without logic changes. It also included code adaptation for new HSI. New features are not enabled. New FW/HSI includes: - Support for 57712 HW - Future support for VF (not used) - Improvements in FW interrupts scheme - FW FCoE hooks (stubs for future usage) Signed-off-by: Dmitry Kravkov <dmitry@broadcom.com> Signed-off-by: Michael Chan <mchan@broadcom.com> Signed-off-by: Eilon Greenstein <eilong@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/bnx2x/bnx2x_cmn.h')
-rw-r--r--drivers/net/bnx2x/bnx2x_cmn.h256
1 files changed, 183 insertions, 73 deletions
diff --git a/drivers/net/bnx2x/bnx2x_cmn.h b/drivers/net/bnx2x/bnx2x_cmn.h
index 1ad08e4e88f4..2fb9045833e1 100644
--- a/drivers/net/bnx2x/bnx2x_cmn.h
+++ b/drivers/net/bnx2x/bnx2x_cmn.h
@@ -107,6 +107,13 @@ void bnx2x_setup_cnic_irq_info(struct bnx2x *bp);
107void bnx2x_int_enable(struct bnx2x *bp); 107void bnx2x_int_enable(struct bnx2x *bp);
108 108
109/** 109/**
110 * Disable HW interrupts.
111 *
112 * @param bp
113 */
114void bnx2x_int_disable(struct bnx2x *bp);
115
116/**
110 * Disable interrupts. This function ensures that there are no 117 * Disable interrupts. This function ensures that there are no
111 * ISRs or SP DPCs (sp_task) are running after it returns. 118 * ISRs or SP DPCs (sp_task) are running after it returns.
112 * 119 *
@@ -163,27 +170,30 @@ int bnx2x_alloc_mem(struct bnx2x *bp);
163void bnx2x_free_mem(struct bnx2x *bp); 170void bnx2x_free_mem(struct bnx2x *bp);
164 171
165/** 172/**
166 * Bring up a leading (the first) eth Client. 173 * Setup eth Client.
167 * 174 *
168 * @param bp 175 * @param bp
176 * @param fp
177 * @param is_leading
169 * 178 *
170 * @return int 179 * @return int
171 */ 180 */
172int bnx2x_setup_leading(struct bnx2x *bp); 181int bnx2x_setup_client(struct bnx2x *bp, struct bnx2x_fastpath *fp,
182 int is_leading);
173 183
174/** 184/**
175 * Setup non-leading eth Client. 185 * Bring down an eth client.
176 * 186 *
177 * @param bp 187 * @param bp
178 * @param fp 188 * @param p
179 * 189 *
180 * @return int 190 * @return int
181 */ 191 */
182int bnx2x_setup_multi(struct bnx2x *bp, int index); 192int bnx2x_stop_fw_client(struct bnx2x *bp,
193 struct bnx2x_client_ramrod_params *p);
183 194
184/** 195/**
185 * Set number of quueus according to mode and number of available 196 * Set number of quueus according to mode
186 * msi-x vectors
187 * 197 *
188 * @param bp 198 * @param bp
189 * 199 *
@@ -228,16 +238,7 @@ int bnx2x_release_hw_lock(struct bnx2x *bp, u32 resource);
228 * @param bp driver handle 238 * @param bp driver handle
229 * @param set 239 * @param set
230 */ 240 */
231void bnx2x_set_eth_mac_addr_e1h(struct bnx2x *bp, int set); 241void bnx2x_set_eth_mac(struct bnx2x *bp, int set);
232
233/**
234 * Configure eth MAC address in the HW according to the value in
235 * netdev->dev_addr for 57710
236 *
237 * @param bp driver handle
238 * @param set
239 */
240void bnx2x_set_eth_mac_addr_e1(struct bnx2x *bp, int set);
241 242
242#ifdef BCM_CNIC 243#ifdef BCM_CNIC
243/** 244/**
@@ -257,12 +258,15 @@ int bnx2x_set_iscsi_eth_mac_addr(struct bnx2x *bp, int set);
257 * Initialize status block in FW and HW 258 * Initialize status block in FW and HW
258 * 259 *
259 * @param bp driver handle 260 * @param bp driver handle
260 * @param sb host_status_block
261 * @param dma_addr_t mapping 261 * @param dma_addr_t mapping
262 * @param int sb_id 262 * @param int sb_id
263 * @param int vfid
264 * @param u8 vf_valid
265 * @param int fw_sb_id
266 * @param int igu_sb_id
263 */ 267 */
264void bnx2x_init_sb(struct bnx2x *bp, struct host_status_block *sb, 268void bnx2x_init_sb(struct bnx2x *bp, dma_addr_t mapping, int vfid,
265 dma_addr_t mapping, int sb_id); 269 u8 vf_valid, int fw_sb_id, int igu_sb_id);
266 270
267/** 271/**
268 * Reconfigure FW/HW according to dev->flags rx mode 272 * Reconfigure FW/HW according to dev->flags rx mode
@@ -295,14 +299,6 @@ void bnx2x_disable_close_the_gate(struct bnx2x *bp);
295void bnx2x_stats_handle(struct bnx2x *bp, enum bnx2x_stats_event event); 299void bnx2x_stats_handle(struct bnx2x *bp, enum bnx2x_stats_event event);
296 300
297/** 301/**
298 * Configures FW with client paramteres (like HW VLAN removal)
299 * for each active client.
300 *
301 * @param bp
302 */
303void bnx2x_set_client_config(struct bnx2x *bp);
304
305/**
306 * Handle sp events 302 * Handle sp events
307 * 303 *
308 * @param fp fastpath handle for the event 304 * @param fp fastpath handle for the event
@@ -310,14 +306,29 @@ void bnx2x_set_client_config(struct bnx2x *bp);
310 */ 306 */
311void bnx2x_sp_event(struct bnx2x_fastpath *fp, union eth_rx_cqe *rr_cqe); 307void bnx2x_sp_event(struct bnx2x_fastpath *fp, union eth_rx_cqe *rr_cqe);
312 308
309/**
310 * Init/halt function before/after sending
311 * CLIENT_SETUP/CFC_DEL for the first/last client.
312 *
313 * @param bp
314 *
315 * @return int
316 */
317int bnx2x_func_start(struct bnx2x *bp);
318int bnx2x_func_stop(struct bnx2x *bp);
319
320/**
321 * Prepare ILT configurations according to current driver
322 * parameters.
323 *
324 * @param bp
325 */
326void bnx2x_ilt_set_info(struct bnx2x *bp);
313 327
314static inline void bnx2x_update_fpsb_idx(struct bnx2x_fastpath *fp) 328static inline void bnx2x_update_fpsb_idx(struct bnx2x_fastpath *fp)
315{ 329{
316 struct host_status_block *fpsb = fp->status_blk;
317
318 barrier(); /* status block is written to by the chip */ 330 barrier(); /* status block is written to by the chip */
319 fp->fp_c_idx = fpsb->c_status_block.status_block_index; 331 fp->fp_hc_idx = fp->sb_running_index[SM_RX_ID];
320 fp->fp_u_idx = fpsb->u_status_block.status_block_index;
321} 332}
322 333
323static inline void bnx2x_update_rx_prod(struct bnx2x *bp, 334static inline void bnx2x_update_rx_prod(struct bnx2x *bp,
@@ -344,8 +355,8 @@ static inline void bnx2x_update_rx_prod(struct bnx2x *bp,
344 wmb(); 355 wmb();
345 356
346 for (i = 0; i < sizeof(struct ustorm_eth_rx_producers)/4; i++) 357 for (i = 0; i < sizeof(struct ustorm_eth_rx_producers)/4; i++)
347 REG_WR(bp, BAR_USTRORM_INTMEM + 358 REG_WR(bp,
348 USTORM_RX_PRODS_OFFSET(BP_PORT(bp), fp->cl_id) + i*4, 359 BAR_USTRORM_INTMEM + fp->ustorm_rx_prods_offset + i*4,
349 ((u32 *)&rx_prods)[i]); 360 ((u32 *)&rx_prods)[i]);
350 361
351 mmiowb(); /* keep prod updates ordered */ 362 mmiowb(); /* keep prod updates ordered */
@@ -434,6 +445,17 @@ static inline int bnx2x_has_tx_work(struct bnx2x_fastpath *fp)
434 return hw_cons != fp->tx_pkt_cons; 445 return hw_cons != fp->tx_pkt_cons;
435} 446}
436 447
448static inline int bnx2x_has_rx_work(struct bnx2x_fastpath *fp)
449{
450 u16 rx_cons_sb;
451
452 /* Tell compiler that status block fields can change */
453 barrier();
454 rx_cons_sb = le16_to_cpu(*fp->rx_cons_sb);
455 if ((rx_cons_sb & MAX_RCQ_DESC_CNT) == MAX_RCQ_DESC_CNT)
456 rx_cons_sb++;
457 return (fp->rx_comp_cons != rx_cons_sb);
458}
437static inline void bnx2x_free_rx_sge(struct bnx2x *bp, 459static inline void bnx2x_free_rx_sge(struct bnx2x *bp,
438 struct bnx2x_fastpath *fp, u16 index) 460 struct bnx2x_fastpath *fp, u16 index)
439{ 461{
@@ -454,13 +476,35 @@ static inline void bnx2x_free_rx_sge(struct bnx2x *bp,
454 sge->addr_lo = 0; 476 sge->addr_lo = 0;
455} 477}
456 478
457static inline void bnx2x_free_rx_sge_range(struct bnx2x *bp, 479
458 struct bnx2x_fastpath *fp, int last) 480
481
482
483static inline void bnx2x_clear_sge_mask_next_elems(struct bnx2x_fastpath *fp)
459{ 484{
460 int i; 485 int i, j;
461 486
462 for (i = 0; i < last; i++) 487 for (i = 1; i <= NUM_RX_SGE_PAGES; i++) {
463 bnx2x_free_rx_sge(bp, fp, i); 488 int idx = RX_SGE_CNT * i - 1;
489
490 for (j = 0; j < 2; j++) {
491 SGE_MASK_CLEAR_BIT(fp, idx);
492 idx--;
493 }
494 }
495}
496
497static inline void bnx2x_init_sge_ring_bit_mask(struct bnx2x_fastpath *fp)
498{
499 /* Set the mask to all 1-s: it's faster to compare to 0 than to 0xf-s */
500 memset(fp->sge_mask, 0xff,
501 (NUM_RX_SGE >> RX_SGE_MASK_ELEM_SHIFT)*sizeof(u64));
502
503 /* Clear the two last indices in the page to 1:
504 these are the indices that correspond to the "next" element,
505 hence will never be indicated and should be removed from
506 the calculations. */
507 bnx2x_clear_sge_mask_next_elems(fp);
464} 508}
465 509
466static inline int bnx2x_alloc_rx_sge(struct bnx2x *bp, 510static inline int bnx2x_alloc_rx_sge(struct bnx2x *bp,
@@ -540,33 +584,15 @@ static inline void bnx2x_reuse_rx_skb(struct bnx2x_fastpath *fp,
540 dma_unmap_addr(cons_rx_buf, mapping)); 584 dma_unmap_addr(cons_rx_buf, mapping));
541 *prod_bd = *cons_bd; 585 *prod_bd = *cons_bd;
542} 586}
543 587static inline void bnx2x_free_rx_sge_range(struct bnx2x *bp,
544static inline void bnx2x_clear_sge_mask_next_elems(struct bnx2x_fastpath *fp) 588 struct bnx2x_fastpath *fp, int last)
545{ 589{
546 int i, j; 590 int i;
547
548 for (i = 1; i <= NUM_RX_SGE_PAGES; i++) {
549 int idx = RX_SGE_CNT * i - 1;
550 591
551 for (j = 0; j < 2; j++) { 592 for (i = 0; i < last; i++)
552 SGE_MASK_CLEAR_BIT(fp, idx); 593 bnx2x_free_rx_sge(bp, fp, i);
553 idx--;
554 }
555 }
556} 594}
557 595
558static inline void bnx2x_init_sge_ring_bit_mask(struct bnx2x_fastpath *fp)
559{
560 /* Set the mask to all 1-s: it's faster to compare to 0 than to 0xf-s */
561 memset(fp->sge_mask, 0xff,
562 (NUM_RX_SGE >> RX_SGE_MASK_ELEM_SHIFT)*sizeof(u64));
563
564 /* Clear the two last indices in the page to 1:
565 these are the indices that correspond to the "next" element,
566 hence will never be indicated and should be removed from
567 the calculations. */
568 bnx2x_clear_sge_mask_next_elems(fp);
569}
570static inline void bnx2x_free_tpa_pool(struct bnx2x *bp, 596static inline void bnx2x_free_tpa_pool(struct bnx2x *bp,
571 struct bnx2x_fastpath *fp, int last) 597 struct bnx2x_fastpath *fp, int last)
572{ 598{
@@ -592,7 +618,7 @@ static inline void bnx2x_free_tpa_pool(struct bnx2x *bp,
592} 618}
593 619
594 620
595static inline void bnx2x_init_tx_ring(struct bnx2x *bp) 621static inline void bnx2x_init_tx_rings(struct bnx2x *bp)
596{ 622{
597 int i, j; 623 int i, j;
598 624
@@ -611,7 +637,7 @@ static inline void bnx2x_init_tx_ring(struct bnx2x *bp)
611 BCM_PAGE_SIZE*(i % NUM_TX_RINGS))); 637 BCM_PAGE_SIZE*(i % NUM_TX_RINGS)));
612 } 638 }
613 639
614 fp->tx_db.data.header.header = DOORBELL_HDR_DB_TYPE; 640 SET_FLAG(fp->tx_db.data.header.header, DOORBELL_HDR_DB_TYPE, 1);
615 fp->tx_db.data.zero_fill1 = 0; 641 fp->tx_db.data.zero_fill1 = 0;
616 fp->tx_db.data.prod = 0; 642 fp->tx_db.data.prod = 0;
617 643
@@ -619,22 +645,94 @@ static inline void bnx2x_init_tx_ring(struct bnx2x *bp)
619 fp->tx_pkt_cons = 0; 645 fp->tx_pkt_cons = 0;
620 fp->tx_bd_prod = 0; 646 fp->tx_bd_prod = 0;
621 fp->tx_bd_cons = 0; 647 fp->tx_bd_cons = 0;
622 fp->tx_cons_sb = BNX2X_TX_SB_INDEX;
623 fp->tx_pkt = 0; 648 fp->tx_pkt = 0;
624 } 649 }
625} 650}
626static inline int bnx2x_has_rx_work(struct bnx2x_fastpath *fp) 651static inline void bnx2x_set_next_page_rx_bd(struct bnx2x_fastpath *fp)
627{ 652{
628 u16 rx_cons_sb; 653 int i;
629 654
630 /* Tell compiler that status block fields can change */ 655 for (i = 1; i <= NUM_RX_RINGS; i++) {
631 barrier(); 656 struct eth_rx_bd *rx_bd;
632 rx_cons_sb = le16_to_cpu(*fp->rx_cons_sb); 657
633 if ((rx_cons_sb & MAX_RCQ_DESC_CNT) == MAX_RCQ_DESC_CNT) 658 rx_bd = &fp->rx_desc_ring[RX_DESC_CNT * i - 2];
634 rx_cons_sb++; 659 rx_bd->addr_hi =
635 return fp->rx_comp_cons != rx_cons_sb; 660 cpu_to_le32(U64_HI(fp->rx_desc_mapping +
661 BCM_PAGE_SIZE*(i % NUM_RX_RINGS)));
662 rx_bd->addr_lo =
663 cpu_to_le32(U64_LO(fp->rx_desc_mapping +
664 BCM_PAGE_SIZE*(i % NUM_RX_RINGS)));
665 }
636} 666}
637 667
668static inline void bnx2x_set_next_page_sgl(struct bnx2x_fastpath *fp)
669{
670 int i;
671
672 for (i = 1; i <= NUM_RX_SGE_PAGES; i++) {
673 struct eth_rx_sge *sge;
674
675 sge = &fp->rx_sge_ring[RX_SGE_CNT * i - 2];
676 sge->addr_hi =
677 cpu_to_le32(U64_HI(fp->rx_sge_mapping +
678 BCM_PAGE_SIZE*(i % NUM_RX_SGE_PAGES)));
679
680 sge->addr_lo =
681 cpu_to_le32(U64_LO(fp->rx_sge_mapping +
682 BCM_PAGE_SIZE*(i % NUM_RX_SGE_PAGES)));
683 }
684}
685
686static inline void bnx2x_set_next_page_rx_cq(struct bnx2x_fastpath *fp)
687{
688 int i;
689 for (i = 1; i <= NUM_RCQ_RINGS; i++) {
690 struct eth_rx_cqe_next_page *nextpg;
691
692 nextpg = (struct eth_rx_cqe_next_page *)
693 &fp->rx_comp_ring[RCQ_DESC_CNT * i - 1];
694 nextpg->addr_hi =
695 cpu_to_le32(U64_HI(fp->rx_comp_mapping +
696 BCM_PAGE_SIZE*(i % NUM_RCQ_RINGS)));
697 nextpg->addr_lo =
698 cpu_to_le32(U64_LO(fp->rx_comp_mapping +
699 BCM_PAGE_SIZE*(i % NUM_RCQ_RINGS)));
700 }
701}
702
703
704
705static inline void __storm_memset_struct(struct bnx2x *bp,
706 u32 addr, size_t size, u32 *data)
707{
708 int i;
709 for (i = 0; i < size/4; i++)
710 REG_WR(bp, addr + (i * 4), data[i]);
711}
712
713static inline void storm_memset_mac_filters(struct bnx2x *bp,
714 struct tstorm_eth_mac_filter_config *mac_filters,
715 u16 abs_fid)
716{
717 size_t size = sizeof(struct tstorm_eth_mac_filter_config);
718
719 u32 addr = BAR_TSTRORM_INTMEM +
720 TSTORM_MAC_FILTER_CONFIG_OFFSET(abs_fid);
721
722 __storm_memset_struct(bp, addr, size, (u32 *)mac_filters);
723}
724
725static inline void storm_memset_cmng(struct bnx2x *bp,
726 struct cmng_struct_per_port *cmng,
727 u8 port)
728{
729 size_t size = sizeof(struct cmng_struct_per_port);
730
731 u32 addr = BAR_XSTRORM_INTMEM +
732 XSTORM_CMNG_PER_PORT_VARS_OFFSET(port);
733
734 __storm_memset_struct(bp, addr, size, (u32 *)cmng);
735}
638/* HW Lock for shared dual port PHYs */ 736/* HW Lock for shared dual port PHYs */
639void bnx2x_acquire_phy_lock(struct bnx2x *bp); 737void bnx2x_acquire_phy_lock(struct bnx2x *bp);
640void bnx2x_release_phy_lock(struct bnx2x *bp); 738void bnx2x_release_phy_lock(struct bnx2x *bp);
@@ -659,4 +757,16 @@ int bnx2x_nic_unload(struct bnx2x *bp, int unload_mode);
659int bnx2x_nic_load(struct bnx2x *bp, int load_mode); 757int bnx2x_nic_load(struct bnx2x *bp, int load_mode);
660int bnx2x_set_power_state(struct bnx2x *bp, pci_power_t state); 758int bnx2x_set_power_state(struct bnx2x *bp, pci_power_t state);
661 759
760/**
761 * Allocate/release memories outsize main driver structure
762 *
763 * @param bp
764 *
765 * @return int
766 */
767int __devinit bnx2x_alloc_mem_bp(struct bnx2x *bp);
768void bnx2x_free_mem_bp(struct bnx2x *bp);
769
770#define BNX2X_FW_IP_HDR_ALIGN_PAD 2 /* FW places hdr with this padding */
771
662#endif /* BNX2X_CMN_H */ 772#endif /* BNX2X_CMN_H */