2009-11-29 23:15:25 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* Driver for Solarflare Solarstorm network controllers and boards
|
2011-02-25 08:01:34 +08:00
|
|
|
* Copyright 2009-2010 Solarflare Communications Inc.
|
2009-11-29 23:15:25 +08:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License version 2 as published
|
|
|
|
* by the Free Software Foundation, incorporated herein by reference.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "net_driver.h"
|
|
|
|
#include "efx.h"
|
|
|
|
#include "mcdi.h"
|
|
|
|
#include "mcdi_pcol.h"
|
|
|
|
|
sfc: Add SR-IOV back-end support for SFC9000 family
On the SFC9000 family, each port has 1024 Virtual Interfaces (VIs),
each with an RX queue, a TX queue, an event queue and a mailbox
register. These may be assigned to up to 127 SR-IOV virtual functions
per port, with up to 64 VIs per VF.
We allocate an extra channel (IRQ and event queue only) to receive
requests from VF drivers.
There is a per-port limit of 4 concurrent RX queue flushes, and queue
flushes may be initiated by the MC in response to a Function Level
Reset (FLR) of a VF. Therefore, when SR-IOV is in use, we submit all
flush requests via the MC.
The RSS indirection table is shared with VFs, so the number of RX
queues used in the PF is limited to the number of VIs per VF.
This is almost entirely the work of Steve Hodgson, formerly
shodgson@solarflare.com.
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2012-02-14 08:48:07 +08:00
|
|
|
int efx_mcdi_set_mac(struct efx_nic *efx)
|
2009-11-29 23:15:25 +08:00
|
|
|
{
|
|
|
|
u32 reject, fcntl;
|
|
|
|
u8 cmdbytes[MC_CMD_SET_MAC_IN_LEN];
|
|
|
|
|
|
|
|
memcpy(cmdbytes + MC_CMD_SET_MAC_IN_ADDR_OFST,
|
|
|
|
efx->net_dev->dev_addr, ETH_ALEN);
|
|
|
|
|
|
|
|
MCDI_SET_DWORD(cmdbytes, SET_MAC_IN_MTU,
|
|
|
|
EFX_MAX_FRAME_LEN(efx->net_dev->mtu));
|
|
|
|
MCDI_SET_DWORD(cmdbytes, SET_MAC_IN_DRAIN, 0);
|
|
|
|
|
|
|
|
/* The MCDI command provides for controlling accept/reject
|
|
|
|
* of broadcast packets too, but the driver doesn't currently
|
|
|
|
* expose this. */
|
|
|
|
reject = (efx->promiscuous) ? 0 :
|
|
|
|
(1 << MC_CMD_SET_MAC_IN_REJECT_UNCST_LBN);
|
|
|
|
MCDI_SET_DWORD(cmdbytes, SET_MAC_IN_REJECT, reject);
|
|
|
|
|
|
|
|
switch (efx->wanted_fc) {
|
|
|
|
case EFX_FC_RX | EFX_FC_TX:
|
|
|
|
fcntl = MC_CMD_FCNTL_BIDIR;
|
|
|
|
break;
|
|
|
|
case EFX_FC_RX:
|
|
|
|
fcntl = MC_CMD_FCNTL_RESPOND;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
fcntl = MC_CMD_FCNTL_OFF;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (efx->wanted_fc & EFX_FC_AUTO)
|
|
|
|
fcntl = MC_CMD_FCNTL_AUTO;
|
2011-05-23 19:18:45 +08:00
|
|
|
if (efx->fc_disable)
|
|
|
|
fcntl = MC_CMD_FCNTL_OFF;
|
2009-11-29 23:15:25 +08:00
|
|
|
|
|
|
|
MCDI_SET_DWORD(cmdbytes, SET_MAC_IN_FCNTL, fcntl);
|
|
|
|
|
|
|
|
return efx_mcdi_rpc(efx, MC_CMD_SET_MAC, cmdbytes, sizeof(cmdbytes),
|
|
|
|
NULL, 0, NULL);
|
|
|
|
}
|
|
|
|
|
2011-09-08 09:09:42 +08:00
|
|
|
bool efx_mcdi_mac_check_fault(struct efx_nic *efx)
|
2009-11-29 23:15:25 +08:00
|
|
|
{
|
|
|
|
u8 outbuf[MC_CMD_GET_LINK_OUT_LEN];
|
|
|
|
size_t outlength;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
BUILD_BUG_ON(MC_CMD_GET_LINK_IN_LEN != 0);
|
|
|
|
|
|
|
|
rc = efx_mcdi_rpc(efx, MC_CMD_GET_LINK, NULL, 0,
|
|
|
|
outbuf, sizeof(outbuf), &outlength);
|
2011-09-08 09:09:42 +08:00
|
|
|
if (rc) {
|
|
|
|
netif_err(efx, hw, efx->net_dev, "%s: failed rc=%d\n",
|
|
|
|
__func__, rc);
|
|
|
|
return true;
|
|
|
|
}
|
2009-11-29 23:15:25 +08:00
|
|
|
|
2011-09-08 09:09:42 +08:00
|
|
|
return MCDI_DWORD(outbuf, GET_LINK_OUT_MAC_FAULT) != 0;
|
2009-11-29 23:15:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int efx_mcdi_mac_stats(struct efx_nic *efx, dma_addr_t dma_addr,
|
|
|
|
u32 dma_len, int enable, int clear)
|
|
|
|
{
|
|
|
|
u8 inbuf[MC_CMD_MAC_STATS_IN_LEN];
|
|
|
|
int rc;
|
|
|
|
efx_dword_t *cmd_ptr;
|
2010-04-28 17:29:32 +08:00
|
|
|
int period = enable ? 1000 : 0;
|
2009-11-29 23:15:25 +08:00
|
|
|
u32 addr_hi;
|
|
|
|
u32 addr_lo;
|
|
|
|
|
2011-12-20 08:44:06 +08:00
|
|
|
BUILD_BUG_ON(MC_CMD_MAC_STATS_OUT_DMA_LEN != 0);
|
2009-11-29 23:15:25 +08:00
|
|
|
|
|
|
|
addr_lo = ((u64)dma_addr) >> 0;
|
|
|
|
addr_hi = ((u64)dma_addr) >> 32;
|
|
|
|
|
|
|
|
MCDI_SET_DWORD(inbuf, MAC_STATS_IN_DMA_ADDR_LO, addr_lo);
|
|
|
|
MCDI_SET_DWORD(inbuf, MAC_STATS_IN_DMA_ADDR_HI, addr_hi);
|
|
|
|
cmd_ptr = (efx_dword_t *)MCDI_PTR(inbuf, MAC_STATS_IN_CMD);
|
2010-04-28 17:29:32 +08:00
|
|
|
EFX_POPULATE_DWORD_7(*cmd_ptr,
|
2011-12-20 08:44:06 +08:00
|
|
|
MC_CMD_MAC_STATS_IN_DMA, !!enable,
|
|
|
|
MC_CMD_MAC_STATS_IN_CLEAR, clear,
|
|
|
|
MC_CMD_MAC_STATS_IN_PERIODIC_CHANGE, 1,
|
|
|
|
MC_CMD_MAC_STATS_IN_PERIODIC_ENABLE, !!enable,
|
|
|
|
MC_CMD_MAC_STATS_IN_PERIODIC_CLEAR, 0,
|
|
|
|
MC_CMD_MAC_STATS_IN_PERIODIC_NOEVENT, 1,
|
|
|
|
MC_CMD_MAC_STATS_IN_PERIOD_MS, period);
|
2009-11-29 23:15:25 +08:00
|
|
|
MCDI_SET_DWORD(inbuf, MAC_STATS_IN_DMA_LEN, dma_len);
|
|
|
|
|
|
|
|
rc = efx_mcdi_rpc(efx, MC_CMD_MAC_STATS, inbuf, sizeof(inbuf),
|
|
|
|
NULL, 0, NULL);
|
|
|
|
if (rc)
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
fail:
|
2010-06-23 19:30:07 +08:00
|
|
|
netif_err(efx, hw, efx->net_dev, "%s: %s failed rc=%d\n",
|
|
|
|
__func__, enable ? "enable" : "disable", rc);
|
2009-11-29 23:15:25 +08:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2011-09-03 07:15:00 +08:00
|
|
|
int efx_mcdi_mac_reconfigure(struct efx_nic *efx)
|
2009-11-29 23:15:25 +08:00
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
2011-09-14 02:47:48 +08:00
|
|
|
WARN_ON(!mutex_is_locked(&efx->mac_lock));
|
|
|
|
|
2009-11-29 23:15:25 +08:00
|
|
|
rc = efx_mcdi_set_mac(efx);
|
|
|
|
if (rc != 0)
|
|
|
|
return rc;
|
|
|
|
|
2011-09-14 02:47:48 +08:00
|
|
|
return efx_mcdi_rpc(efx, MC_CMD_SET_MCAST_HASH,
|
|
|
|
efx->multicast_hash.byte,
|
|
|
|
sizeof(efx->multicast_hash),
|
|
|
|
NULL, 0, NULL);
|
2009-11-29 23:15:25 +08:00
|
|
|
}
|