Skip to content

Commit 4244910

Browse files
refactormanJeff Kirsher
authored andcommitted
ice: Call ice_aq_set_mac_cfg
As per the specification, the driver needs to call set_mac_cfg (opcode 0x0603) to be able to exercise jumbo frames. Call the function during initialization and the post reset rebuild flow. Signed-off-by: Anirudh Venkataramanan <[email protected]> Signed-off-by: Tony Nguyen <[email protected]> Tested-by: Andrew Bowers <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent 28bf267 commit 4244910

File tree

5 files changed

+103
-0
lines changed

5 files changed

+103
-0
lines changed

drivers/net/ethernet/intel/ice/ice_adminq_cmd.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,6 +1068,25 @@ struct ice_aqc_set_phy_cfg_data {
10681068
u8 rsvd1;
10691069
};
10701070

1071+
/* Set MAC Config command data structure (direct 0x0603) */
1072+
struct ice_aqc_set_mac_cfg {
1073+
__le16 max_frame_size;
1074+
u8 params;
1075+
#define ICE_AQ_SET_MAC_PACE_S 3
1076+
#define ICE_AQ_SET_MAC_PACE_M (0xF << ICE_AQ_SET_MAC_PACE_S)
1077+
#define ICE_AQ_SET_MAC_PACE_TYPE_M BIT(7)
1078+
#define ICE_AQ_SET_MAC_PACE_TYPE_RATE 0
1079+
#define ICE_AQ_SET_MAC_PACE_TYPE_FIXED ICE_AQ_SET_MAC_PACE_TYPE_M
1080+
u8 tx_tmr_priority;
1081+
__le16 tx_tmr_value;
1082+
__le16 fc_refresh_threshold;
1083+
u8 drop_opts;
1084+
#define ICE_AQ_SET_MAC_AUTO_DROP_MASK BIT(0)
1085+
#define ICE_AQ_SET_MAC_AUTO_DROP_NONE 0
1086+
#define ICE_AQ_SET_MAC_AUTO_DROP_BLOCKING_PKTS BIT(0)
1087+
u8 reserved[7];
1088+
};
1089+
10711090
/* Restart AN command data structure (direct 0x0605)
10721091
* Also used for response, with only the lport_num field present.
10731092
*/
@@ -1774,6 +1793,7 @@ struct ice_aq_desc {
17741793
struct ice_aqc_download_pkg download_pkg;
17751794
struct ice_aqc_set_mac_lb set_mac_lb;
17761795
struct ice_aqc_alloc_free_res_cmd sw_res_ctrl;
1796+
struct ice_aqc_set_mac_cfg set_mac_cfg;
17771797
struct ice_aqc_set_event_mask set_event_mask;
17781798
struct ice_aqc_get_link_status get_link_status;
17791799
struct ice_aqc_event_lan_overflow lan_overflow;
@@ -1870,6 +1890,7 @@ enum ice_adminq_opc {
18701890
/* PHY commands */
18711891
ice_aqc_opc_get_phy_caps = 0x0600,
18721892
ice_aqc_opc_set_phy_cfg = 0x0601,
1893+
ice_aqc_opc_set_mac_cfg = 0x0603,
18731894
ice_aqc_opc_restart_an = 0x0605,
18741895
ice_aqc_opc_get_link_status = 0x0607,
18751896
ice_aqc_opc_set_event_mask = 0x0613,

drivers/net/ethernet/intel/ice/ice_common.c

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,71 @@ ice_aq_get_link_info(struct ice_port_info *pi, bool ena_lse,
315315
return 0;
316316
}
317317

318+
/**
319+
* ice_fill_tx_timer_and_fc_thresh
320+
* @hw: pointer to the HW struct
321+
* @cmd: pointer to MAC cfg structure
322+
*
323+
* Add Tx timer and FC refresh threshold info to Set MAC Config AQ command
324+
* descriptor
325+
*/
326+
static void
327+
ice_fill_tx_timer_and_fc_thresh(struct ice_hw *hw,
328+
struct ice_aqc_set_mac_cfg *cmd)
329+
{
330+
u16 fc_thres_val, tx_timer_val;
331+
u32 val;
332+
333+
/* We read back the transmit timer and FC threshold value of
334+
* LFC. Thus, we will use index =
335+
* PRTMAC_HSEC_CTL_TX_PAUSE_QUANTA_MAX_INDEX.
336+
*
337+
* Also, because we are operating on transmit timer and FC
338+
* threshold of LFC, we don't turn on any bit in tx_tmr_priority
339+
*/
340+
#define IDX_OF_LFC PRTMAC_HSEC_CTL_TX_PAUSE_QUANTA_MAX_INDEX
341+
342+
/* Retrieve the transmit timer */
343+
val = rd32(hw, PRTMAC_HSEC_CTL_TX_PAUSE_QUANTA(IDX_OF_LFC));
344+
tx_timer_val = val &
345+
PRTMAC_HSEC_CTL_TX_PAUSE_QUANTA_HSEC_CTL_TX_PAUSE_QUANTA_M;
346+
cmd->tx_tmr_value = cpu_to_le16(tx_timer_val);
347+
348+
/* Retrieve the FC threshold */
349+
val = rd32(hw, PRTMAC_HSEC_CTL_TX_PAUSE_REFRESH_TIMER(IDX_OF_LFC));
350+
fc_thres_val = val & PRTMAC_HSEC_CTL_TX_PAUSE_REFRESH_TIMER_M;
351+
352+
cmd->fc_refresh_threshold = cpu_to_le16(fc_thres_val);
353+
}
354+
355+
/**
356+
* ice_aq_set_mac_cfg
357+
* @hw: pointer to the HW struct
358+
* @max_frame_size: Maximum Frame Size to be supported
359+
* @cd: pointer to command details structure or NULL
360+
*
361+
* Set MAC configuration (0x0603)
362+
*/
363+
enum ice_status
364+
ice_aq_set_mac_cfg(struct ice_hw *hw, u16 max_frame_size, struct ice_sq_cd *cd)
365+
{
366+
struct ice_aqc_set_mac_cfg *cmd;
367+
struct ice_aq_desc desc;
368+
369+
cmd = &desc.params.set_mac_cfg;
370+
371+
if (max_frame_size == 0)
372+
return ICE_ERR_PARAM;
373+
374+
ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_set_mac_cfg);
375+
376+
cmd->max_frame_size = cpu_to_le16(max_frame_size);
377+
378+
ice_fill_tx_timer_and_fc_thresh(hw, cmd);
379+
380+
return ice_aq_send_cmd(hw, &desc, NULL, 0, cd);
381+
}
382+
318383
/**
319384
* ice_init_fltr_mgmt_struct - initializes filter management list and locks
320385
* @hw: pointer to the HW struct
@@ -745,6 +810,10 @@ enum ice_status ice_init_hw(struct ice_hw *hw)
745810
status = ice_aq_manage_mac_read(hw, mac_buf, mac_buf_len, NULL);
746811
devm_kfree(ice_hw_to_dev(hw), mac_buf);
747812

813+
if (status)
814+
goto err_unroll_fltr_mgmt_struct;
815+
/* enable jumbo frame support at MAC level */
816+
status = ice_aq_set_mac_cfg(hw, ICE_AQ_SET_MAC_FRAME_SIZE_MAX, NULL);
748817
if (status)
749818
goto err_unroll_fltr_mgmt_struct;
750819
/* Obtain counter base index which would be used by flow director */

drivers/net/ethernet/intel/ice/ice_common.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ enum ice_status
108108
ice_aq_set_link_restart_an(struct ice_port_info *pi, bool ena_link,
109109
struct ice_sq_cd *cd);
110110
enum ice_status
111+
ice_aq_set_mac_cfg(struct ice_hw *hw, u16 max_frame_size, struct ice_sq_cd *cd);
112+
enum ice_status
111113
ice_aq_get_link_info(struct ice_port_info *pi, bool ena_lse,
112114
struct ice_link_status *link, struct ice_sq_cd *cd);
113115
enum ice_status

drivers/net/ethernet/intel/ice/ice_hw_autogen.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,11 @@
219219
#define VPLAN_TX_QBASE_VFNUMQ_M ICE_M(0xFF, 16)
220220
#define VPLAN_TXQ_MAPENA(_VF) (0x00073800 + ((_VF) * 4))
221221
#define VPLAN_TXQ_MAPENA_TX_ENA_M BIT(0)
222+
#define PRTMAC_HSEC_CTL_TX_PAUSE_QUANTA(_i) (0x001E36E0 + ((_i) * 32))
223+
#define PRTMAC_HSEC_CTL_TX_PAUSE_QUANTA_MAX_INDEX 8
224+
#define PRTMAC_HSEC_CTL_TX_PAUSE_QUANTA_HSEC_CTL_TX_PAUSE_QUANTA_M ICE_M(0xFFFF, 0)
225+
#define PRTMAC_HSEC_CTL_TX_PAUSE_REFRESH_TIMER(_i) (0x001E3800 + ((_i) * 32))
226+
#define PRTMAC_HSEC_CTL_TX_PAUSE_REFRESH_TIMER_M ICE_M(0xFFFF, 0)
222227
#define GL_MDCK_TX_TDPU 0x00049348
223228
#define GL_MDCK_TX_TDPU_RCU_ANTISPOOF_ITR_DIS_M BIT(1)
224229
#define GL_MDET_RX 0x00294C00

drivers/net/ethernet/intel/ice/ice_main.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4901,6 +4901,12 @@ static void ice_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type)
49014901
goto err_init_ctrlq;
49024902
}
49034903

4904+
ret = ice_aq_set_mac_cfg(hw, ICE_AQ_SET_MAC_FRAME_SIZE_MAX, NULL);
4905+
if (ret) {
4906+
dev_err(dev, "set_mac_cfg failed %s\n", ice_stat_str(ret));
4907+
goto err_init_ctrlq;
4908+
}
4909+
49044910
err = ice_sched_init_port(hw->port_info);
49054911
if (err)
49064912
goto err_sched_init_port;

0 commit comments

Comments
 (0)