1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* Copyright (c) 2025 Broadcom */ 3 4 #ifndef _BNGE_RESC_H_ 5 #define _BNGE_RESC_H_ 6 7 #include "bnge_netdev.h" 8 #include "bnge_rmem.h" 9 10 struct bnge_hw_resc { 11 u16 min_rsscos_ctxs; 12 u16 max_rsscos_ctxs; 13 u16 resv_rsscos_ctxs; 14 u16 min_cp_rings; 15 u16 max_cp_rings; 16 u16 resv_cp_rings; 17 u16 min_tx_rings; 18 u16 max_tx_rings; 19 u16 resv_tx_rings; 20 u16 max_tx_sch_inputs; 21 u16 min_rx_rings; 22 u16 max_rx_rings; 23 u16 resv_rx_rings; 24 u16 min_hw_ring_grps; 25 u16 max_hw_ring_grps; 26 u16 resv_hw_ring_grps; 27 u16 min_l2_ctxs; 28 u16 max_l2_ctxs; 29 u16 min_vnics; 30 u16 max_vnics; 31 u16 resv_vnics; 32 u16 min_stat_ctxs; 33 u16 max_stat_ctxs; 34 u16 resv_stat_ctxs; 35 u16 max_nqs; 36 u16 max_irqs; 37 u16 resv_irqs; 38 u32 max_encap_records; 39 u32 max_decap_records; 40 u32 max_tx_em_flows; 41 u32 max_tx_wm_flows; 42 u32 max_rx_em_flows; 43 u32 max_rx_wm_flows; 44 }; 45 46 struct bnge_hw_rings { 47 u16 tx; 48 u16 rx; 49 u16 grp; 50 u16 nq; 51 u16 cmpl; 52 u16 stat; 53 u16 vnic; 54 u16 rss_ctx; 55 }; 56 57 /* "TXRX", 2 hypens, plus maximum integer */ 58 #define BNGE_IRQ_NAME_EXTRA 17 59 struct bnge_irq { 60 irq_handler_t handler; 61 unsigned int vector; 62 u8 requested:1; 63 u8 have_cpumask:1; 64 char name[IFNAMSIZ + BNGE_IRQ_NAME_EXTRA]; 65 cpumask_var_t cpu_mask; 66 }; 67 68 int bnge_reserve_rings(struct bnge_dev *bd); 69 int bnge_fix_rings_count(u16 *rx, u16 *tx, u16 max, bool shared); 70 int bnge_alloc_irqs(struct bnge_dev *bd); 71 void bnge_free_irqs(struct bnge_dev *bd); 72 int bnge_net_init_dflt_config(struct bnge_dev *bd); 73 void bnge_net_uninit_dflt_config(struct bnge_dev *bd); 74 void bnge_aux_init_dflt_config(struct bnge_dev *bd); 75 76 static inline u32 bnge_adjust_pow_two(u32 total_ent,u16 ent_per_blk)77bnge_adjust_pow_two(u32 total_ent, u16 ent_per_blk) 78 { 79 u32 blks = total_ent / ent_per_blk; 80 81 if (blks == 0 || blks == 1) 82 return ++blks; 83 84 if (!is_power_of_2(blks)) 85 blks = roundup_pow_of_two(blks); 86 87 return blks; 88 } 89 90 #define BNGE_MAX_ROCE_MSIX 64 91 #define BNGE_MIN_ROCE_CP_RINGS 2 92 #define BNGE_MIN_ROCE_STAT_CTXS 1 93 94 #endif /* _BNGE_RESC_H_ */ 95