Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/ice/ice_lib.c
/* SPDX-License-Identifier: BSD-3-Clause */ | /* SPDX-License-Identifier: BSD-3-Clause */ | ||||
/* Copyright (c) 2020, Intel Corporation | /* Copyright (c) 2021, Intel Corporation | ||||
* All rights reserved. | * All rights reserved. | ||||
* | * | ||||
* Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
* modification, are permitted provided that the following conditions are met: | * modification, are permitted provided that the following conditions are met: | ||||
* | * | ||||
* 1. Redistributions of source code must retain the above copyright notice, | * 1. Redistributions of source code must retain the above copyright notice, | ||||
* this list of conditions and the following disclaimer. | * this list of conditions and the following disclaimer. | ||||
* | * | ||||
▲ Show 20 Lines • Show All 2,190 Lines • ▼ Show 20 Lines | |||||
* | * | ||||
* Formats the NVM information including firmware version, API version, NVM | * Formats the NVM information including firmware version, API version, NVM | ||||
* version, the EETRACK id, and OEM specific version information into a string | * version, the EETRACK id, and OEM specific version information into a string | ||||
* buffer. | * buffer. | ||||
*/ | */ | ||||
static void | static void | ||||
ice_nvm_version_str(struct ice_hw *hw, struct sbuf *buf) | ice_nvm_version_str(struct ice_hw *hw, struct sbuf *buf) | ||||
{ | { | ||||
struct ice_nvm_info *nvm = &hw->nvm; | struct ice_nvm_info *nvm = &hw->flash.nvm; | ||||
struct ice_orom_info *orom = &nvm->orom; | struct ice_orom_info *orom = &hw->flash.orom; | ||||
struct ice_netlist_ver_info *netlist_ver = &hw->netlist_ver; | struct ice_netlist_info *netlist = &hw->flash.netlist; | ||||
/* Note that the netlist versions are stored in packed Binary Coded | /* Note that the netlist versions are stored in packed Binary Coded | ||||
* Decimal format. The use of '%x' will correctly display these as | * Decimal format. The use of '%x' will correctly display these as | ||||
* decimal numbers. This works because every 4 bits will be displayed | * decimal numbers. This works because every 4 bits will be displayed | ||||
* as a hexadecimal digit, and the BCD format will only use the values | * as a hexadecimal digit, and the BCD format will only use the values | ||||
* 0-9. | * 0-9. | ||||
*/ | */ | ||||
sbuf_printf(buf, | sbuf_printf(buf, | ||||
"fw %u.%u.%u api %u.%u nvm %x.%02x etid %08x netlist %x.%x.%x-%x.%x.%x.%04x oem %u.%u.%u", | "fw %u.%u.%u api %u.%u nvm %x.%02x etid %08x netlist %x.%x.%x-%x.%x.%x.%04x oem %u.%u.%u", | ||||
hw->fw_maj_ver, hw->fw_min_ver, hw->fw_patch, | hw->fw_maj_ver, hw->fw_min_ver, hw->fw_patch, | ||||
hw->api_maj_ver, hw->api_min_ver, | hw->api_maj_ver, hw->api_min_ver, | ||||
nvm->major_ver, nvm->minor_ver, nvm->eetrack, | nvm->major, nvm->minor, nvm->eetrack, | ||||
netlist_ver->major, netlist_ver->minor, | netlist->major, netlist->minor, | ||||
netlist_ver->type >> 16, netlist_ver->type & 0xFFFF, | netlist->type >> 16, netlist->type & 0xFFFF, | ||||
netlist_ver->rev, netlist_ver->cust_ver, netlist_ver->hash, | netlist->rev, netlist->cust_ver, netlist->hash, | ||||
orom->major, orom->build, orom->patch); | orom->major, orom->build, orom->patch); | ||||
} | } | ||||
/** | /** | ||||
* ice_print_nvm_version - Print the NVM info to the kernel message log | * ice_print_nvm_version - Print the NVM info to the kernel message log | ||||
* @sc: the device softc structure | * @sc: the device softc structure | ||||
* | * | ||||
* Format and print an NVM version string using ice_nvm_version_str(). | * Format and print an NVM version string using ice_nvm_version_str(). | ||||
▲ Show 20 Lines • Show All 3,652 Lines • ▼ Show 20 Lines | |||||
* rss_gethashconfig() to determine which flows to enable. If RSS kernel | * rss_gethashconfig() to determine which flows to enable. If RSS kernel | ||||
* support is not enabled, this macro will fall back to suitable defaults. | * support is not enabled, this macro will fall back to suitable defaults. | ||||
*/ | */ | ||||
static void | static void | ||||
ice_set_rss_flow_flds(struct ice_vsi *vsi) | ice_set_rss_flow_flds(struct ice_vsi *vsi) | ||||
{ | { | ||||
struct ice_softc *sc = vsi->sc; | struct ice_softc *sc = vsi->sc; | ||||
struct ice_hw *hw = &sc->hw; | struct ice_hw *hw = &sc->hw; | ||||
struct ice_rss_hash_cfg rss_cfg = { 0, 0, ICE_RSS_ANY_HEADERS, false }; | |||||
device_t dev = sc->dev; | device_t dev = sc->dev; | ||||
enum ice_status status; | enum ice_status status; | ||||
u_int rss_hash_config; | u_int rss_hash_config; | ||||
rss_hash_config = rss_gethashconfig(); | rss_hash_config = rss_gethashconfig(); | ||||
if (rss_hash_config & RSS_HASHTYPE_RSS_IPV4) { | if (rss_hash_config & RSS_HASHTYPE_RSS_IPV4) { | ||||
status = ice_add_rss_cfg(hw, vsi->idx, ICE_FLOW_HASH_IPV4, | rss_cfg.addl_hdrs = ICE_FLOW_SEG_HDR_IPV4; | ||||
ICE_FLOW_SEG_HDR_IPV4); | rss_cfg.hash_flds = ICE_FLOW_HASH_IPV4; | ||||
status = ice_add_rss_cfg(hw, vsi->idx, &rss_cfg); | |||||
if (status) | if (status) | ||||
device_printf(dev, | device_printf(dev, | ||||
"ice_add_rss_cfg on VSI %d failed for ipv4 flow, err %s aq_err %s\n", | "ice_add_rss_cfg on VSI %d failed for ipv4 flow, err %s aq_err %s\n", | ||||
vsi->idx, ice_status_str(status), ice_aq_str(hw->adminq.sq_last_status)); | vsi->idx, ice_status_str(status), ice_aq_str(hw->adminq.sq_last_status)); | ||||
} | } | ||||
if (rss_hash_config & RSS_HASHTYPE_RSS_TCP_IPV4) { | if (rss_hash_config & RSS_HASHTYPE_RSS_TCP_IPV4) { | ||||
status = ice_add_rss_cfg(hw, vsi->idx, ICE_HASH_TCP_IPV4, | rss_cfg.addl_hdrs = ICE_FLOW_SEG_HDR_IPV4 | ICE_FLOW_SEG_HDR_TCP; | ||||
ICE_FLOW_SEG_HDR_TCP | ICE_FLOW_SEG_HDR_IPV4); | rss_cfg.hash_flds = ICE_HASH_TCP_IPV4; | ||||
status = ice_add_rss_cfg(hw, vsi->idx, &rss_cfg); | |||||
if (status) | if (status) | ||||
device_printf(dev, | device_printf(dev, | ||||
"ice_add_rss_cfg on VSI %d failed for tcp4 flow, err %s aq_err %s\n", | "ice_add_rss_cfg on VSI %d failed for tcp4 flow, err %s aq_err %s\n", | ||||
vsi->idx, ice_status_str(status), ice_aq_str(hw->adminq.sq_last_status)); | vsi->idx, ice_status_str(status), ice_aq_str(hw->adminq.sq_last_status)); | ||||
} | } | ||||
if (rss_hash_config & RSS_HASHTYPE_RSS_UDP_IPV4) { | if (rss_hash_config & RSS_HASHTYPE_RSS_UDP_IPV4) { | ||||
status = ice_add_rss_cfg(hw, vsi->idx, ICE_HASH_UDP_IPV4, | rss_cfg.addl_hdrs = ICE_FLOW_SEG_HDR_IPV4 | ICE_FLOW_SEG_HDR_UDP; | ||||
ICE_FLOW_SEG_HDR_UDP | ICE_FLOW_SEG_HDR_IPV4); | rss_cfg.hash_flds = ICE_HASH_UDP_IPV4; | ||||
status = ice_add_rss_cfg(hw, vsi->idx, &rss_cfg); | |||||
if (status) | if (status) | ||||
device_printf(dev, | device_printf(dev, | ||||
"ice_add_rss_cfg on VSI %d failed for udp4 flow, err %s aq_err %s\n", | "ice_add_rss_cfg on VSI %d failed for udp4 flow, err %s aq_err %s\n", | ||||
vsi->idx, ice_status_str(status), ice_aq_str(hw->adminq.sq_last_status)); | vsi->idx, ice_status_str(status), ice_aq_str(hw->adminq.sq_last_status)); | ||||
} | } | ||||
if (rss_hash_config & (RSS_HASHTYPE_RSS_IPV6 | RSS_HASHTYPE_RSS_IPV6_EX)) { | if (rss_hash_config & (RSS_HASHTYPE_RSS_IPV6 | RSS_HASHTYPE_RSS_IPV6_EX)) { | ||||
status = ice_add_rss_cfg(hw, vsi->idx, ICE_FLOW_HASH_IPV6, | rss_cfg.addl_hdrs = ICE_FLOW_SEG_HDR_IPV6; | ||||
ICE_FLOW_SEG_HDR_IPV6); | rss_cfg.hash_flds = ICE_FLOW_HASH_IPV6; | ||||
status = ice_add_rss_cfg(hw, vsi->idx, &rss_cfg); | |||||
if (status) | if (status) | ||||
device_printf(dev, | device_printf(dev, | ||||
"ice_add_rss_cfg on VSI %d failed for ipv6 flow, err %s aq_err %s\n", | "ice_add_rss_cfg on VSI %d failed for ipv6 flow, err %s aq_err %s\n", | ||||
vsi->idx, ice_status_str(status), ice_aq_str(hw->adminq.sq_last_status)); | vsi->idx, ice_status_str(status), ice_aq_str(hw->adminq.sq_last_status)); | ||||
} | } | ||||
if (rss_hash_config & RSS_HASHTYPE_RSS_TCP_IPV6) { | if (rss_hash_config & RSS_HASHTYPE_RSS_TCP_IPV6) { | ||||
status = ice_add_rss_cfg(hw, vsi->idx, ICE_HASH_TCP_IPV6, | rss_cfg.addl_hdrs = ICE_FLOW_SEG_HDR_IPV6 | ICE_FLOW_SEG_HDR_TCP; | ||||
ICE_FLOW_SEG_HDR_TCP | ICE_FLOW_SEG_HDR_IPV6); | rss_cfg.hash_flds = ICE_HASH_TCP_IPV6; | ||||
status = ice_add_rss_cfg(hw, vsi->idx, &rss_cfg); | |||||
if (status) | if (status) | ||||
device_printf(dev, | device_printf(dev, | ||||
"ice_add_rss_cfg on VSI %d failed for tcp6 flow, err %s aq_err %s\n", | "ice_add_rss_cfg on VSI %d failed for tcp6 flow, err %s aq_err %s\n", | ||||
vsi->idx, ice_status_str(status), ice_aq_str(hw->adminq.sq_last_status)); | vsi->idx, ice_status_str(status), ice_aq_str(hw->adminq.sq_last_status)); | ||||
} | } | ||||
if (rss_hash_config & RSS_HASHTYPE_RSS_UDP_IPV6) { | if (rss_hash_config & RSS_HASHTYPE_RSS_UDP_IPV6) { | ||||
status = ice_add_rss_cfg(hw, vsi->idx, ICE_HASH_UDP_IPV6, | rss_cfg.addl_hdrs = ICE_FLOW_SEG_HDR_IPV6 | ICE_FLOW_SEG_HDR_UDP; | ||||
ICE_FLOW_SEG_HDR_UDP | ICE_FLOW_SEG_HDR_IPV6); | rss_cfg.hash_flds = ICE_HASH_UDP_IPV6; | ||||
status = ice_add_rss_cfg(hw, vsi->idx, &rss_cfg); | |||||
if (status) | if (status) | ||||
device_printf(dev, | device_printf(dev, | ||||
"ice_add_rss_cfg on VSI %d failed for udp6 flow, err %s aq_err %s\n", | "ice_add_rss_cfg on VSI %d failed for udp6 flow, err %s aq_err %s\n", | ||||
vsi->idx, ice_status_str(status), ice_aq_str(hw->adminq.sq_last_status)); | vsi->idx, ice_status_str(status), ice_aq_str(hw->adminq.sq_last_status)); | ||||
} | } | ||||
/* Warn about RSS hash types which are not supported */ | /* Warn about RSS hash types which are not supported */ | ||||
/* coverity[dead_error_condition] */ | /* coverity[dead_error_condition] */ | ||||
Show All 15 Lines | |||||
* assignment. | * assignment. | ||||
*/ | */ | ||||
static int | static int | ||||
ice_set_rss_lut(struct ice_vsi *vsi) | ice_set_rss_lut(struct ice_vsi *vsi) | ||||
{ | { | ||||
struct ice_softc *sc = vsi->sc; | struct ice_softc *sc = vsi->sc; | ||||
struct ice_hw *hw = &sc->hw; | struct ice_hw *hw = &sc->hw; | ||||
device_t dev = sc->dev; | device_t dev = sc->dev; | ||||
struct ice_aq_get_set_rss_lut_params lut_params; | |||||
enum ice_status status; | enum ice_status status; | ||||
int i, err = 0; | int i, err = 0; | ||||
u8 *lut; | u8 *lut; | ||||
lut = (u8 *)malloc(vsi->rss_table_size, M_ICE, M_NOWAIT|M_ZERO); | lut = (u8 *)malloc(vsi->rss_table_size, M_ICE, M_NOWAIT|M_ZERO); | ||||
if (!lut) { | if (!lut) { | ||||
device_printf(dev, "Failed to allocate RSS lut memory\n"); | device_printf(dev, "Failed to allocate RSS lut memory\n"); | ||||
return (ENOMEM); | return (ENOMEM); | ||||
} | } | ||||
/* Populate the LUT with max no. of queues. If the RSS kernel | /* Populate the LUT with max no. of queues. If the RSS kernel | ||||
* interface is disabled, this will assign the lookup table in | * interface is disabled, this will assign the lookup table in | ||||
* a simple round robin fashion | * a simple round robin fashion | ||||
*/ | */ | ||||
for (i = 0; i < vsi->rss_table_size; i++) { | for (i = 0; i < vsi->rss_table_size; i++) { | ||||
/* XXX: this needs to be changed if num_rx_queues ever counts | /* XXX: this needs to be changed if num_rx_queues ever counts | ||||
* more than just the RSS queues */ | * more than just the RSS queues */ | ||||
lut[i] = rss_get_indirection_to_bucket(i) % vsi->num_rx_queues; | lut[i] = rss_get_indirection_to_bucket(i) % vsi->num_rx_queues; | ||||
} | } | ||||
status = ice_aq_set_rss_lut(hw, vsi->idx, vsi->rss_lut_type, | lut_params.vsi_handle = vsi->idx; | ||||
lut, vsi->rss_table_size); | lut_params.lut_size = vsi->rss_table_size; | ||||
lut_params.lut_type = vsi->rss_lut_type; | |||||
lut_params.lut = lut; | |||||
lut_params.global_lut_id = 0; | |||||
status = ice_aq_set_rss_lut(hw, &lut_params); | |||||
if (status) { | if (status) { | ||||
device_printf(dev, | device_printf(dev, | ||||
"Cannot set RSS lut, err %s aq_err %s\n", | "Cannot set RSS lut, err %s aq_err %s\n", | ||||
ice_status_str(status), ice_aq_str(hw->adminq.sq_last_status)); | ice_status_str(status), ice_aq_str(hw->adminq.sq_last_status)); | ||||
err = (EIO); | err = (EIO); | ||||
} | } | ||||
free(lut, M_ICE); | free(lut, M_ICE); | ||||
▲ Show 20 Lines • Show All 2,170 Lines • Show Last 20 Lines |