@@ -1239,13 +1239,17 @@ static int bnxt_async_event_process(struct bnxt *bp,
12391239 switch (event_id ) {
12401240 case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_STATUS_CHANGE :
12411241 set_bit (BNXT_LINK_CHNG_SP_EVENT , & bp -> sp_event );
1242- schedule_work (& bp -> sp_task );
1242+ break ;
1243+ case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PF_DRVR_UNLOAD :
1244+ set_bit (BNXT_HWRM_PF_UNLOAD_SP_EVENT , & bp -> sp_event );
12431245 break ;
12441246 default :
12451247 netdev_err (bp -> dev , "unhandled ASYNC event (id 0x%x)\n" ,
12461248 event_id );
1247- break ;
1249+ goto async_event_process_exit ;
12481250 }
1251+ schedule_work (& bp -> sp_task );
1252+ async_event_process_exit :
12491253 return 0 ;
12501254}
12511255
@@ -2596,28 +2600,27 @@ static int bnxt_alloc_mem(struct bnxt *bp, bool irq_re_init)
25962600void bnxt_hwrm_cmd_hdr_init (struct bnxt * bp , void * request , u16 req_type ,
25972601 u16 cmpl_ring , u16 target_id )
25982602{
2599- struct hwrm_cmd_req_hdr * req = request ;
2603+ struct input * req = request ;
26002604
2601- req -> cmpl_ring_req_type =
2602- cpu_to_le32 ( req_type | (cmpl_ring << HWRM_CMPL_RING_SFT ) );
2603- req -> target_id_seq_id = cpu_to_le32 (target_id << HWRM_TARGET_FID_SFT );
2605+ req -> req_type = cpu_to_le16 ( req_type );
2606+ req -> cmpl_ring = cpu_to_le16 (cmpl_ring );
2607+ req -> target_id = cpu_to_le16 (target_id );
26042608 req -> resp_addr = cpu_to_le64 (bp -> hwrm_cmd_resp_dma_addr );
26052609}
26062610
2607- int _hwrm_send_message (struct bnxt * bp , void * msg , u32 msg_len , int timeout )
2611+ static int bnxt_hwrm_do_send_msg (struct bnxt * bp , void * msg , u32 msg_len ,
2612+ int timeout , bool silent )
26082613{
26092614 int i , intr_process , rc ;
2610- struct hwrm_cmd_req_hdr * req = msg ;
2615+ struct input * req = msg ;
26112616 u32 * data = msg ;
26122617 __le32 * resp_len , * valid ;
26132618 u16 cp_ring_id , len = 0 ;
26142619 struct hwrm_err_output * resp = bp -> hwrm_cmd_resp_addr ;
26152620
2616- req -> target_id_seq_id |= cpu_to_le32 (bp -> hwrm_cmd_seq ++ );
2621+ req -> seq_id = cpu_to_le16 (bp -> hwrm_cmd_seq ++ );
26172622 memset (resp , 0 , PAGE_SIZE );
2618- cp_ring_id = (le32_to_cpu (req -> cmpl_ring_req_type ) &
2619- HWRM_CMPL_RING_MASK ) >>
2620- HWRM_CMPL_RING_SFT ;
2623+ cp_ring_id = le16_to_cpu (req -> cmpl_ring );
26212624 intr_process = (cp_ring_id == INVALID_HW_RING_ID ) ? 0 : 1 ;
26222625
26232626 /* Write request msg to hwrm channel */
@@ -2628,12 +2631,14 @@ int _hwrm_send_message(struct bnxt *bp, void *msg, u32 msg_len, int timeout)
26282631
26292632 /* currently supports only one outstanding message */
26302633 if (intr_process )
2631- bp -> hwrm_intr_seq_id = le32_to_cpu (req -> target_id_seq_id ) &
2632- HWRM_SEQ_ID_MASK ;
2634+ bp -> hwrm_intr_seq_id = le16_to_cpu (req -> seq_id );
26332635
26342636 /* Ring channel doorbell */
26352637 writel (1 , bp -> bar0 + 0x100 );
26362638
2639+ if (!timeout )
2640+ timeout = DFLT_HWRM_CMD_TIMEOUT ;
2641+
26372642 i = 0 ;
26382643 if (intr_process ) {
26392644 /* Wait until hwrm response cmpl interrupt is processed */
@@ -2644,7 +2649,7 @@ int _hwrm_send_message(struct bnxt *bp, void *msg, u32 msg_len, int timeout)
26442649
26452650 if (bp -> hwrm_intr_seq_id != HWRM_SEQ_ID_INVALID ) {
26462651 netdev_err (bp -> dev , "Resp cmpl intr err msg: 0x%x\n" ,
2647- req -> cmpl_ring_req_type );
2652+ le16_to_cpu ( req -> req_type ) );
26482653 return -1 ;
26492654 }
26502655 } else {
@@ -2660,8 +2665,8 @@ int _hwrm_send_message(struct bnxt *bp, void *msg, u32 msg_len, int timeout)
26602665
26612666 if (i >= timeout ) {
26622667 netdev_err (bp -> dev , "Error (timeout: %d) msg {0x%x 0x%x} len:%d\n" ,
2663- timeout , req -> cmpl_ring_req_type ,
2664- req -> target_id_seq_id , * resp_len );
2668+ timeout , le16_to_cpu ( req -> req_type ) ,
2669+ le16_to_cpu ( req -> seq_id ) , * resp_len );
26652670 return -1 ;
26662671 }
26672672
@@ -2675,20 +2680,23 @@ int _hwrm_send_message(struct bnxt *bp, void *msg, u32 msg_len, int timeout)
26752680
26762681 if (i >= timeout ) {
26772682 netdev_err (bp -> dev , "Error (timeout: %d) msg {0x%x 0x%x} len:%d v:%d\n" ,
2678- timeout , req -> cmpl_ring_req_type ,
2679- req -> target_id_seq_id , len , * valid );
2683+ timeout , le16_to_cpu ( req -> req_type ) ,
2684+ le16_to_cpu ( req -> seq_id ) , len , * valid );
26802685 return -1 ;
26812686 }
26822687 }
26832688
26842689 rc = le16_to_cpu (resp -> error_code );
2685- if (rc ) {
2690+ if (rc && ! silent )
26862691 netdev_err (bp -> dev , "hwrm req_type 0x%x seq id 0x%x error 0x%x\n" ,
26872692 le16_to_cpu (resp -> req_type ),
26882693 le16_to_cpu (resp -> seq_id ), rc );
2689- return rc ;
2690- }
2691- return 0 ;
2694+ return rc ;
2695+ }
2696+
2697+ int _hwrm_send_message (struct bnxt * bp , void * msg , u32 msg_len , int timeout )
2698+ {
2699+ return bnxt_hwrm_do_send_msg (bp , msg , msg_len , timeout , false);
26922700}
26932701
26942702int hwrm_send_message (struct bnxt * bp , void * msg , u32 msg_len , int timeout )
@@ -2701,6 +2709,17 @@ int hwrm_send_message(struct bnxt *bp, void *msg, u32 msg_len, int timeout)
27012709 return rc ;
27022710}
27032711
2712+ int hwrm_send_message_silent (struct bnxt * bp , void * msg , u32 msg_len ,
2713+ int timeout )
2714+ {
2715+ int rc ;
2716+
2717+ mutex_lock (& bp -> hwrm_cmd_lock );
2718+ rc = bnxt_hwrm_do_send_msg (bp , msg , msg_len , timeout , true);
2719+ mutex_unlock (& bp -> hwrm_cmd_lock );
2720+ return rc ;
2721+ }
2722+
27042723static int bnxt_hwrm_func_drv_rgtr (struct bnxt * bp )
27052724{
27062725 struct hwrm_func_drv_rgtr_input req = {0 };
@@ -3517,47 +3536,82 @@ static void bnxt_hwrm_ring_free(struct bnxt *bp, bool close_path)
35173536 }
35183537}
35193538
3539+ static void bnxt_hwrm_set_coal_params (struct bnxt * bp , u32 max_bufs ,
3540+ u32 buf_tmrs , u16 flags ,
3541+ struct hwrm_ring_cmpl_ring_cfg_aggint_params_input * req )
3542+ {
3543+ req -> flags = cpu_to_le16 (flags );
3544+ req -> num_cmpl_dma_aggr = cpu_to_le16 ((u16 )max_bufs );
3545+ req -> num_cmpl_dma_aggr_during_int = cpu_to_le16 (max_bufs >> 16 );
3546+ req -> cmpl_aggr_dma_tmr = cpu_to_le16 ((u16 )buf_tmrs );
3547+ req -> cmpl_aggr_dma_tmr_during_int = cpu_to_le16 (buf_tmrs >> 16 );
3548+ /* Minimum time between 2 interrupts set to buf_tmr x 2 */
3549+ req -> int_lat_tmr_min = cpu_to_le16 ((u16 )buf_tmrs * 2 );
3550+ req -> int_lat_tmr_max = cpu_to_le16 ((u16 )buf_tmrs * 4 );
3551+ req -> num_cmpl_aggr_int = cpu_to_le16 ((u16 )max_bufs * 4 );
3552+ }
3553+
35203554int bnxt_hwrm_set_coal (struct bnxt * bp )
35213555{
35223556 int i , rc = 0 ;
3523- struct hwrm_ring_cmpl_ring_cfg_aggint_params_input req = {0 };
3557+ struct hwrm_ring_cmpl_ring_cfg_aggint_params_input req_rx = {0 },
3558+ req_tx = {0 }, * req ;
35243559 u16 max_buf , max_buf_irq ;
35253560 u16 buf_tmr , buf_tmr_irq ;
35263561 u32 flags ;
35273562
3528- bnxt_hwrm_cmd_hdr_init (bp , & req , HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS ,
3529- -1 , -1 );
3563+ bnxt_hwrm_cmd_hdr_init (bp , & req_rx ,
3564+ HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS , -1 , -1 );
3565+ bnxt_hwrm_cmd_hdr_init (bp , & req_tx ,
3566+ HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS , -1 , -1 );
35303567
3531- /* Each rx completion (2 records) should be DMAed immediately */
3532- max_buf = min_t (u16 , bp -> coal_bufs / 4 , 2 );
3568+ /* Each rx completion (2 records) should be DMAed immediately.
3569+ * DMA 1/4 of the completion buffers at a time.
3570+ */
3571+ max_buf = min_t (u16 , bp -> rx_coal_bufs / 4 , 2 );
35333572 /* max_buf must not be zero */
35343573 max_buf = clamp_t (u16 , max_buf , 1 , 63 );
3535- max_buf_irq = clamp_t (u16 , bp -> coal_bufs_irq , 1 , 63 );
3536- buf_tmr = max_t (u16 , bp -> coal_ticks / 4 , 1 );
3537- buf_tmr_irq = max_t (u16 , bp -> coal_ticks_irq , 1 );
3574+ max_buf_irq = clamp_t (u16 , bp -> rx_coal_bufs_irq , 1 , 63 );
3575+ buf_tmr = BNXT_USEC_TO_COAL_TIMER (bp -> rx_coal_ticks );
3576+ /* buf timer set to 1/4 of interrupt timer */
3577+ buf_tmr = max_t (u16 , buf_tmr / 4 , 1 );
3578+ buf_tmr_irq = BNXT_USEC_TO_COAL_TIMER (bp -> rx_coal_ticks_irq );
3579+ buf_tmr_irq = max_t (u16 , buf_tmr_irq , 1 );
35383580
35393581 flags = RING_CMPL_RING_CFG_AGGINT_PARAMS_REQ_FLAGS_TIMER_RESET ;
35403582
35413583 /* RING_IDLE generates more IRQs for lower latency. Enable it only
35423584 * if coal_ticks is less than 25 us.
35433585 */
3544- if (BNXT_COAL_TIMER_TO_USEC ( bp -> coal_ticks ) < 25 )
3586+ if (bp -> rx_coal_ticks < 25 )
35453587 flags |= RING_CMPL_RING_CFG_AGGINT_PARAMS_REQ_FLAGS_RING_IDLE ;
35463588
3547- req .flags = cpu_to_le16 (flags );
3548- req .num_cmpl_dma_aggr = cpu_to_le16 (max_buf );
3549- req .num_cmpl_dma_aggr_during_int = cpu_to_le16 (max_buf_irq );
3550- req .cmpl_aggr_dma_tmr = cpu_to_le16 (buf_tmr );
3551- req .cmpl_aggr_dma_tmr_during_int = cpu_to_le16 (buf_tmr_irq );
3552- req .int_lat_tmr_min = cpu_to_le16 (buf_tmr );
3553- req .int_lat_tmr_max = cpu_to_le16 (bp -> coal_ticks );
3554- req .num_cmpl_aggr_int = cpu_to_le16 (bp -> coal_bufs );
3589+ bnxt_hwrm_set_coal_params (bp , max_buf_irq << 16 | max_buf ,
3590+ buf_tmr_irq << 16 | buf_tmr , flags , & req_rx );
3591+
3592+ /* max_buf must not be zero */
3593+ max_buf = clamp_t (u16 , bp -> tx_coal_bufs , 1 , 63 );
3594+ max_buf_irq = clamp_t (u16 , bp -> tx_coal_bufs_irq , 1 , 63 );
3595+ buf_tmr = BNXT_USEC_TO_COAL_TIMER (bp -> tx_coal_ticks );
3596+ /* buf timer set to 1/4 of interrupt timer */
3597+ buf_tmr = max_t (u16 , buf_tmr / 4 , 1 );
3598+ buf_tmr_irq = BNXT_USEC_TO_COAL_TIMER (bp -> tx_coal_ticks_irq );
3599+ buf_tmr_irq = max_t (u16 , buf_tmr_irq , 1 );
3600+
3601+ flags = RING_CMPL_RING_CFG_AGGINT_PARAMS_REQ_FLAGS_TIMER_RESET ;
3602+ bnxt_hwrm_set_coal_params (bp , max_buf_irq << 16 | max_buf ,
3603+ buf_tmr_irq << 16 | buf_tmr , flags , & req_tx );
35553604
35563605 mutex_lock (& bp -> hwrm_cmd_lock );
35573606 for (i = 0 ; i < bp -> cp_nr_rings ; i ++ ) {
3558- req . ring_id = cpu_to_le16 ( bp -> grp_info [i ]. cp_fw_ring_id ) ;
3607+ struct bnxt_napi * bnapi = bp -> bnapi [i ];
35593608
3560- rc = _hwrm_send_message (bp , & req , sizeof (req ),
3609+ req = & req_rx ;
3610+ if (!bnapi -> rx_ring )
3611+ req = & req_tx ;
3612+ req -> ring_id = cpu_to_le16 (bp -> grp_info [i ].cp_fw_ring_id );
3613+
3614+ rc = _hwrm_send_message (bp , req , sizeof (* req ),
35613615 HWRM_CMD_TIMEOUT );
35623616 if (rc )
35633617 break ;
@@ -3766,10 +3820,14 @@ static int bnxt_hwrm_ver_get(struct bnxt *bp)
37663820 resp -> hwrm_intf_upd );
37673821 netdev_warn (bp -> dev , "Please update firmware with HWRM interface 1.0.0 or newer.\n" );
37683822 }
3769- snprintf (bp -> fw_ver_str , BC_HWRM_STR_LEN , "bc %d.%d.%d rm %d.%d.%d" ,
3823+ snprintf (bp -> fw_ver_str , BC_HWRM_STR_LEN , "%d.%d.%d/ %d.%d.%d" ,
37703824 resp -> hwrm_fw_maj , resp -> hwrm_fw_min , resp -> hwrm_fw_bld ,
37713825 resp -> hwrm_intf_maj , resp -> hwrm_intf_min , resp -> hwrm_intf_upd );
37723826
3827+ bp -> hwrm_cmd_timeout = le16_to_cpu (resp -> def_req_timeout );
3828+ if (!bp -> hwrm_cmd_timeout )
3829+ bp -> hwrm_cmd_timeout = DFLT_HWRM_CMD_TIMEOUT ;
3830+
37733831hwrm_ver_get_exit :
37743832 mutex_unlock (& bp -> hwrm_cmd_lock );
37753833 return rc ;
@@ -5291,10 +5349,16 @@ static int bnxt_init_board(struct pci_dev *pdev, struct net_device *dev)
52915349 bp -> rx_ring_size = BNXT_DEFAULT_RX_RING_SIZE ;
52925350 bp -> tx_ring_size = BNXT_DEFAULT_TX_RING_SIZE ;
52935351
5294- bp -> coal_ticks = BNXT_USEC_TO_COAL_TIMER (4 );
5295- bp -> coal_bufs = 20 ;
5296- bp -> coal_ticks_irq = BNXT_USEC_TO_COAL_TIMER (1 );
5297- bp -> coal_bufs_irq = 2 ;
5352+ /* tick values in micro seconds */
5353+ bp -> rx_coal_ticks = 12 ;
5354+ bp -> rx_coal_bufs = 30 ;
5355+ bp -> rx_coal_ticks_irq = 1 ;
5356+ bp -> rx_coal_bufs_irq = 2 ;
5357+
5358+ bp -> tx_coal_ticks = 25 ;
5359+ bp -> tx_coal_bufs = 30 ;
5360+ bp -> tx_coal_ticks_irq = 2 ;
5361+ bp -> tx_coal_bufs_irq = 2 ;
52985362
52995363 init_timer (& bp -> timer );
53005364 bp -> timer .data = (unsigned long )bp ;
@@ -5559,6 +5623,8 @@ static void bnxt_cfg_ntp_filters(struct bnxt *bp)
55595623 }
55605624 }
55615625 }
5626+ if (test_and_clear_bit (BNXT_HWRM_PF_UNLOAD_SP_EVENT , & bp -> sp_event ))
5627+ netdev_info (bp -> dev , "Receive PF driver unload event!" );
55625628}
55635629
55645630#else
@@ -5674,7 +5740,6 @@ static int bnxt_probe_phy(struct bnxt *bp)
56745740{
56755741 int rc = 0 ;
56765742 struct bnxt_link_info * link_info = & bp -> link_info ;
5677- char phy_ver [PHY_VER_STR_LEN ];
56785743
56795744 rc = bnxt_update_link (bp , false);
56805745 if (rc ) {
@@ -5694,11 +5759,6 @@ static int bnxt_probe_phy(struct bnxt *bp)
56945759 link_info -> req_duplex = link_info -> duplex_setting ;
56955760 link_info -> req_flow_ctrl = link_info -> force_pause_setting ;
56965761 }
5697- snprintf (phy_ver , PHY_VER_STR_LEN , " ph %d.%d.%d" ,
5698- link_info -> phy_ver [0 ],
5699- link_info -> phy_ver [1 ],
5700- link_info -> phy_ver [2 ]);
5701- strcat (bp -> fw_ver_str , phy_ver );
57025762 return rc ;
57035763}
57045764
0 commit comments