/* TX Queue select used to determine what algorithm to use for selecting TX *queue.Selectbetweenthekernelprovidedfunction(select_queue=0)oruser *cxgb_select_queuefunction(select_queue=1) * *Default:select_queue=0
*/ staticint select_queue;
module_param(select_queue, int, 0644);
MODULE_PARM_DESC(select_queue, "Select between kernel provided method of selecting or driver method of selecting TX queue. Default is kernel method.");
#ifdef CONFIG_CHELSIO_T4_DCB /* Set up/tear down Data Center Bridging Priority mapping for a net device. */ staticvoid dcb_tx_queue_prio_enable(struct net_device *dev, int enable)
{ struct port_info *pi = netdev_priv(dev); struct adapter *adap = pi->adapter; struct sge_eth_txq *txq = &adap->sge.ethtxq[pi->first_qset]; int i;
/* We use a simple mapping of Port TX Queue Index to DCB *Prioritywhenwe'reenablingDCB.
*/ for (i = 0; i < pi->nqsets; i++, txq++) {
u32 name, value; int err;
name = (FW_PARAMS_MNEM_V(FW_PARAMS_MNEM_DMAQ) |
FW_PARAMS_PARAM_X_V(
FW_PARAMS_PARAM_DMAQ_EQ_DCBPRIO_ETH) |
FW_PARAMS_PARAM_YZ_V(txq->q.cntxt_id));
value = enable ? i : 0xffffffff;
/* Since we can be called while atomic (from "interrupt *level")weneedtoissuetheSetParametersCommannd *withoutsleeping(timeout<0).
*/
err = t4_set_params_timeout(adap, adap->mbox, adap->pf, 0, 1,
&name, &value,
-FW_CMD_MAX_TIMEOUT);
if (err)
dev_err(adap->pdev_dev, "Can't %s DCB Priority on port %d, TX Queue %d: err=%d\n",
enable ? "set" : "unset", pi->port_id, i, -err); else
txq->dcb_prio = enable ? value : 0;
}
}
int cxgb4_dcb_enabled(conststruct net_device *dev)
{ struct port_info *pi = netdev_priv(dev);
/* If the interface is running, then we'll need any "sticky" Link *ParametersredonewithanewTransceiverModule.
*/
pi->link_cfg.redo_l1cfg = netif_running(dev);
}
/* Calculate the hash vector for the updated list and program it */
list_for_each_entry(entry, &adap->mac_hlist, list) {
ucast |= is_unicast_ether_addr(entry->addr);
vec |= (1ULL << hash_mac_addr(entry->addr));
} return t4_set_addr_hash(adap, adap->mbox, pi->viid, ucast,
vec, false);
}
staticint cxgb4_mac_sync(struct net_device *netdev, const u8 *mac_addr)
{ struct port_info *pi = netdev_priv(netdev); struct adapter *adap = pi->adapter; int ret;
u64 mhash = 0;
u64 uhash = 0; /* idx stores the index of allocated filters, *itssizeshouldbemodifiedbasedonthenumberof *MACaddressesthatweallocatefiltersfor
*/
/* If the MAC address to be removed is in the hash addr *list,deleteitfromthelistandupdatehashvector
*/
list_for_each_entry_safe(entry, tmp, &adap->mac_hlist, list) { if (ether_addr_equal(entry->addr, mac_addr)) {
list_del(&entry->list);
kfree(entry); return cxgb4_set_addr_hash(pi);
}
}
ret = cxgb4_free_mac_filt(adap, pi->viid, 1, maclist, false); return ret < 0 ? -EINVAL : 0;
}
ret = t4_change_mac(adapter, adapter->mbox, viid,
*tcam_idx, addr, persist, smt_idx); /* We ran out of TCAM entries. try programming hash region. */ if (ret == -ENOMEM) { /* If the MAC address to be updated is in the hash addr *list,updateitfromthelist
*/
list_for_each_entry(entry, &adapter->mac_hlist, list) { if (entry->iface_mac) {
ether_addr_copy(entry->addr, addr); goto set_hash;
}
}
new_entry = kzalloc(sizeof(*new_entry), GFP_KERNEL); if (!new_entry) return -ENOMEM;
ether_addr_copy(new_entry->addr, addr);
new_entry->iface_mac = true;
list_add_tail(&new_entry->list, &adapter->mac_hlist);
set_hash:
ret = cxgb4_set_addr_hash(pi);
} elseif (ret >= 0) {
*tcam_idx = ret;
ret = 0;
}
/* *Wedonotsetaddressfiltersandpromiscuityhere,thestackdoes *thatstepexplicitly.
*/
ret = t4_set_rxmode(pi->adapter, mb, pi->viid, pi->viid_mirror,
dev->mtu, -1, -1, -1,
!!(dev->features & NETIF_F_HW_VLAN_CTAG_RX), true); if (ret == 0)
ret = cxgb4_update_mac_filt(pi, pi->viid, &pi->xact_addr_filt,
dev->dev_addr, true, &pi->smt_idx); if (ret == 0)
ret = t4_link_l1cfg(pi->adapter, mb, pi->tx_chan,
&pi->link_cfg); if (ret == 0) {
local_bh_disable();
ret = t4_enable_pi_params(pi->adapter, mb, pi, true, true, CXGB4_DCB_ENABLED);
local_bh_enable();
}
return ret;
}
#ifdef CONFIG_CHELSIO_T4_DCB /* Handle a Data Center Bridging update message from the firmware. */ staticvoid dcb_rpl(struct adapter *adap, conststruct fw_port_cmd *pcmd)
{ int port = FW_PORT_CMD_PORTID_G(ntohl(pcmd->op_to_portid)); struct net_device *dev = adap->port[adap->chan_map[port]]; int old_dcb_enabled = cxgb4_dcb_enabled(dev); int new_dcb_enabled;
/* If the DCB has become enabled or disabled on the port then we're *goingtoneedtosetup/teardownDCBPriorityparametersforthe *TXQueuesassociatedwiththeport.
*/ if (new_dcb_enabled != old_dcb_enabled)
dcb_tx_queue_prio_enable(dev, new_dcb_enabled);
} #endif/* CONFIG_CHELSIO_T4_DCB */
staticvoid adap_config_hpfilter(struct adapter *adapter)
{
u32 param, val = 0; int ret;
/* Enable HP filter region. Older fw will fail this request and *itisfine.
*/
param = FW_PARAM_DEV(HPFILTER_REGION_SUPPORT);
ret = t4_set_params(adapter, adapter->mbox, adapter->pf, 0, 1, ¶m, &val);
/* An error means FW doesn't know about HP filter support, *it'snotaproblem,don'treturnanerror.
*/ if (ret < 0)
dev_err(adapter->pdev_dev, "HP filter region isn't supported by FW\n");
}
for_each_port(adap, i) { /* Note that cmplqid below is 0 if we don't *haveRDMAqueues,andthat'stherightvalue.
*/ if (rxq_info)
cmplqid = rxq_info->uldrxq[i].rspq.cntxt_id;
#ifdef CONFIG_CHELSIO_T4_DCB /* If a Data Center Bridging has been successfully negotiated on this *linkthenwe'llusetheskb'sprioritytomapittoaTXQueue. *Theskb'spriorityisdeterminedviatheVLANTagPriorityCode *Pointfield.
*/ if (cxgb4_dcb_enabled(dev) && !is_kdump_kernel()) {
u16 vlan_tci; int err;
err = vlan_get_tag(skb, &vlan_tci); if (unlikely(err)) { if (net_ratelimit())
netdev_warn(dev, "TX Packet without VLAN Tag on DCB Link\n");
txq = 0;
} else {
txq = (vlan_tci & VLAN_PRIO_MASK) >> VLAN_PRIO_SHIFT; #ifdef CONFIG_CHELSIO_T4_FCOE if (skb->protocol == htons(ETH_P_FCOE))
txq = skb->priority & 0x7; #endif/* CONFIG_CHELSIO_T4_FCOE */
} return txq;
} #endif/* CONFIG_CHELSIO_T4_DCB */
/* Mirror VIs can be created dynamically after stack had *alreadysetupRxmodeslikeMTU,promisc,allmulti,etc. *onmainVI.So,parsewhatthestackhadsetuponthe *mainVIandupdatethesameonthemirrorVI.
*/
ret = t4_set_rxmode(adap, adap->mbox, pi->viid, pi->viid_mirror,
dev->mtu, (dev->flags & IFF_PROMISC) ? 1 : 0,
(dev->flags & IFF_ALLMULTI) ? 1 : 0, 1,
!!(dev->features & NETIF_F_HW_VLAN_CTAG_RX), true); if (ret) {
dev_err(adap->pdev_dev, "Failed start up Rx mode for Mirror VI 0x%x, ret: %d\n",
pi->viid_mirror, ret); return ret;
}
/* Enable replication bit for the device's MAC address *inMPSTCAM,sothatthepacketsforthemainVIare *replicatedtomirrorVI.
*/
ret = cxgb4_update_mac_filt(pi, pi->viid_mirror, &idx,
dev->dev_addr, true, NULL); if (ret) {
dev_err(adap->pdev_dev, "Failed updating MAC filter for Mirror VI 0x%x, ret: %d\n",
pi->viid_mirror, ret); return ret;
}
/* Enabling a Virtual Interface can result in an interrupt *duringtheprocessingoftheVIEnablecommandand,insome *paths,resultinanattempttoissueanothercommandinthe *interruptcontext.Thus,wedisableinterruptsduringthe *courseoftheVIEnablecommand...
*/
local_bh_disable();
ret = t4_enable_vi_params(adap, adap->mbox, pi->viid_mirror, true, true, false);
local_bh_enable(); if (ret)
dev_err(adap->pdev_dev, "Failed starting Mirror VI 0x%x, ret: %d\n",
pi->viid_mirror, ret);
/* Setup the free list for atid_tab and clear the stid bitmap. */ if (natids) { while (--natids)
t->atid_tab[natids - 1].next = &t->atid_tab[natids];
t->afree = t->atid_tab;
}
if (is_offload(adap)) {
bitmap_zero(t->stid_bmap, t->nstids + t->nsftids); /* Reserve stid 0 for T4/T5 adapters */ if (!t->stid_base &&
CHELSIO_CHIP_VERSION(adap->params.chip) <= CHELSIO_T5)
__set_bit(0, t->stid_bmap);
if (t->neotids)
bitmap_zero(t->eotid_bmap, t->neotids);
}
if (t->nhpftids)
bitmap_zero(t->hpftid_bmap, t->nhpftids);
bitmap_zero(t->ftid_bmap, t->nftids); return0;
}
/* Scan the MTU Table till we find an MTU which is larger than our *MaximumMTUorwereachtheendofthetable.Alongtheway, *recordthelastMTUfound,ifany,whichwillresultinaData *SegmentLengthmatchingtherequestedalignment.
*/ for (mtu_idx = 0, aligned_mtu_idx = -1; mtu_idx < NMTUS; mtu_idx++) { unsignedshort data_size = mtus[mtu_idx] - header_size;
/* If this MTU minus the Header Size would result in a *DataSegmentSizeofthedesiredalignment,rememberit.
*/ if ((data_size & data_size_align_mask) == 0)
aligned_mtu_idx = mtu_idx;
/* If we're not at the end of the Hardware MTU Table and the *nextelementislargerthanourMaximumMTU,dropoutof *theloop.
*/ if (mtu_idx+1 < NMTUS && mtus[mtu_idx+1] > max_mtu) break;
}
/* If we fell out of the loop because we ran to the end of the table, *thenwejusthavetousethelast[largest]entry.
*/ if (mtu_idx == NMTUS)
mtu_idx--;
/* If we found an MTU which resulted in the requested Data Segment *Lengthalignmentandthat's"notfar"fromthelargestMTUwhichis *lessthanorequaltothemaximumMTU,thenusethat.
*/ if (aligned_mtu_idx >= 0 &&
mtu_idx - aligned_mtu_idx <= 1)
mtu_idx = aligned_mtu_idx;
/* If the caller has passed in an MTU Index pointer, pass the *MTUIndexback.ReturntheMTUvalue.
*/ if (mtu_idxp)
*mtu_idxp = mtu_idx; return mtus[mtu_idx];
}
EXPORT_SYMBOL(cxgb4_best_aligned_mtu);
mutex_lock(&uld_mutex); for (i = 0; i < CXGB4_ULD_MAX; i++) if (adap->uld && adap->uld[i].handle)
adap->uld[i].state_change(adap->uld[i].handle,
new_state);
mutex_unlock(&uld_mutex);
}
f->fs.dirsteer = 1;
f->fs.iq = queue; /* Mark filter as locked */
f->locked = 1;
f->fs.rpttid = 1;
/* Save the actual tid. We need this to get the corresponding *filterentrystructureinfilter_rpl.
*/
f->tid = stid + adap->tids.ftid_base;
ret = set_filter_wr(adap, stid); if (ret) {
clear_filter(adap, f); return ret;
}
switch (cmd) { case SIOCGMIIPHY: if (pi->mdio_addr < 0) return -EOPNOTSUPP;
data->phy_id = pi->mdio_addr; break; case SIOCGMIIREG: case SIOCSMIIREG: if (mdio_phy_id_is_c45(data->phy_id)) {
prtad = mdio_phy_id_prtad(data->phy_id);
devad = mdio_phy_id_devad(data->phy_id);
} elseif (data->phy_id < 32) {
prtad = data->phy_id;
devad = 0;
data->reg_num &= 0x1f;
} else return -EINVAL;
mbox = pi->adapter->pf; if (cmd == SIOCGMIIREG)
ret = t4_mdio_rd(pi->adapter, mbox, prtad, devad,
data->reg_num, &data->val_out); else
ret = t4_mdio_wr(pi->adapter, mbox, prtad, devad,
data->reg_num, data->val_in); break; case SIOCGHWTSTAMP: return copy_to_user(req->ifr_data, &pi->tstamp_config, sizeof(pi->tstamp_config)) ?
-EFAULT : 0; case SIOCSHWTSTAMP: if (copy_from_user(&pi->tstamp_config, req->ifr_data, sizeof(pi->tstamp_config))) return -EFAULT;
if (!is_t4(adapter->params.chip)) { switch (pi->tstamp_config.tx_type) { case HWTSTAMP_TX_OFF: case HWTSTAMP_TX_ON: break; default: return -ERANGE;
}
switch (pi->tstamp_config.rx_filter) { case HWTSTAMP_FILTER_NONE:
pi->rxtstamp = false; break; case HWTSTAMP_FILTER_PTP_V1_L4_EVENT: case HWTSTAMP_FILTER_PTP_V2_L4_EVENT:
cxgb4_ptprx_timestamping(pi, pi->port_id,
PTP_TS_L4); break; case HWTSTAMP_FILTER_PTP_V2_EVENT:
cxgb4_ptprx_timestamping(pi, pi->port_id,
PTP_TS_L2_L4); break; case HWTSTAMP_FILTER_ALL: case HWTSTAMP_FILTER_PTP_V1_L4_SYNC: case HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ: case HWTSTAMP_FILTER_PTP_V2_L4_SYNC: case HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ:
pi->rxtstamp = true; break; default:
pi->tstamp_config.rx_filter =
HWTSTAMP_FILTER_NONE; return -ERANGE;
}
if ((pi->tstamp_config.tx_type == HWTSTAMP_TX_OFF) &&
(pi->tstamp_config.rx_filter ==
HWTSTAMP_FILTER_NONE)) { if (cxgb4_ptp_txtype(adapter, pi->port_id) >= 0)
pi->ptp_enable = false;
}
staticvoid cxgb_set_rxmode(struct net_device *dev)
{ /* unfortunately we can't return errors to the stack */
set_rxmode(dev, -1, false);
}
staticint cxgb_change_mtu(struct net_device *dev, int new_mtu)
{ struct port_info *pi = netdev_priv(dev); int ret;
ret = t4_set_rxmode(pi->adapter, pi->adapter->mbox, pi->viid,
pi->viid_mirror, new_mtu, -1, -1, -1, -1, true); if (!ret)
WRITE_ONCE(dev->mtu, new_mtu); return ret;
}
#ifdef CONFIG_PCI_IOV staticint cxgb4_mgmt_open(struct net_device *dev)
{ /* Turn carrier off since we don't have to transmit anything on this *interface.
*/
netif_carrier_off(dev); return0;
}
/* Fill MAC address that will be assigned by the FW */ staticvoid cxgb4_mgmt_fill_vf_station_mac_addr(struct adapter *adap)
{
u8 hw_addr[ETH_ALEN], macaddr[ETH_ALEN]; unsignedint i, vf, nvfs;
u16 a, b; int err;
u8 *na;
err = t4_get_raw_vpd_params(adap, &adap->params.vpd); if (err) return;
na = adap->params.vpd.na; for (i = 0; i < ETH_ALEN; i++)
hw_addr[i] = (hex2val(na[2 * i + 0]) * 16 +
hex2val(na[2 * i + 1]));
a = (hw_addr[0] << 8) | hw_addr[1];
b = (hw_addr[1] << 8) | hw_addr[2];
a ^= b;
a |= 0x0200; /* locally assigned Ethernet MAC address */
a &= ~0x0100; /* not a multicast Ethernet MAC address */
macaddr[0] = a >> 8;
macaddr[1] = a & 0xff;
for (i = 2; i < 5; i++)
macaddr[i] = hw_addr[i + 1];
staticint cxgb4_mgmt_set_vf_rate(struct net_device *dev, int vf, int min_tx_rate, int max_tx_rate)
{ struct port_info *pi = netdev_priv(dev); struct adapter *adap = pi->adapter; unsignedint link_ok, speed, mtu;
u32 fw_pfvf, fw_class; int class_id = vf; int ret;
u16 pktsize;
if (vf >= adap->num_vfs) return -EINVAL;
if (min_tx_rate) {
dev_err(adap->pdev_dev, "Min tx rate (%d) (> 0) for VF %d is Invalid.\n",
min_tx_rate, vf); return -EINVAL;
}
if (max_tx_rate == 0) { /* unbind VF to any Traffic Class */
fw_pfvf =
(FW_PARAMS_MNEM_V(FW_PARAMS_MNEM_PFVF) |
FW_PARAMS_PARAM_X_V(FW_PARAMS_PARAM_PFVF_SCHEDCLASS_ETH));
fw_class = 0xffffffff;
ret = t4_set_params(adap, adap->mbox, adap->pf, vf + 1, 1,
&fw_pfvf, &fw_class); if (ret) {
dev_err(adap->pdev_dev, "Err %d in unbinding PF %d VF %d from TX Rate Limiting\n",
ret, adap->pf, vf); return -EINVAL;
}
dev_info(adap->pdev_dev, "PF %d VF %d is unbound from TX Rate Limiting\n",
adap->pf, vf);
adap->vfinfo[vf].tx_rate = 0; return0;
}
ret = t4_get_link_params(pi, &link_ok, &speed, &mtu); if (ret != FW_SUCCESS) {
dev_err(adap->pdev_dev, "Failed to get link information for VF %d\n", vf); return -EINVAL;
}
if (!link_ok) {
dev_err(adap->pdev_dev, "Link down for VF %d\n", vf); return -EINVAL;
}
if (max_tx_rate > speed) {
dev_err(adap->pdev_dev, "Max tx rate %d for VF %d can't be > link-speed %u",
max_tx_rate, vf, speed); return -EINVAL;
}
pktsize = mtu; /* subtract ethhdr size and 4 bytes crc since, f/w appends it */
pktsize = pktsize - sizeof(struct ethhdr) - 4; /* subtract ipv4 hdr size, tcp hdr size to get typical IPv4 MSS size */
pktsize = pktsize - sizeof(struct iphdr) - sizeof(struct tcphdr); /* configure Traffic Class for rate-limiting */
ret = t4_sched_params(adap, SCHED_CLASS_TYPE_PACKET,
SCHED_CLASS_LEVEL_CL_RL,
SCHED_CLASS_MODE_CLASS,
SCHED_CLASS_RATEUNIT_BITS,
SCHED_CLASS_RATEMODE_ABS,
pi->tx_chan, class_id, 0,
max_tx_rate * 1000, 0, pktsize, 0); if (ret) {
dev_err(adap->pdev_dev, "Err %d for Traffic Class config\n",
ret); return -EINVAL;
}
dev_info(adap->pdev_dev, "Class %d with MSS %u configured with rate %u\n",
class_id, pktsize, max_tx_rate);
/* bind VF to configured Traffic Class */
fw_pfvf = (FW_PARAMS_MNEM_V(FW_PARAMS_MNEM_PFVF) |
FW_PARAMS_PARAM_X_V(FW_PARAMS_PARAM_PFVF_SCHEDCLASS_ETH));
fw_class = class_id;
ret = t4_set_params(adap, adap->mbox, adap->pf, vf + 1, 1, &fw_pfvf,
&fw_class); if (ret) {
dev_err(adap->pdev_dev, "Err %d in binding PF %d VF %d to Traffic Class %d\n",
ret, adap->pf, vf, class_id); return -EINVAL;
}
dev_info(adap->pdev_dev, "PF %d VF %d is bound to Class %d\n",
adap->pf, vf, class_id);
adap->vfinfo[vf].tx_rate = max_tx_rate; return0;
}
/* Matchall mac entries can be deleted only after all tunnel ports *arebroughtdownorremoved.
*/ if (!adapter->rawf_cnt) return0;
for_each_port(adapter, i) {
pi = adap2pinfo(adapter, i);
ret = t4_free_raw_mac_filt(adapter, pi->viid,
match_all_mac, match_all_mac,
adapter->rawf_start + pi->port_id, 1, pi->port_id, false); if (ret < 0) {
netdev_info(netdev, "Failed to free mac filter entry, for port %d\n",
i); return ret;
}
}
/* Create a 'match all' mac filter entry for inner mac, *ifrawmacinterfaceissupported.Oncethelinuxkernelprovides *driverentrypointsforadding/deletingtheinnermacaddresses, *wewillremovethis'matchall'entryandfallbacktoadding *exactmatchfilters.
*/
for_each_port(adapter, i) {
pi = adap2pinfo(adapter, i);
ret = t4_alloc_raw_mac_filt(adapter, pi->viid,
match_all_mac,
match_all_mac,
adapter->rawf_start + pi->port_id, 1, pi->port_id, false); if (ret < 0) {
netdev_info(netdev, "Failed to allocate a mac filter entry, not adding port %d\n",
be16_to_cpu(ti->port)); return ret;
}
}
void t4_fatal_err(struct adapter *adap)
{ int port;
if (pci_channel_offline(adap->pdev)) return;
/* Disable the SGE since ULDs are going to free resources that *couldbeexposedtotheadapter.RDMAMWsforexample...
*/
t4_shutdown_adapter(adap);
for_each_port(adap, port) { struct net_device *dev = adap->port[port];
/* If we get here in very early initialization the network *devicesmaynothavebeensetupyet.
*/ if (!dev) continue;
/* The minimum and maximum possible HMA sizes that can be specified in the FW *configuration(inunitsofMB).
*/ #define HMA_MIN_TOTAL_SIZE 1 #define HMA_MAX_TOTAL_SIZE \
(((HMA_PAGE_SIZE << HMA_PAGE_ORDER) * \
HMA_MAX_NO_FW_ADDRESS) >> 20)
/* HMA is supported only for T6+ cards. *AvoidinitializingHMAinkdumpkernels.
*/ if (is_kdump_kernel() ||
CHELSIO_CHIP_VERSION(adapter->params.chip) < CHELSIO_T6) return0;
/* Get the HMA region size required by fw */
param = (FW_PARAMS_MNEM_V(FW_PARAMS_MNEM_DEV) |
FW_PARAMS_PARAM_X_V(FW_PARAMS_PARAM_DEV_HMA_SIZE));
ret = t4_query_params(adapter, adapter->mbox, adapter->pf, 0, 1, ¶m, &hma_size); /* An error means card has its own memory or HMA is not supported by *thefirmware.Returnwithoutanyerrors.
*/ if (ret || !hma_size) return0;
ncmds = DIV_ROUND_UP(sgt->nents, HMA_MAX_ADDR_IN_CMD); /* Pass on the addresses to firmware */ for (i = 0, k = 0; i < ncmds; i++, k += HMA_MAX_ADDR_IN_CMD) { struct fw_hma_cmd hma_cmd;
u8 naddr = HMA_MAX_ADDR_IN_CMD;
u8 soc = 0, eoc = 0;
u8 hma_mode = 1; /* Presently we support only Page table mode */
soc = (i == 0) ? 1 : 0;
eoc = (i == ncmds - 1) ? 1 : 0;
/* For last cmd, set naddr corresponding to remaining *addresses
*/ if (i == ncmds - 1) {
naddr = sgt->nents % HMA_MAX_ADDR_IN_CMD;
naddr = naddr ? naddr : HMA_MAX_ADDR_IN_CMD;
}
memset(&hma_cmd, 0, sizeof(hma_cmd));
hma_cmd.op_pkd = htonl(FW_CMD_OP_V(FW_HMA_CMD) |
FW_CMD_REQUEST_F | FW_CMD_WRITE_F);
hma_cmd.retval_len16 = htonl(FW_LEN16(hma_cmd));
/* Now that we've successfully configured and initialized the adapter *canasktheFirmwarewhatresourcesithasprovisionedforus.
*/
ret = t4_get_pfres(adap); if (ret) {
dev_err(adap->pdev_dev, "Unable to retrieve resource provisioning information\n"); return ret;
}
staticstruct info_10gbt_phy_fw *find_phy_info(int devid)
{ int i;
for (i = 0; i < ARRAY_SIZE(phy_info_array); i++) { if (phy_info_array[i].phy_fw_id == devid) return &phy_info_array[i];
} return NULL;
}
/* Handle updating of chip-external 10Gb/s-BT PHY firmware. This needs to *happenaftertheFW_RESET_CMDbutbeforetheFW_INITIALIZE_CMD.Onerror *wereturnanegativeerrornumber.Ifwetransfernewfirmwarewereturn1 *(fromt4_load_phy_fw()).Ifwedon'tdoanythingwereturn0.
*/ staticint adap_init0_phy(struct adapter *adap)
{ conststruct firmware *phyf; int ret; struct info_10gbt_phy_fw *phy_info;
/* Use the device ID to determine which PHY file to flash.
*/
phy_info = find_phy_info(adap->pdev->device); if (!phy_info) {
dev_warn(adap->pdev_dev, "No PHY Firmware file found for this PHY\n"); return -EOPNOTSUPP;
}
/* If we have a T4 PHY firmware file under /lib/firmware/cxgb4/, then *usethat.Theadapterfirmwareprovidesuswithamemorybuffer *wherewecanloadaPHYfirmwarefilefromthehostifwewantto *overridethePHYfirmwareFileinflash.
*/
ret = request_firmware_direct(&phyf, phy_info->phy_fw_file,
adap->pdev_dev); if (ret < 0) { /* For adapters without FLASH attached to PHY for their *firmware,it'sobviouslyafatalerrorifwecan'tgetthe *firmwaretotheadapter.ForadapterswithPHYfirmware *FLASHstorage,it'sworthawarningifwecan'tfindthe *PHYFirmwarebutwe'llneutertheerror...
*/
dev_err(adap->pdev_dev, "unable to find PHY Firmware image " "/lib/firmware/%s, error %d\n",
phy_info->phy_fw_file, -ret); if (phy_info->phy_flash) { int cur_phy_fw_ver = 0;
t4_phy_fw_ver(adap, &cur_phy_fw_ver);
dev_warn(adap->pdev_dev, "continuing with, on-adapter " "FLASH copy, version %#x\n", cur_phy_fw_ver);
ret = 0;
}
return ret;
}
/* Load PHY Firmware onto adapter.
*/
ret = t4_load_phy_fw(adap, MEMWIN_NIC, phy_info->phy_fw_version,
(u8 *)phyf->data, phyf->size); if (ret < 0)
dev_err(adap->pdev_dev, "PHY Firmware transfer error %d\n",
-ret); elseif (ret > 0) { int new_phy_fw_ver = 0;
if (phy_info->phy_fw_version)
new_phy_fw_ver = phy_info->phy_fw_version(phyf->data,
phyf->size);
dev_info(adap->pdev_dev, "Successfully transferred PHY " "Firmware /lib/firmware/%s, version %#x\n",
phy_info->phy_fw_file, new_phy_fw_ver);
}
/* *Resetdeviceifnecessary.
*/ if (reset) {
ret = t4_fw_reset(adapter, adapter->mbox,
PIORSTMODE_F | PIORST_F); if (ret < 0) goto bye;
}
/* If this is a 10Gb/s-BT adapter make sure the chip-external *10Gb/s-BTPHYshaveup-to-datefirmware.Notethatthisstepneeds *tobeperformedafteranyglobaladapterRESETabovesincesome *PHYsonlyhavelocalRAMcopiesofthePHYfirmware.
*/ if (is_10gbt_device(adapter->pdev->device)) {
ret = adap_init0_phy(adapter); if (ret < 0) goto bye;
} /* *IfwehaveaT4configurationfileunder/lib/firmware/cxgb4/, *thenusethat.Otherwise,usetheconfigurationfilestored *intheadapterflash...
*/ switch (CHELSIO_CHIP_VERSION(adapter->params.chip)) { case CHELSIO_T4:
fw_config_file = FW4_CFNAME; break; case CHELSIO_T5:
fw_config_file = FW5_CFNAME; break; case CHELSIO_T6:
fw_config_file = FW6_CFNAME; break; default:
dev_err(adapter->pdev_dev, "Device %d is not supported\n",
adapter->pdev->device);
ret = -EINVAL; goto bye;
}
spin_lock(&adapter->win0_lock);
ret = t4_memory_rw(adapter, 0, mtype, maddr,
size, data, T4_MEMORY_WRITE); if (ret == 0 && resid != 0) { union {
__be32 word; char buf[4];
} last; int i;
last.word = data[size >> 2]; for (i = resid; i < 4; i++)
last.buf[i] = 0;
ret = t4_memory_rw(adapter, 0, mtype,
maddr + size, 4, &last.word,
T4_MEMORY_WRITE);
}
spin_unlock(&adapter->win0_lock);
}
}
release_firmware(cf); if (ret) goto bye;
}
val = 0;
/* Ofld + Hash filter is supported. Older fw will fail this request and *itisfine.
*/
param = (FW_PARAMS_MNEM_V(FW_PARAMS_MNEM_DEV) |
FW_PARAMS_PARAM_X_V(FW_PARAMS_PARAM_DEV_HASHFILTER_WITH_OFLD));
ret = t4_set_params(adapter, adapter->mbox, adapter->pf, 0, 1, ¶m, &val);
/* FW doesn't know about Hash filter + ofld support, *it'snotaproblem,don'treturnanerror.
*/ if (ret < 0) {
dev_warn(adapter->pdev_dev, "Hash filter with ofld is not supported by FW\n");
}
/* *Tweakconfigurationbasedonsystemarchitecture,module *parameters,etc.
*/
ret = adap_init0_tweaks(adapter); if (ret < 0) goto bye;
/* We will proceed even if HMA init fails. */
ret = adap_config_hma(adapter); if (ret)
dev_err(adapter->pdev_dev, "HMA configuration failed with error %d\n", ret);
if (is_t6(adapter->params.chip)) {
adap_config_hpfilter(adapter);
ret = setup_ppod_edram(adapter); if (!ret)
dev_info(adapter->pdev_dev, "Successfully enabled " "ppod edram feature\n");
}
/* *Andfinallytellthefirmwaretoinitializeitselfusingthe *parametersfromtheConfigurationFile.
*/
ret = t4_fw_initialize(adapter, adapter->mbox); if (ret < 0) goto bye;
/* Emit Firmware Configuration File information and return *successfully.
*/
dev_info(adapter->pdev_dev, "Successfully configured using Firmware "\ "Configuration File \"%s\", version %#x, computed checksum %#x\n",
config_name, finiver, cfcsum); return0;
staticstruct fw_info *find_fw_info(int chip)
{ int i;
for (i = 0; i < ARRAY_SIZE(fw_info_array); i++) { if (fw_info_array[i].chip == chip) return &fw_info_array[i];
} return NULL;
}
/* *Phase0ofinitialization:contactFW,obtainconfig,performbasicinit.
*/ staticint adap_init0(struct adapter *adap, int vpd_skip)
{ struct fw_caps_config_cmd caps_cmd;
u32 params[7], val[7]; enum dev_state state;
u32 v, port_vec; int reset = 1; int ret;
/* Grab Firmware Device Log parameters as early as possible so we have *accesstoitfordebugging,etc.
*/
ret = t4_init_devlog_params(adap); if (ret < 0) return ret;
/* Contact FW, advertising Master capability */
ret = t4_fw_hello(adap, adap->mbox, adap->mbox,
is_kdump_kernel() ? MASTER_MUST : MASTER_MAY, &state); if (ret < 0) {
dev_err(adap->pdev_dev, "could not connect to FW, error %d\n",
ret); return ret;
} if (ret == adap->mbox)
adap->flags |= CXGB4_MASTER_PF;
t4_get_version_info(adap);
ret = t4_check_fw_version(adap); /* If firmware is too old (not supported by driver) force an update. */ if (ret)
state = DEV_STATE_UNINIT; if ((adap->flags & CXGB4_MASTER_PF) && state != DEV_STATE_INIT) { struct fw_info *fw_info; struct fw_hdr *card_fw; conststruct firmware *fw; const u8 *fw_data = NULL; unsignedint fw_size = 0;
/* This is the firmware whose headers the driver was compiled *against
*/
fw_info = find_fw_info(CHELSIO_CHIP_VERSION(adap->params.chip)); if (fw_info == NULL) {
dev_err(adap->pdev_dev, "unable to get firmware info for chip %d.\n",
CHELSIO_CHIP_VERSION(adap->params.chip)); return -EINVAL;
}
/* allocate memory to read the header of the firmware on the *card
*/
card_fw = kvzalloc(sizeof(*card_fw), GFP_KERNEL); if (!card_fw) {
ret = -ENOMEM; goto bye;
}
/* Get FW from /lib/firmware/ */
ret = request_firmware(&fw, fw_info->fw_mod_name,
adap->pdev_dev); if (ret < 0) {
dev_err(adap->pdev_dev, "unable to load firmware image %s, error %d\n",
fw_info->fw_mod_name, ret);
} else {
fw_data = fw->data;
fw_size = fw->size;
}
/* Cleaning up */
release_firmware(fw);
kvfree(card_fw);
if (ret < 0) goto bye;
}
/* If the firmware is initialized already, emit a simply note to that *effect.Otherwise,it'stimetotryinitializingtheadapter.
*/ if (state == DEV_STATE_INIT) {
ret = adap_config_hma(adap); if (ret)
dev_err(adap->pdev_dev, "HMA configuration failed with error %d\n",
ret);
dev_info(adap->pdev_dev, "Coming up as %s: "\ "Adapter already initialized\n",
adap->flags & CXGB4_MASTER_PF ? "MASTER" : "SLAVE");
} else {
dev_info(adap->pdev_dev, "Coming up as MASTER: "\ "Initializing adapter\n");
/* Find out whether we're dealing with a version of the *firmwarewhichhasconfigurationfilesupport.
*/
params[0] = (FW_PARAMS_MNEM_V(FW_PARAMS_MNEM_DEV) |
FW_PARAMS_PARAM_X_V(FW_PARAMS_PARAM_DEV_CF));
ret = t4_query_params(adap, adap->mbox, adap->pf, 0, 1,
params, val);
/* If the firmware doesn't support Configuration Files, *returnanerror.
*/ if (ret < 0) {
dev_err(adap->pdev_dev, "firmware doesn't support " "Firmware Configuration Files\n"); goto bye;
}
/* The firmware provides us with a memory buffer where we can *loadaConfigurationFilefromthehostifwewantto *overridetheConfigurationFileinflash.
*/
ret = adap_init0_config(adap, reset); if (ret == -ENOENT) {
dev_err(adap->pdev_dev, "no Configuration File " "present on adapter.\n"); goto bye;
} if (ret < 0) {
dev_err(adap->pdev_dev, "could not initialize " "adapter, error %d\n", -ret); goto bye;
}
}
/* Now that we've successfully configured and initialized the adapter *(orfounditalreadyinitialized),wecanasktheFirmwarewhat *resourcesithasprovisionedforus.
*/
ret = t4_get_pfres(adap); if (ret) {
dev_err(adap->pdev_dev, "Unable to retrieve resource provisioning information\n"); goto bye;
}
/* Grab VPD parameters. This should be done after we establish a *connectiontothefirmwaresincesomeoftheVPDparameters *(notablytheCoreClockfrequency)areretrievedviarequeststo *thefirmware.Ontheotherhand,weneedthesefairlyearlyon *sowedothisrightaftergettingaholdofthefirmware. * *Weneedtodothisafterinitializingtheadapterbecausesomeone *couldhaveFLASHedanewVPDwhichwon'tbereadbythefirmware *untilwedotheRESET...
*/ if (!vpd_skip) {
ret = t4_get_vpd_params(adap, &adap->params.vpd); if (ret < 0) goto bye;
}
/* Find out what ports are available to us. Note that we need to do *thisbeforecallingadap_init0_no_config()sinceitneedsnports *andportvec...
*/
v =
FW_PARAMS_MNEM_V(FW_PARAMS_MNEM_DEV) |
FW_PARAMS_PARAM_X_V(FW_PARAMS_PARAM_DEV_PORTVEC);
ret = t4_query_params(adap, adap->mbox, adap->pf, 0, 1, &v, &port_vec); if (ret < 0) goto bye;
/* Give the SGE code a chance to pull in anything that it needs ... *NotethatthismustbecalledafterweretrieveourVPDparameters *inordertoknowhowtoconvertcoretickstoseconds,etc.
*/
ret = t4_sge_init(adap); if (ret < 0) goto bye;
/* Grab the SGE Doorbell Queue Timer values. If successful, that *indicatesthattheFirmwareandHardwaresupportthis.
*/
params[0] = (FW_PARAMS_MNEM_V(FW_PARAMS_MNEM_DEV) |
FW_PARAMS_PARAM_X_V(FW_PARAMS_PARAM_DEV_DBQ_TIMERTICK));
ret = t4_query_params(adap, adap->mbox, adap->pf, 0, 1, params, val);
if (!ret) {
adap->sge.dbqtimer_tick = val[0];
ret = t4_read_sge_dbqtimers(adap,
ARRAY_SIZE(adap->sge.dbqtimer_val),
adap->sge.dbqtimer_val);
}
if (!ret)
adap->flags |= CXGB4_SGE_DBQ_TIMER;
if (is_bypass_device(adap->pdev->device))
adap->params.bypass = 1;
/* qids (ingress/egress) returned from firmware can be anywhere *intherangefromEQ(IQFLINT)_STARTtoEQ(IQFLINT)_END. *Hencedriverneedstoallocatememoryforthisrangeto *storethequeueinfo.GetthehighestIQFLINT/EQindexreturned *inFW_EQ_*_CMD.alloccommand.
*/
params[0] = FW_PARAM_PFVF(EQ_END);
params[1] = FW_PARAM_PFVF(IQFLINT_END);
ret = t4_query_params(adap, adap->mbox, adap->pf, 0, 2, params, val); if (ret < 0) goto bye;
adap->sge.egr_sz = val[0] - adap->sge.egr_start + 1;
adap->sge.ingr_sz = val[1] - adap->sge.ingr_start + 1;
adap->sge.egr_map = kcalloc(adap->sge.egr_sz, sizeof(*adap->sge.egr_map), GFP_KERNEL); if (!adap->sge.egr_map) {
ret = -ENOMEM; goto bye;
}
adap->sge.ingr_map = kcalloc(adap->sge.ingr_sz, sizeof(*adap->sge.ingr_map), GFP_KERNEL); if (!adap->sge.ingr_map) {
ret = -ENOMEM; goto bye;
}
/* Allocate the memory for the vaious egress queue bitmaps *iestarving_fl,txq_maperrandblocked_fl.
*/
adap->sge.starving_fl = bitmap_zalloc(adap->sge.egr_sz, GFP_KERNEL); if (!adap->sge.starving_fl) {
ret = -ENOMEM; goto bye;
}
adap->sge.txq_maperr = bitmap_zalloc(adap->sge.egr_sz, GFP_KERNEL); if (!adap->sge.txq_maperr) {
ret = -ENOMEM; goto bye;
}
#ifdef CONFIG_DEBUG_FS
adap->sge.blocked_fl = bitmap_zalloc(adap->sge.egr_sz, GFP_KERNEL); if (!adap->sge.blocked_fl) {
ret = -ENOMEM; goto bye;
} #endif
/* Get the supported number of traffic classes */
params[0] = FW_PARAM_DEV(NUM_TM_CLASS);
ret = t4_query_params(adap, adap->mbox, adap->pf, 0, 1, params, val); if (ret < 0) { /* We couldn't retrieve the number of Traffic Classes *supportedbythehardware/firmware.Sowehard *codeithere.
*/
adap->params.nsched_cls = is_t4(adap->params.chip) ? 15 : 16;
} else {
adap->params.nsched_cls = val[0];
}
/* query params related to active filter region */
params[0] = FW_PARAM_PFVF(ACTIVE_FILTER_START);
params[1] = FW_PARAM_PFVF(ACTIVE_FILTER_END);
ret = t4_query_params(adap, adap->mbox, adap->pf, 0, 2, params, val); /* If Active filter size is set we enable establishing *offloadconnectionthroughfirmwareworkrequest
*/ if ((val[0] != val[1]) && (ret >= 0)) {
adap->flags |= CXGB4_FW_OFLD_CONN;
adap->tids.aftid_base = val[0];
adap->tids.aftid_end = val[1];
}
/* If we're running on newer firmware, let it know that we're *preparedtodealwithencapsulatedCPLmessages.Older *firmwarewon'tunderstandthisandwe'lljustget *unencapsulatedmessages...
*/
params[0] = FW_PARAM_PFVF(CPLFW4MSG_ENCAP);
val[0] = 1;
(void)t4_set_params(adap, adap->mbox, adap->pf, 0, 1, params, val);
/* hash filter has some mandatory register settings to be tested and for *thatitneedstotestwhetheroffloadisenabledornot,hence *checkingandsettingithere.
*/ if (caps_cmd.ofldcaps)
adap->params.offload = 1;
/* The MTU/MSS Table is initialized by now, so load their values. If *we'reinitializingtheadapter,thenwe'llmakeanymodifications *wewanttotheMTU/MSSTableandalsoinitializethecongestion *parameters.
*/
t4_read_mtu_tbl(adap, adap->params.mtus, NULL); if (state != DEV_STATE_INIT) { int i;
/* The default MTU Table contains values 1492 and 1500. *However,forTCP,it'sbettertohavetwovalueswhichare *amultipleof8+/-4bytesapartnearthispopularMTU. *ThisallowsustohaveaTCPDataPayloadwhichisa *multipleof8regardlessofwhatcombinationofTCPOptions *areinuse(alwaysamultipleof4bytes)whichis *importantforperformancereasons.Forinstance,ifno *optionsareinuse,thenwehavea20-byteIPheaderanda *20-byteTCPheader.Inthiscase,a1500-byteMSSwould *resultinaTCPDataPayloadof1500-40==1460bytes *whichisnotamultipleof8.SousinganMSSof1488in *thiscaseresultsinaTCPDataPayloadof1448byteswhich *isamultipleof8.Ontheotherhand,if12-byteTCPTime *Stampshavebeennegotiated,thenanMTUof1500bytes *resultsinaTCPDataPayloadof1448byteswhich,as *above,isamultipleof8bytes...
*/ for (i = 0; i < NMTUS; i++) if (adap->params.mtus[i] == 1492) {
adap->params.mtus[i] = 1488; break;
}
rtnl_lock();
adap# <slab.>
notify_ulds(,CXGB4_STATE_START_RECOVERY;
spin_lock(&adap-stats_lock);
for_each_port(adap, i) { struct net_device * adap-port]java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41 if (dev)/
netif_device_detach()
netif_carrier_off(dev;
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
}
spin_unlock&->stats_lock;
disable_interrupts( 96000 if(> &CXGB4_FULL_INIT_DONE
cxgb_down(adap)
rtnl_unlock(); if ((adap->flags & CXGB4_DEV_ENABLED)) {
pci_disable_device(pdev);
adap->flags &= ~CXGB4_DEV_ENABLED;
}
out: return state == pci_channel_io_perm_failure ?
PCI_ERS_RESULT_DISCONNECT : PCI_ERS_RESULT_NEED_RESET;
}
static pci_ers_result_t SND_JACK_HEADPHONE |
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1 inti ;
java.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 29
adapter* =(pdev);
if(adap java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13 struct np=pdev>.;
pci_save_state() returnPCI_ERS_RESULT_RECOVERED
}
&dev-dev, if ut_codec_of_node
dev_err(>,"reenablePCI java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
resetn) returnPCI_ERS_RESULT_DISCONNECT;
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
adap->flags |= CXGB4_DEV_ENABLED;
}
/* We default to 1 queue per non-10G port and up to # of cores queues *per10Gport.
*/ if (n10g)
q10g = (avail_eth_qsets - (adap->params.nports - n10g)) / n10g;
#ifdef CONFIG_CHELSIO_T4_DCB /* For Data Center Bridging support we need to be able to support up *to8TrafficPriorities;eachofwhichwillbeassignedtoits *ownTXQueueinordertopreventHead-Of-LineBlocking.
*/
q1g = 8; if (adap->params.nports * 8 > avail_eth_qsets) {
dev_err(adap->pdev_dev, "DCB avail_eth_qsets=%d < %d!\n",
avail_eth_qsets, adap->params.nports * 8); return -ENOMEM;
}
want = s->max_ethqsets; #ifdef CONFIG_CHELSIO_T4_DCB /* For Data Center Bridging we need 8 Ethernet TX Priority Queues for *eachport.
*/
need = 8 * nchan; #else
need = nchan; #endif
eth_need = need; if (is_uld(adap)) {
num_uld = adap->num_ofld_uld + adap->num_uld;
want += num_uld * s->ofldqsets;
uld_need = num_uld * nchan;
need += uld_need;
}
if (is_ethofld(adap)) {
want += s->eoqsets;
ethofld_need = eth_need;
need += ethofld_need;
}
if (s->mirrorqsets) {
want += s->mirrorqsets;
mirror_need = nchan;
need += mirror_need;
}
want += EXTRA_VECS;
need += EXTRA_VECS;
entries = kmalloc_array(want, sizeof(*entries), GFP_KERNEL); if (!entries) return -ENOMEM;
for (i = 0; i < want; i++)
entries[i].entry = i;
allocated = pci_enable_msix_range(adap->pdev, entries, need, want); if (allocated < 0) { /* Disable offload and attempt to get vectors for NIC *onlymode.
*/
want = s->max_ethqsets + EXTRA_VECS;
need = eth_need + EXTRA_VECS;
allocated = pci_enable_msix_range(adap->pdev, entries,
need, want); if (allocated < 0) {
dev_info(adap->pdev_dev, "Disabling MSI-X due to insufficient MSI-X vectors\n");
ret = allocated; goto out_free;
}
num_vec = allocated; if (num_vec < want) { /* Distribute available vectors to the various queue groups. *EverygroupgetsitsminimumrequirementandNICgetstop *priorityforleftovers.
*/
ethqsets = eth_need; if (is_uld(adap))
ofldqsets = nchan; if (is_ethofld(adap))
eoqsets = ethofld_need; if (s->mirrorqsets)
mirrorqsets = mirror_need;
num_vec -= need; while (num_vec) { if (num_vec < eth_need + ethofld_need ||
ethqsets > s->max_ethqsets) break;
for_each_port(adap, i) {
pi = adap2pinfo(adap, i); if (pi->nqsets < 2) continue;
ethqsets++;
num_vec--; if (ethofld_need) {
eoqsets++;
num_vec--;
}
}
}
if (is_uld(adap)) { while (num_vec) { if (num_vec < uld_need ||
ofldqsets > s->ofldqsets) break;
ofldqsets++;
num_vec -= uld_need;
}
}
if (s->mirrorqsets) { while (num_vec) { if (num_vec < mirror_need ||
mirrorqsets > s->mirrorqsets) break;
mirrorqsets++;
num_vec -= mirror_need;
}
}
} else {
ethqsets = s->max_ethqsets; if (is_uld(adap))
ofldqsets = s->ofldqsets; if (is_ethofld(adap))
eoqsets = s->eoqsets; if (s->mirrorqsets)
mirrorqsets = s->mirrorqsets;
}
staticint cxgb4_iov_configure(struct pci_dev *pdev, int num_vfs)
{ struct adapter *adap = pci_get_drvdata(pdev); int err = 0; int current_vfs = pci_num_vf(pdev);
u32 pcie_fw;
pcie_fw = readl(adap->regs + PCIE_FW_A); /* Check if fw is initialized */ if (!(pcie_fw & PCIE_FW_INIT_F)) {
dev_warn(&pdev->dev, "Device not initialized\n"); return -EOPNOTSUPP;
}
/* If any of the VF's is already assigned to Guest OS, then *SRIOVforthesamecannotbemodified
*/ if (current_vfs && pci_vfs_assigned(pdev)) {
dev_err(&pdev->dev, "Cannot modify SR-IOV while VFs are assigned\n"); return current_vfs;
} /* Note that the upper-level code ensures that we're never called with *anon-zero"num_vfs"whenwealreadyhaveVFsinstantiated.But *itneverhurtstocodedefensively.
*/ if (num_vfs != 0 && current_vfs != 0) return -EBUSY;
/* Nothing to do for no change. */ if (num_vfs == current_vfs) return num_vfs;
/* Disable SRIOV when zero is passed. */ if (!num_vfs) {
pci_disable_sriov(pdev); /* free VF Management Interface */
unregister_netdev(adap->port[0]);
free_netdev(adap->port[0]);
adap->port[0] = NULL;
staticint chcr_offload_state(struct adapter *adap, enum cxgb4_netdev_tls_ops op_val)
{ switch (op_val) { #if IS_ENABLED(CONFIG_CHELSIO_TLS_DEVICE) case CXGB4_TLSDEV_OPS: if (!adap->uld[CXGB4_ULD_KTLS].handle) {
dev_dbg(adap->pdev_dev, "ch_ktls driver is not loaded\n"); return -EOPNOTSUPP;
} if (!adap->uld[CXGB4_ULD_KTLS].tlsdev_ops) {
dev_dbg(adap->pdev_dev, "ch_ktls driver has no registered tlsdev_ops\n"); return -EOPNOTSUPP;
} break; #endif/* CONFIG_CHELSIO_TLS_DEVICE */ #if IS_ENABLED(CONFIG_CHELSIO_IPSEC_INLINE) case CXGB4_XFRMDEV_OPS: if (!adap->uld[CXGB4_ULD_IPSEC].handle) {
dev_dbg(adap->pdev_dev, "chipsec driver is not loaded\n"); return -EOPNOTSUPP;
} if (!adap->uld[CXGB4_ULD_IPSEC].xfrmdev_ops) {
dev_dbg(adap->pdev_dev, "chipsec driver has no registered xfrmdev_ops\n"); return -EOPNOTSUPP;
} break; #endif/* CONFIG_CHELSIO_IPSEC_INLINE */ default:
dev_dbg(adap->pdev_dev, "driver has no support for offload %d\n", op_val); return -EOPNOTSUPP;
}
mutex_lock(&uld_mutex);
ret = chcr_offload_state(adap, CXGB4_TLSDEV_OPS); if (ret) goto out_unlock;
ret = cxgb4_set_ktls_feature(adap, FW_PARAMS_PARAM_DEV_KTLS_HW_ENABLE); if (ret) goto out_unlock;
ret = adap->uld[CXGB4_ULD_KTLS].tlsdev_ops->tls_dev_add(netdev, sk,
direction,
crypto_info,
tcp_sn); /* if there is a failure, clear the refcount */ if (ret)
cxgb4_set_ktls_feature(adap,
FW_PARAMS_PARAM_DEV_KTLS_HW_DISABLE);
out_unlock:
mutex_unlock(&uld_mutex); return ret;
}
if (!mutex_trylock(&uld_mutex)) {
NL_SET_ERR_MSG_MOD(extack, "crypto uld critical resource is under use"); return -EBUSY;
}
ret = chcr_offload_state(adap, CXGB4_XFRMDEV_OPS); if (ret) goto out_unlock;
ret = adap->uld[CXGB4_ULD_IPSEC].xfrmdev_ops->xdo_dev_state_add(dev, x,
extack);
if (!mutex_trylock(&uld_mutex)) {
dev_dbg(adap->pdev_dev, "crypto uld critical resource is under use\n"); return;
} if (chcr_offload_state(adap, CXGB4_XFRMDEV_OPS)) goto out_unlock;
if (!mutex_trylock(&uld_mutex)) {
dev_dbg(adap->pdev_dev, "crypto uld critical resource is under use\n"); return;
} if (chcr_offload_state(adap, CXGB4_XFRMDEV_OPS)) goto out_unlock;
if (!mutex_trylock(&uld_mutex)) {
dev_dbg(adap->pdev_dev, "crypto uld critical resource is under use\n"); return;
} if (chcr_offload_state(adap, CXGB4_XFRMDEV_OPS)) goto out_unlock;
err = pci_request_regions(pdev, KBUILD_MODNAME); if (err) { /* Just info, some other driver may have claimed the device. */
dev_info(&pdev->dev, "cannot obtain PCI resources\n"); return err;
}
if (adapter->flags & CXGB4_FW_OK) {
err = t4_port_init(adapter, func, func, 0); if (err) goto out_free_dev;
} elseif (adapter->params.nports == 1) { /* If we don't have a connection to the firmware -- possibly *becauseofanerror--grabtherawVPDparameterssowe *cansettheproperMACAddressonthedebugnetwork *interfacethatwe'vecreated.
*/
u8 hw_addr[ETH_ALEN];
u8 *na = adapter->params.vpd.na;
err = t4_get_raw_vpd_params(adapter, &adapter->params.vpd); if (!err) { for (i = 0; i < ETH_ALEN; i++)
hw_addr[i] = (hex2val(na[2 * i + 0]) * 16 +
hex2val(na[2 * i + 1]));
t4_set_hw_addr(adapter, 0, hw_addr);
}
}
if (!(adapter->flags & CXGB4_FW_OK)) goto fw_attach_fail;
/* Configure queues and allocate tables now, they can be needed as *soonasthefirstregister_netdevcompletes.
*/
err = cfg_queues(adapter); if (err) goto out_free_dev;
adapter->smt = t4_init_smt(); if (!adapter->smt) { /* We tolerate a lack of SMT, giving up some functionality */
dev_warn(&pdev->dev, "could not allocate SMT, continuing\n");
}
adapter->l2t = t4_init_l2t(adapter->l2t_start, adapter->l2t_end); if (!adapter->l2t) { /* We tolerate a lack of L2T, giving up some functionality */
dev_warn(&pdev->dev, "could not allocate L2T, continuing\n");
adapter->params.offload = 0;
}
#if IS_ENABLED(CONFIG_IPV6) if (chip_ver <= CHELSIO_T5 &&
(!(t4_read_reg(adapter, LE_DB_CONFIG_A) & ASLIPCOMPEN_F))) { /* CLIP functionality is not present in hardware, *hencedisablealloffloadfeatures
*/
dev_warn(&pdev->dev, "CLIP not enabled in hardware, continuing\n");
adapter->params.offload = 0;
} else {
adapter->clipt = t4_init_clip_tbl(adapter->clipt_start,
adapter->clipt_end); if (!adapter->clipt) { /* We tolerate a lack of clip_table, giving up *somefunctionality
*/
dev_warn(&pdev->dev, "could not allocate Clip table, continuing\n");
adapter->params.offload = 0;
}
} #endif
for_each_port(adapter, i) {
pi = adap2pinfo(adapter, i);
pi->sched_tbl = t4_init_sched(adapter->params.nsched_cls); if (!pi->sched_tbl)
dev_warn(&pdev->dev, "could not activate scheduling on port %d\n",
i);
}
if (is_offload(adapter) || is_hashfilter(adapter)) { if (t4_read_reg(adapter, LE_DB_CONFIG_A) & HASHEN_F) {
u32 v;
v = t4_read_reg(adapter, LE_DB_HASH_CONFIG_A); if (chip_ver <= CHELSIO_T5) {
adapter->tids.nhash = 1 << HASHTIDSIZE_G(v);
v = t4_read_reg(adapter, LE_DB_TID_HASHBASE_A);
adapter->tids.hash_base = v / 4;
} else {
adapter->tids.nhash = HASHTBLSIZE_G(v) << 3;
v = t4_read_reg(adapter,
T6_LE_DB_HASH_TID_BASE_A);
adapter->tids.hash_base = v;
}
}
}
if (tid_init(&adapter->tids) < 0) {
dev_warn(&pdev->dev, "could not allocate TID table, " "continuing\n");
adapter->params.offload = 0;
} else {
adapter->tc_u32 = cxgb4_init_tc_u32(adapter); if (!adapter->tc_u32)
dev_warn(&pdev->dev, "could not offload tc u32, continuing\n");
if (cxgb4_init_tc_flower(adapter))
dev_warn(&pdev->dev, "could not offload tc flower, continuing\n");
if (cxgb4_init_tc_mqprio(adapter))
dev_warn(&pdev->dev, "could not offload tc mqprio, continuing\n");
if (cxgb4_init_tc_matchall(adapter))
dev_warn(&pdev->dev, "could not offload tc matchall, continuing\n"); if (cxgb4_init_ethtool_filters(adapter))
dev_warn(&pdev->dev, "could not initialize ethtool filters, continuing\n");
}
/* See what interrupts we'll be using */ if (msi > 1 && enable_msix(adapter) == 0)
adapter->flags |= CXGB4_USING_MSIX; elseif (msi > 0 && pci_enable_msi(pdev) == 0) {
adapter->flags |= CXGB4_USING_MSI; if (msi > 1)
free_msix_info(adapter);
}
/* check for PCI Express bandwidth capabiltites */
pcie_print_link_status(pdev);
cxgb4_init_mps_ref_entries(adapter);
err = init_rss(adapter); if (err) goto out_free_dev;
err = setup_non_data_intr(adapter); if (err) {
dev_err(adapter->pdev_dev, "Non Data interrupt allocation failed, err: %d\n", err); goto out_free_dev;
}
err = register_netdev(adapter->port[i]); if (err) break;
adapter->chan_map[pi->tx_chan] = i;
print_port_info(adapter->port[i]);
} if (i == 0) {
dev_err(&pdev->dev, "could not register any net devices\n"); goto out_free_dev;
} if (err) {
dev_warn(&pdev->dev, "only %d net devices registered\n", i);
err = 0;
}
if (cxgb4_debugfs_root) {
adapter->debugfs_root = debugfs_create_dir(pci_name(pdev),
cxgb4_debugfs_root);
setup_debugfs(adapter);
}
/* PCIe EEH recovery on powerpc platforms needs fundamental reset */
pdev->needs_freset = 1;
if (is_uld(adapter))
cxgb4_uld_enable(adapter);
if (!is_t4(adapter->params.chip))
cxgb4_ptp_init(adapter);
if (IS_REACHABLE(CONFIG_THERMAL) &&
!is_t4(adapter->params.chip) && (adapter->flags & CXGB4_FW_OK))
cxgb4_thermal_init(adapter);
print_adapter_info(adapter); return0;
out_free_dev:
t4_free_sge_resources(adapter);
free_some_resources(adapter); if (adapter->flags & CXGB4_USING_MSIX)
free_msix_info(adapter); if (adapter->num_uld || adapter->num_ofld_uld)
t4_uld_mem_free(adapter);
out_unmap_bar: if (!is_t4(adapter->params.chip))
iounmap(adapter->bar2);
out_free_adapter: if (adapter->workq)
destroy_workqueue(adapter->workq);
/* As with remove_one() above (see extended comment), we only want do *docleanuponPCIDeviceswhichwentallthewaythroughinit_one() *...
*/ if (!adapter) {
pci_release_regions(pdev); return;
}
adapter->flags |= CXGB4_SHUTTING_DOWN;
if (adapter->pf == 4) { int i;
for_each_port(adapter, i) if (adapter->port[i]->reg_state == NETREG_REGISTERED)
cxgb_close(adapter->port[i]);
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.325Bemerkung:
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.