MCPcopy Create free account
hub / github.com/F-Stack/f-stack / i40e_update_flow_control

Function i40e_update_flow_control

dpdk/drivers/net/i40e/i40e_ethdev.c:6194–6248  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6192}
6193
6194static int
6195i40e_update_flow_control(struct i40e_hw *hw)
6196{
6197#define I40E_LINK_PAUSE_RXTX (I40E_AQ_LINK_PAUSE_RX | I40E_AQ_LINK_PAUSE_TX)
6198 struct i40e_link_status link_status;
6199 uint32_t rxfc = 0, txfc = 0, reg;
6200 uint8_t an_info;
6201 int ret;
6202
6203 memset(&link_status, 0, sizeof(link_status));
6204 ret = i40e_aq_get_link_info(hw, FALSE, &link_status, NULL);
6205 if (ret != I40E_SUCCESS) {
6206 PMD_DRV_LOG(ERR, "Failed to get link status information");
6207 goto write_reg; /* Disable flow control */
6208 }
6209
6210 an_info = hw->phy.link_info.an_info;
6211 if (!(an_info & I40E_AQ_AN_COMPLETED)) {
6212 PMD_DRV_LOG(INFO, "Link auto negotiation not completed");
6213 ret = I40E_ERR_NOT_READY;
6214 goto write_reg; /* Disable flow control */
6215 }
6216 /**
6217 * If link auto negotiation is enabled, flow control needs to
6218 * be configured according to it
6219 */
6220 switch (an_info & I40E_LINK_PAUSE_RXTX) {
6221 case I40E_LINK_PAUSE_RXTX:
6222 rxfc = 1;
6223 txfc = 1;
6224 hw->fc.current_mode = I40E_FC_FULL;
6225 break;
6226 case I40E_AQ_LINK_PAUSE_RX:
6227 rxfc = 1;
6228 hw->fc.current_mode = I40E_FC_RX_PAUSE;
6229 break;
6230 case I40E_AQ_LINK_PAUSE_TX:
6231 txfc = 1;
6232 hw->fc.current_mode = I40E_FC_TX_PAUSE;
6233 break;
6234 default:
6235 hw->fc.current_mode = I40E_FC_NONE;
6236 break;
6237 }
6238
6239write_reg:
6240 I40E_WRITE_REG(hw, I40E_PRTDCB_FCCFG,
6241 txfc << I40E_PRTDCB_FCCFG_TFCE_SHIFT);
6242 reg = I40E_READ_REG(hw, I40E_PRTDCB_MFLCN);
6243 reg &= ~I40E_PRTDCB_MFLCN_RFCE_MASK;
6244 reg |= rxfc << I40E_PRTDCB_MFLCN_RFCE_SHIFT;
6245 I40E_WRITE_REG(hw, I40E_PRTDCB_MFLCN, reg);
6246
6247 return ret;
6248}
6249
6250/* PF setup */
6251static int

Callers 1

i40e_pf_setupFunction · 0.85

Calls 2

memsetFunction · 0.85
i40e_aq_get_link_infoFunction · 0.85

Tested by

no test coverage detected