2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* linux/drivers/message/fusion/mptlan.c
|
|
|
|
* IP Over Fibre Channel device driver.
|
2007-08-14 10:52:54 +00:00
|
|
|
* For use with LSI Fibre Channel PCI chip/adapters
|
|
|
|
* running LSI Fusion MPT (Message Passing Technology) firmware.
|
2005-04-16 22:20:36 +00:00
|
|
|
*
|
2008-05-20 19:26:41 +00:00
|
|
|
* Copyright (c) 2000-2008 LSI Corporation
|
2007-06-13 22:31:07 +00:00
|
|
|
* (mailto:DL-MPTFusionLinux@lsi.com)
|
2005-04-16 22:20:36 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
|
|
|
|
/*
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; version 2 of the License.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
NO WARRANTY
|
|
|
|
THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
|
|
CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
|
|
|
|
LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
|
|
|
|
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
|
|
|
|
solely responsible for determining the appropriateness of using and
|
|
|
|
distributing the Program and assumes all risks associated with its
|
|
|
|
exercise of rights under this Agreement, including but not limited to
|
|
|
|
the risks and costs of program errors, damage to or loss of data,
|
|
|
|
programs or equipment, and unavailability or interruption of operations.
|
|
|
|
|
|
|
|
DISCLAIMER OF LIABILITY
|
|
|
|
NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
|
|
|
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
|
|
|
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
|
|
|
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
|
|
|
USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
|
|
|
|
HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
|
|
|
|
/*
|
|
|
|
* Define statements used for debugging
|
|
|
|
*/
|
|
|
|
//#define MPT_LAN_IO_DEBUG
|
|
|
|
|
|
|
|
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
|
|
|
|
|
|
|
|
#include "mptlan.h"
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/fs.h>
|
2009-10-07 13:09:06 +00:00
|
|
|
#include <linux/sched.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 08:04:11 +00:00
|
|
|
#include <linux/slab.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2007-01-05 03:47:47 +00:00
|
|
|
#define my_VERSION MPT_LINUX_VERSION_COMMON
|
2005-04-16 22:20:36 +00:00
|
|
|
#define MYNAM "mptlan"
|
|
|
|
|
|
|
|
MODULE_LICENSE("GPL");
|
2007-01-05 03:47:47 +00:00
|
|
|
MODULE_VERSION(my_VERSION);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
|
|
|
|
/*
|
|
|
|
* MPT LAN message sizes without variable part.
|
|
|
|
*/
|
|
|
|
#define MPT_LAN_RECEIVE_POST_REQUEST_SIZE \
|
|
|
|
(sizeof(LANReceivePostRequest_t) - sizeof(SGE_MPI_UNION))
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Fusion MPT LAN private structures
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct BufferControl {
|
|
|
|
struct sk_buff *skb;
|
|
|
|
dma_addr_t dma;
|
|
|
|
unsigned int len;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct mpt_lan_priv {
|
|
|
|
MPT_ADAPTER *mpt_dev;
|
|
|
|
u8 pnum; /* Port number in the IOC. This is not a Unix network port! */
|
|
|
|
|
|
|
|
atomic_t buckets_out; /* number of unused buckets on IOC */
|
|
|
|
int bucketthresh; /* Send more when this many left */
|
|
|
|
|
|
|
|
int *mpt_txfidx; /* Free Tx Context list */
|
|
|
|
int mpt_txfidx_tail;
|
|
|
|
spinlock_t txfidx_lock;
|
|
|
|
|
|
|
|
int *mpt_rxfidx; /* Free Rx Context list */
|
|
|
|
int mpt_rxfidx_tail;
|
|
|
|
spinlock_t rxfidx_lock;
|
|
|
|
|
|
|
|
struct BufferControl *RcvCtl; /* Receive BufferControl structs */
|
|
|
|
struct BufferControl *SendCtl; /* Send BufferControl structs */
|
|
|
|
|
|
|
|
int max_buckets_out; /* Max buckets to send to IOC */
|
|
|
|
int tx_max_out; /* IOC's Tx queue len */
|
|
|
|
|
|
|
|
u32 total_posted;
|
|
|
|
u32 total_received;
|
|
|
|
|
2006-11-22 14:57:56 +00:00
|
|
|
struct delayed_work post_buckets_task;
|
|
|
|
struct net_device *dev;
|
2005-04-16 22:20:36 +00:00
|
|
|
unsigned long post_buckets_active;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct mpt_lan_ohdr {
|
|
|
|
u16 dtype;
|
|
|
|
u8 daddr[FC_ALEN];
|
|
|
|
u16 stype;
|
|
|
|
u8 saddr[FC_ALEN];
|
|
|
|
};
|
|
|
|
|
|
|
|
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Forward protos...
|
|
|
|
*/
|
|
|
|
static int lan_reply (MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf,
|
|
|
|
MPT_FRAME_HDR *reply);
|
|
|
|
static int mpt_lan_open(struct net_device *dev);
|
|
|
|
static int mpt_lan_reset(struct net_device *dev);
|
|
|
|
static int mpt_lan_close(struct net_device *dev);
|
2006-11-22 14:57:56 +00:00
|
|
|
static void mpt_lan_post_receive_buckets(struct mpt_lan_priv *priv);
|
2005-04-16 22:20:36 +00:00
|
|
|
static void mpt_lan_wake_post_buckets_task(struct net_device *dev,
|
|
|
|
int priority);
|
|
|
|
static int mpt_lan_receive_post_turbo(struct net_device *dev, u32 tmsg);
|
|
|
|
static int mpt_lan_receive_post_reply(struct net_device *dev,
|
|
|
|
LANReceivePostReply_t *pRecvRep);
|
|
|
|
static int mpt_lan_send_turbo(struct net_device *dev, u32 tmsg);
|
|
|
|
static int mpt_lan_send_reply(struct net_device *dev,
|
|
|
|
LANSendReply_t *pSendRep);
|
|
|
|
static int mpt_lan_ioc_reset(MPT_ADAPTER *ioc, int reset_phase);
|
|
|
|
static int mpt_lan_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply);
|
|
|
|
static unsigned short mpt_lan_type_trans(struct sk_buff *skb,
|
|
|
|
struct net_device *dev);
|
|
|
|
|
|
|
|
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
|
|
|
|
/*
|
|
|
|
* Fusion MPT LAN private data
|
|
|
|
*/
|
2007-08-14 10:42:53 +00:00
|
|
|
static u8 LanCtx = MPT_MAX_PROTOCOL_DRIVERS;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
static u32 max_buckets_out = 127;
|
|
|
|
static u32 tx_max_out_p = 127 - 16;
|
|
|
|
|
|
|
|
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
|
|
|
|
/**
|
|
|
|
* lan_reply - Handle all data sent from the hardware.
|
|
|
|
* @ioc: Pointer to MPT_ADAPTER structure
|
|
|
|
* @mf: Pointer to original MPT request frame (NULL if TurboReply)
|
|
|
|
* @reply: Pointer to MPT reply frame
|
|
|
|
*
|
|
|
|
* Returns 1 indicating original alloc'd request frame ptr
|
|
|
|
* should be freed, or 0 if it shouldn't.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
lan_reply (MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *reply)
|
|
|
|
{
|
|
|
|
struct net_device *dev = ioc->netdev;
|
|
|
|
int FreeReqFrame = 0;
|
|
|
|
|
|
|
|
dioprintk((KERN_INFO MYNAM ": %s/%s: Got reply.\n",
|
|
|
|
IOC_AND_NETDEV_NAMES_s_s(dev)));
|
|
|
|
|
|
|
|
// dioprintk((KERN_INFO MYNAM "@lan_reply: mf = %p, reply = %p\n",
|
|
|
|
// mf, reply));
|
|
|
|
|
|
|
|
if (mf == NULL) {
|
|
|
|
u32 tmsg = CAST_PTR_TO_U32(reply);
|
|
|
|
|
|
|
|
dioprintk((KERN_INFO MYNAM ": %s/%s: @lan_reply, tmsg %08x\n",
|
|
|
|
IOC_AND_NETDEV_NAMES_s_s(dev),
|
|
|
|
tmsg));
|
|
|
|
|
|
|
|
switch (GET_LAN_FORM(tmsg)) {
|
|
|
|
|
|
|
|
// NOTE! (Optimization) First case here is now caught in
|
|
|
|
// mptbase.c::mpt_interrupt() routine and callcack here
|
2005-04-22 22:01:52 +00:00
|
|
|
// is now skipped for this case!
|
2005-04-16 22:20:36 +00:00
|
|
|
#if 0
|
|
|
|
case LAN_REPLY_FORM_MESSAGE_CONTEXT:
|
|
|
|
// dioprintk((KERN_INFO MYNAM "/lan_reply: "
|
|
|
|
// "MessageContext turbo reply received\n"));
|
|
|
|
FreeReqFrame = 1;
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
case LAN_REPLY_FORM_SEND_SINGLE:
|
|
|
|
// dioprintk((MYNAM "/lan_reply: "
|
|
|
|
// "calling mpt_lan_send_reply (turbo)\n"));
|
|
|
|
|
2005-04-22 22:01:52 +00:00
|
|
|
// Potential BUG here?
|
2005-04-16 22:20:36 +00:00
|
|
|
// FreeReqFrame = mpt_lan_send_turbo(dev, tmsg);
|
|
|
|
// If/when mpt_lan_send_turbo would return 1 here,
|
|
|
|
// calling routine (mptbase.c|mpt_interrupt)
|
|
|
|
// would Oops because mf has already been set
|
|
|
|
// to NULL. So after return from this func,
|
|
|
|
// mpt_interrupt() will attempt to put (NULL) mf ptr
|
|
|
|
// item back onto its adapter FreeQ - Oops!:-(
|
|
|
|
// It's Ok, since mpt_lan_send_turbo() *currently*
|
|
|
|
// always returns 0, but..., just in case:
|
|
|
|
|
|
|
|
(void) mpt_lan_send_turbo(dev, tmsg);
|
|
|
|
FreeReqFrame = 0;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LAN_REPLY_FORM_RECEIVE_SINGLE:
|
|
|
|
// dioprintk((KERN_INFO MYNAM "@lan_reply: "
|
|
|
|
// "rcv-Turbo = %08x\n", tmsg));
|
|
|
|
mpt_lan_receive_post_turbo(dev, tmsg);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
printk (KERN_ERR MYNAM "/lan_reply: Got a turbo reply "
|
|
|
|
"that I don't know what to do with\n");
|
|
|
|
|
|
|
|
/* CHECKME! Hmmm... FreeReqFrame is 0 here; is that right? */
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FreeReqFrame;
|
|
|
|
}
|
|
|
|
|
|
|
|
// msg = (u32 *) reply;
|
|
|
|
// dioprintk((KERN_INFO MYNAM "@lan_reply: msg = %08x %08x %08x %08x\n",
|
|
|
|
// le32_to_cpu(msg[0]), le32_to_cpu(msg[1]),
|
|
|
|
// le32_to_cpu(msg[2]), le32_to_cpu(msg[3])));
|
|
|
|
// dioprintk((KERN_INFO MYNAM "@lan_reply: Function = %02xh\n",
|
|
|
|
// reply->u.hdr.Function));
|
|
|
|
|
|
|
|
switch (reply->u.hdr.Function) {
|
|
|
|
|
|
|
|
case MPI_FUNCTION_LAN_SEND:
|
|
|
|
{
|
|
|
|
LANSendReply_t *pSendRep;
|
|
|
|
|
|
|
|
pSendRep = (LANSendReply_t *) reply;
|
|
|
|
FreeReqFrame = mpt_lan_send_reply(dev, pSendRep);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case MPI_FUNCTION_LAN_RECEIVE:
|
|
|
|
{
|
|
|
|
LANReceivePostReply_t *pRecvRep;
|
|
|
|
|
|
|
|
pRecvRep = (LANReceivePostReply_t *) reply;
|
|
|
|
if (pRecvRep->NumberOfContexts) {
|
|
|
|
mpt_lan_receive_post_reply(dev, pRecvRep);
|
|
|
|
if (!(pRecvRep->MsgFlags & MPI_MSGFLAGS_CONTINUATION_REPLY))
|
|
|
|
FreeReqFrame = 1;
|
|
|
|
} else
|
|
|
|
dioprintk((KERN_INFO MYNAM "@lan_reply: zero context "
|
|
|
|
"ReceivePostReply received.\n"));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case MPI_FUNCTION_LAN_RESET:
|
|
|
|
/* Just a default reply. Might want to check it to
|
|
|
|
* make sure that everything went ok.
|
|
|
|
*/
|
|
|
|
FreeReqFrame = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MPI_FUNCTION_EVENT_NOTIFICATION:
|
|
|
|
case MPI_FUNCTION_EVENT_ACK:
|
2005-04-22 22:01:52 +00:00
|
|
|
/* _EVENT_NOTIFICATION should NOT come down this path any more.
|
2005-04-16 22:20:36 +00:00
|
|
|
* Should be routed to mpt_lan_event_process(), but just in case...
|
|
|
|
*/
|
|
|
|
FreeReqFrame = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
printk (KERN_ERR MYNAM "/lan_reply: Got a non-turbo "
|
|
|
|
"reply that I don't know what to do with\n");
|
|
|
|
|
|
|
|
/* CHECKME! Hmmm... FreeReqFrame is 0 here; is that right? */
|
|
|
|
FreeReqFrame = 1;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FreeReqFrame;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
|
|
|
|
static int
|
|
|
|
mpt_lan_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
|
|
|
|
{
|
|
|
|
struct net_device *dev = ioc->netdev;
|
[SCSI] fusion SAS support (mptsas driver) updates
Summary of Changes:
* splitting mpt_interrupt per Christophs suggestion
about a month ago
* rename ScsiCfgData to SpiCfgData structure,
then move all the raid related info into
new structure called RaidCfgData. This is
done because SAS supports RAID, as well as SPI,
so the raid stuff should be seperate.
* incorrect timeout calculation for cntdn
inside WaitForDoorbellAck and WaitForDoortbellInt
* add support for interpreting SAS Log Info
* Increase Event Log Size from 0xA to 0x32
* Fix bug in mptsas/mptfc/mptspi - when controller
has Initiator Mode Disabled, and only running in
TargetMode, the mptctl would panic when loading.
The fix is to return 0, instead of -ENODEV, in
SCSI LLD respective probe routines
* Fix bug in mptlan.c - driver will panic if
there is host reset, due to dev being set to
zero in mpt_lan_ioc_reset
* Fix's for SPI - Echo Buffer
* Several fix's in mptscsih_io_done - FCP Response
info, RESIDUAL_MISMATCH, Data Underrun, etc.
* Cleanup Error Handling - EH handlers,
mptscsih_flush_cmds, and zeroing out ScsiLookup
from mptscsih_qcmd
* Cleanup asyn event handling from
mptscsih -> mptscsih_event_process. Also
added support for SAS Persistent Table Full,
an asyn event
Signed-off-by: Eric Moore <Eric.Moore@lsil.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-09-15 00:09:10 +00:00
|
|
|
struct mpt_lan_priv *priv;
|
|
|
|
|
|
|
|
if (dev == NULL)
|
|
|
|
return(1);
|
|
|
|
else
|
|
|
|
priv = netdev_priv(dev);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
dlprintk((KERN_INFO MYNAM ": IOC %s_reset routed to LAN driver!\n",
|
|
|
|
reset_phase==MPT_IOC_SETUP_RESET ? "setup" : (
|
|
|
|
reset_phase==MPT_IOC_PRE_RESET ? "pre" : "post")));
|
|
|
|
|
|
|
|
if (priv->mpt_rxfidx == NULL)
|
|
|
|
return (1);
|
|
|
|
|
|
|
|
if (reset_phase == MPT_IOC_SETUP_RESET) {
|
|
|
|
;
|
|
|
|
} else if (reset_phase == MPT_IOC_PRE_RESET) {
|
|
|
|
int i;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
netif_stop_queue(dev);
|
|
|
|
|
|
|
|
dlprintk ((KERN_INFO "mptlan/ioc_reset: called netif_stop_queue for %s.\n", dev->name));
|
|
|
|
|
|
|
|
atomic_set(&priv->buckets_out, 0);
|
|
|
|
|
|
|
|
/* Reset Rx Free Tail index and re-populate the queue. */
|
|
|
|
spin_lock_irqsave(&priv->rxfidx_lock, flags);
|
|
|
|
priv->mpt_rxfidx_tail = -1;
|
|
|
|
for (i = 0; i < priv->max_buckets_out; i++)
|
|
|
|
priv->mpt_rxfidx[++priv->mpt_rxfidx_tail] = i;
|
|
|
|
spin_unlock_irqrestore(&priv->rxfidx_lock, flags);
|
|
|
|
} else {
|
2006-11-22 14:57:56 +00:00
|
|
|
mpt_lan_post_receive_buckets(priv);
|
2005-04-16 22:20:36 +00:00
|
|
|
netif_wake_queue(dev);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
|
|
|
|
static int
|
|
|
|
mpt_lan_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply)
|
|
|
|
{
|
|
|
|
dlprintk((KERN_INFO MYNAM ": MPT event routed to LAN driver!\n"));
|
|
|
|
|
|
|
|
switch (le32_to_cpu(pEvReply->Event)) {
|
|
|
|
case MPI_EVENT_NONE: /* 00 */
|
|
|
|
case MPI_EVENT_LOG_DATA: /* 01 */
|
|
|
|
case MPI_EVENT_STATE_CHANGE: /* 02 */
|
|
|
|
case MPI_EVENT_UNIT_ATTENTION: /* 03 */
|
|
|
|
case MPI_EVENT_IOC_BUS_RESET: /* 04 */
|
|
|
|
case MPI_EVENT_EXT_BUS_RESET: /* 05 */
|
|
|
|
case MPI_EVENT_RESCAN: /* 06 */
|
|
|
|
/* Ok, do we need to do anything here? As far as
|
|
|
|
I can tell, this is when a new device gets added
|
|
|
|
to the loop. */
|
|
|
|
case MPI_EVENT_LINK_STATUS_CHANGE: /* 07 */
|
|
|
|
case MPI_EVENT_LOOP_STATE_CHANGE: /* 08 */
|
|
|
|
case MPI_EVENT_LOGOUT: /* 09 */
|
|
|
|
case MPI_EVENT_EVENT_CHANGE: /* 0A */
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* NOTE: pEvent->AckRequired handling now done in mptbase.c;
|
|
|
|
* Do NOT do it here now!
|
|
|
|
*/
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
|
|
|
|
static int
|
|
|
|
mpt_lan_open(struct net_device *dev)
|
|
|
|
{
|
|
|
|
struct mpt_lan_priv *priv = netdev_priv(dev);
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (mpt_lan_reset(dev) != 0) {
|
|
|
|
MPT_ADAPTER *mpt_dev = priv->mpt_dev;
|
|
|
|
|
|
|
|
printk (KERN_WARNING MYNAM "/lan_open: lan_reset failed.");
|
|
|
|
|
|
|
|
if (mpt_dev->active)
|
|
|
|
printk ("The ioc is active. Perhaps it needs to be"
|
|
|
|
" reset?\n");
|
|
|
|
else
|
|
|
|
printk ("The ioc in inactive, most likely in the "
|
|
|
|
"process of being reset. Please try again in "
|
|
|
|
"a moment.\n");
|
|
|
|
}
|
|
|
|
|
treewide: kmalloc() -> kmalloc_array()
The kmalloc() function has a 2-factor argument form, kmalloc_array(). This
patch replaces cases of:
kmalloc(a * b, gfp)
with:
kmalloc_array(a * b, gfp)
as well as handling cases of:
kmalloc(a * b * c, gfp)
with:
kmalloc(array3_size(a, b, c), gfp)
as it's slightly less ugly than:
kmalloc_array(array_size(a, b), c, gfp)
This does, however, attempt to ignore constant size factors like:
kmalloc(4 * 1024, gfp)
though any constants defined via macros get caught up in the conversion.
Any factors with a sizeof() of "unsigned char", "char", and "u8" were
dropped, since they're redundant.
The tools/ directory was manually excluded, since it has its own
implementation of kmalloc().
The Coccinelle script used for this was:
// Fix redundant parens around sizeof().
@@
type TYPE;
expression THING, E;
@@
(
kmalloc(
- (sizeof(TYPE)) * E
+ sizeof(TYPE) * E
, ...)
|
kmalloc(
- (sizeof(THING)) * E
+ sizeof(THING) * E
, ...)
)
// Drop single-byte sizes and redundant parens.
@@
expression COUNT;
typedef u8;
typedef __u8;
@@
(
kmalloc(
- sizeof(u8) * (COUNT)
+ COUNT
, ...)
|
kmalloc(
- sizeof(__u8) * (COUNT)
+ COUNT
, ...)
|
kmalloc(
- sizeof(char) * (COUNT)
+ COUNT
, ...)
|
kmalloc(
- sizeof(unsigned char) * (COUNT)
+ COUNT
, ...)
|
kmalloc(
- sizeof(u8) * COUNT
+ COUNT
, ...)
|
kmalloc(
- sizeof(__u8) * COUNT
+ COUNT
, ...)
|
kmalloc(
- sizeof(char) * COUNT
+ COUNT
, ...)
|
kmalloc(
- sizeof(unsigned char) * COUNT
+ COUNT
, ...)
)
// 2-factor product with sizeof(type/expression) and identifier or constant.
@@
type TYPE;
expression THING;
identifier COUNT_ID;
constant COUNT_CONST;
@@
(
- kmalloc
+ kmalloc_array
(
- sizeof(TYPE) * (COUNT_ID)
+ COUNT_ID, sizeof(TYPE)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(TYPE) * COUNT_ID
+ COUNT_ID, sizeof(TYPE)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(TYPE) * (COUNT_CONST)
+ COUNT_CONST, sizeof(TYPE)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(TYPE) * COUNT_CONST
+ COUNT_CONST, sizeof(TYPE)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(THING) * (COUNT_ID)
+ COUNT_ID, sizeof(THING)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(THING) * COUNT_ID
+ COUNT_ID, sizeof(THING)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(THING) * (COUNT_CONST)
+ COUNT_CONST, sizeof(THING)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(THING) * COUNT_CONST
+ COUNT_CONST, sizeof(THING)
, ...)
)
// 2-factor product, only identifiers.
@@
identifier SIZE, COUNT;
@@
- kmalloc
+ kmalloc_array
(
- SIZE * COUNT
+ COUNT, SIZE
, ...)
// 3-factor product with 1 sizeof(type) or sizeof(expression), with
// redundant parens removed.
@@
expression THING;
identifier STRIDE, COUNT;
type TYPE;
@@
(
kmalloc(
- sizeof(TYPE) * (COUNT) * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kmalloc(
- sizeof(TYPE) * (COUNT) * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kmalloc(
- sizeof(TYPE) * COUNT * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kmalloc(
- sizeof(TYPE) * COUNT * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kmalloc(
- sizeof(THING) * (COUNT) * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
kmalloc(
- sizeof(THING) * (COUNT) * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
kmalloc(
- sizeof(THING) * COUNT * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
kmalloc(
- sizeof(THING) * COUNT * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
)
// 3-factor product with 2 sizeof(variable), with redundant parens removed.
@@
expression THING1, THING2;
identifier COUNT;
type TYPE1, TYPE2;
@@
(
kmalloc(
- sizeof(TYPE1) * sizeof(TYPE2) * COUNT
+ array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
, ...)
|
kmalloc(
- sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
, ...)
|
kmalloc(
- sizeof(THING1) * sizeof(THING2) * COUNT
+ array3_size(COUNT, sizeof(THING1), sizeof(THING2))
, ...)
|
kmalloc(
- sizeof(THING1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(THING1), sizeof(THING2))
, ...)
|
kmalloc(
- sizeof(TYPE1) * sizeof(THING2) * COUNT
+ array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
, ...)
|
kmalloc(
- sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
, ...)
)
// 3-factor product, only identifiers, with redundant parens removed.
@@
identifier STRIDE, SIZE, COUNT;
@@
(
kmalloc(
- (COUNT) * STRIDE * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- COUNT * (STRIDE) * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- COUNT * STRIDE * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- (COUNT) * (STRIDE) * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- COUNT * (STRIDE) * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- (COUNT) * STRIDE * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- (COUNT) * (STRIDE) * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- COUNT * STRIDE * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
)
// Any remaining multi-factor products, first at least 3-factor products,
// when they're not all constants...
@@
expression E1, E2, E3;
constant C1, C2, C3;
@@
(
kmalloc(C1 * C2 * C3, ...)
|
kmalloc(
- (E1) * E2 * E3
+ array3_size(E1, E2, E3)
, ...)
|
kmalloc(
- (E1) * (E2) * E3
+ array3_size(E1, E2, E3)
, ...)
|
kmalloc(
- (E1) * (E2) * (E3)
+ array3_size(E1, E2, E3)
, ...)
|
kmalloc(
- E1 * E2 * E3
+ array3_size(E1, E2, E3)
, ...)
)
// And then all remaining 2 factors products when they're not all constants,
// keeping sizeof() as the second factor argument.
@@
expression THING, E1, E2;
type TYPE;
constant C1, C2, C3;
@@
(
kmalloc(sizeof(THING) * C2, ...)
|
kmalloc(sizeof(TYPE) * C2, ...)
|
kmalloc(C1 * C2 * C3, ...)
|
kmalloc(C1 * C2, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(TYPE) * (E2)
+ E2, sizeof(TYPE)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(TYPE) * E2
+ E2, sizeof(TYPE)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(THING) * (E2)
+ E2, sizeof(THING)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(THING) * E2
+ E2, sizeof(THING)
, ...)
|
- kmalloc
+ kmalloc_array
(
- (E1) * E2
+ E1, E2
, ...)
|
- kmalloc
+ kmalloc_array
(
- (E1) * (E2)
+ E1, E2
, ...)
|
- kmalloc
+ kmalloc_array
(
- E1 * E2
+ E1, E2
, ...)
)
Signed-off-by: Kees Cook <keescook@chromium.org>
2018-06-12 20:55:00 +00:00
|
|
|
priv->mpt_txfidx = kmalloc_array(priv->tx_max_out, sizeof(int),
|
|
|
|
GFP_KERNEL);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (priv->mpt_txfidx == NULL)
|
|
|
|
goto out;
|
|
|
|
priv->mpt_txfidx_tail = -1;
|
|
|
|
|
2006-01-13 17:27:50 +00:00
|
|
|
priv->SendCtl = kcalloc(priv->tx_max_out, sizeof(struct BufferControl),
|
2005-04-16 22:20:36 +00:00
|
|
|
GFP_KERNEL);
|
|
|
|
if (priv->SendCtl == NULL)
|
|
|
|
goto out_mpt_txfidx;
|
2006-01-13 17:27:50 +00:00
|
|
|
for (i = 0; i < priv->tx_max_out; i++)
|
2005-04-16 22:20:36 +00:00
|
|
|
priv->mpt_txfidx[++priv->mpt_txfidx_tail] = i;
|
|
|
|
|
|
|
|
dlprintk((KERN_INFO MYNAM "@lo: Finished initializing SendCtl\n"));
|
|
|
|
|
treewide: kmalloc() -> kmalloc_array()
The kmalloc() function has a 2-factor argument form, kmalloc_array(). This
patch replaces cases of:
kmalloc(a * b, gfp)
with:
kmalloc_array(a * b, gfp)
as well as handling cases of:
kmalloc(a * b * c, gfp)
with:
kmalloc(array3_size(a, b, c), gfp)
as it's slightly less ugly than:
kmalloc_array(array_size(a, b), c, gfp)
This does, however, attempt to ignore constant size factors like:
kmalloc(4 * 1024, gfp)
though any constants defined via macros get caught up in the conversion.
Any factors with a sizeof() of "unsigned char", "char", and "u8" were
dropped, since they're redundant.
The tools/ directory was manually excluded, since it has its own
implementation of kmalloc().
The Coccinelle script used for this was:
// Fix redundant parens around sizeof().
@@
type TYPE;
expression THING, E;
@@
(
kmalloc(
- (sizeof(TYPE)) * E
+ sizeof(TYPE) * E
, ...)
|
kmalloc(
- (sizeof(THING)) * E
+ sizeof(THING) * E
, ...)
)
// Drop single-byte sizes and redundant parens.
@@
expression COUNT;
typedef u8;
typedef __u8;
@@
(
kmalloc(
- sizeof(u8) * (COUNT)
+ COUNT
, ...)
|
kmalloc(
- sizeof(__u8) * (COUNT)
+ COUNT
, ...)
|
kmalloc(
- sizeof(char) * (COUNT)
+ COUNT
, ...)
|
kmalloc(
- sizeof(unsigned char) * (COUNT)
+ COUNT
, ...)
|
kmalloc(
- sizeof(u8) * COUNT
+ COUNT
, ...)
|
kmalloc(
- sizeof(__u8) * COUNT
+ COUNT
, ...)
|
kmalloc(
- sizeof(char) * COUNT
+ COUNT
, ...)
|
kmalloc(
- sizeof(unsigned char) * COUNT
+ COUNT
, ...)
)
// 2-factor product with sizeof(type/expression) and identifier or constant.
@@
type TYPE;
expression THING;
identifier COUNT_ID;
constant COUNT_CONST;
@@
(
- kmalloc
+ kmalloc_array
(
- sizeof(TYPE) * (COUNT_ID)
+ COUNT_ID, sizeof(TYPE)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(TYPE) * COUNT_ID
+ COUNT_ID, sizeof(TYPE)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(TYPE) * (COUNT_CONST)
+ COUNT_CONST, sizeof(TYPE)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(TYPE) * COUNT_CONST
+ COUNT_CONST, sizeof(TYPE)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(THING) * (COUNT_ID)
+ COUNT_ID, sizeof(THING)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(THING) * COUNT_ID
+ COUNT_ID, sizeof(THING)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(THING) * (COUNT_CONST)
+ COUNT_CONST, sizeof(THING)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(THING) * COUNT_CONST
+ COUNT_CONST, sizeof(THING)
, ...)
)
// 2-factor product, only identifiers.
@@
identifier SIZE, COUNT;
@@
- kmalloc
+ kmalloc_array
(
- SIZE * COUNT
+ COUNT, SIZE
, ...)
// 3-factor product with 1 sizeof(type) or sizeof(expression), with
// redundant parens removed.
@@
expression THING;
identifier STRIDE, COUNT;
type TYPE;
@@
(
kmalloc(
- sizeof(TYPE) * (COUNT) * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kmalloc(
- sizeof(TYPE) * (COUNT) * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kmalloc(
- sizeof(TYPE) * COUNT * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kmalloc(
- sizeof(TYPE) * COUNT * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kmalloc(
- sizeof(THING) * (COUNT) * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
kmalloc(
- sizeof(THING) * (COUNT) * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
kmalloc(
- sizeof(THING) * COUNT * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
kmalloc(
- sizeof(THING) * COUNT * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
)
// 3-factor product with 2 sizeof(variable), with redundant parens removed.
@@
expression THING1, THING2;
identifier COUNT;
type TYPE1, TYPE2;
@@
(
kmalloc(
- sizeof(TYPE1) * sizeof(TYPE2) * COUNT
+ array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
, ...)
|
kmalloc(
- sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
, ...)
|
kmalloc(
- sizeof(THING1) * sizeof(THING2) * COUNT
+ array3_size(COUNT, sizeof(THING1), sizeof(THING2))
, ...)
|
kmalloc(
- sizeof(THING1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(THING1), sizeof(THING2))
, ...)
|
kmalloc(
- sizeof(TYPE1) * sizeof(THING2) * COUNT
+ array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
, ...)
|
kmalloc(
- sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
, ...)
)
// 3-factor product, only identifiers, with redundant parens removed.
@@
identifier STRIDE, SIZE, COUNT;
@@
(
kmalloc(
- (COUNT) * STRIDE * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- COUNT * (STRIDE) * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- COUNT * STRIDE * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- (COUNT) * (STRIDE) * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- COUNT * (STRIDE) * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- (COUNT) * STRIDE * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- (COUNT) * (STRIDE) * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- COUNT * STRIDE * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
)
// Any remaining multi-factor products, first at least 3-factor products,
// when they're not all constants...
@@
expression E1, E2, E3;
constant C1, C2, C3;
@@
(
kmalloc(C1 * C2 * C3, ...)
|
kmalloc(
- (E1) * E2 * E3
+ array3_size(E1, E2, E3)
, ...)
|
kmalloc(
- (E1) * (E2) * E3
+ array3_size(E1, E2, E3)
, ...)
|
kmalloc(
- (E1) * (E2) * (E3)
+ array3_size(E1, E2, E3)
, ...)
|
kmalloc(
- E1 * E2 * E3
+ array3_size(E1, E2, E3)
, ...)
)
// And then all remaining 2 factors products when they're not all constants,
// keeping sizeof() as the second factor argument.
@@
expression THING, E1, E2;
type TYPE;
constant C1, C2, C3;
@@
(
kmalloc(sizeof(THING) * C2, ...)
|
kmalloc(sizeof(TYPE) * C2, ...)
|
kmalloc(C1 * C2 * C3, ...)
|
kmalloc(C1 * C2, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(TYPE) * (E2)
+ E2, sizeof(TYPE)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(TYPE) * E2
+ E2, sizeof(TYPE)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(THING) * (E2)
+ E2, sizeof(THING)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(THING) * E2
+ E2, sizeof(THING)
, ...)
|
- kmalloc
+ kmalloc_array
(
- (E1) * E2
+ E1, E2
, ...)
|
- kmalloc
+ kmalloc_array
(
- (E1) * (E2)
+ E1, E2
, ...)
|
- kmalloc
+ kmalloc_array
(
- E1 * E2
+ E1, E2
, ...)
)
Signed-off-by: Kees Cook <keescook@chromium.org>
2018-06-12 20:55:00 +00:00
|
|
|
priv->mpt_rxfidx = kmalloc_array(priv->max_buckets_out, sizeof(int),
|
|
|
|
GFP_KERNEL);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (priv->mpt_rxfidx == NULL)
|
|
|
|
goto out_SendCtl;
|
|
|
|
priv->mpt_rxfidx_tail = -1;
|
|
|
|
|
2006-01-13 17:27:50 +00:00
|
|
|
priv->RcvCtl = kcalloc(priv->max_buckets_out,
|
|
|
|
sizeof(struct BufferControl),
|
2005-04-16 22:20:36 +00:00
|
|
|
GFP_KERNEL);
|
|
|
|
if (priv->RcvCtl == NULL)
|
|
|
|
goto out_mpt_rxfidx;
|
2006-01-13 17:27:50 +00:00
|
|
|
for (i = 0; i < priv->max_buckets_out; i++)
|
2005-04-16 22:20:36 +00:00
|
|
|
priv->mpt_rxfidx[++priv->mpt_rxfidx_tail] = i;
|
|
|
|
|
|
|
|
/**/ dlprintk((KERN_INFO MYNAM "/lo: txfidx contains - "));
|
|
|
|
/**/ for (i = 0; i < priv->tx_max_out; i++)
|
|
|
|
/**/ dlprintk((" %xh", priv->mpt_txfidx[i]));
|
|
|
|
/**/ dlprintk(("\n"));
|
|
|
|
|
|
|
|
dlprintk((KERN_INFO MYNAM "/lo: Finished initializing RcvCtl\n"));
|
|
|
|
|
2006-11-22 14:57:56 +00:00
|
|
|
mpt_lan_post_receive_buckets(priv);
|
2005-04-16 22:20:36 +00:00
|
|
|
printk(KERN_INFO MYNAM ": %s/%s: interface up & active\n",
|
|
|
|
IOC_AND_NETDEV_NAMES_s_s(dev));
|
|
|
|
|
|
|
|
if (mpt_event_register(LanCtx, mpt_lan_event_process) != 0) {
|
|
|
|
printk (KERN_WARNING MYNAM "/lo: Unable to register for Event"
|
|
|
|
" Notifications. This is a bad thing! We're not going "
|
|
|
|
"to go ahead, but I'd be leery of system stability at "
|
|
|
|
"this point.\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
netif_start_queue(dev);
|
|
|
|
dlprintk((KERN_INFO MYNAM "/lo: Done.\n"));
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
out_mpt_rxfidx:
|
|
|
|
kfree(priv->mpt_rxfidx);
|
|
|
|
priv->mpt_rxfidx = NULL;
|
|
|
|
out_SendCtl:
|
|
|
|
kfree(priv->SendCtl);
|
|
|
|
priv->SendCtl = NULL;
|
|
|
|
out_mpt_txfidx:
|
|
|
|
kfree(priv->mpt_txfidx);
|
|
|
|
priv->mpt_txfidx = NULL;
|
|
|
|
out: return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
|
|
|
|
/* Send a LanReset message to the FW. This should result in the FW returning
|
|
|
|
any buckets it still has. */
|
|
|
|
static int
|
|
|
|
mpt_lan_reset(struct net_device *dev)
|
|
|
|
{
|
|
|
|
MPT_FRAME_HDR *mf;
|
|
|
|
LANResetRequest_t *pResetReq;
|
|
|
|
struct mpt_lan_priv *priv = netdev_priv(dev);
|
|
|
|
|
|
|
|
mf = mpt_get_msg_frame(LanCtx, priv->mpt_dev);
|
|
|
|
|
|
|
|
if (mf == NULL) {
|
|
|
|
/* dlprintk((KERN_ERR MYNAM "/reset: Evil funkiness abounds! "
|
|
|
|
"Unable to allocate a request frame.\n"));
|
|
|
|
*/
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
pResetReq = (LANResetRequest_t *) mf;
|
|
|
|
|
|
|
|
pResetReq->Function = MPI_FUNCTION_LAN_RESET;
|
|
|
|
pResetReq->ChainOffset = 0;
|
|
|
|
pResetReq->Reserved = 0;
|
|
|
|
pResetReq->PortNumber = priv->pnum;
|
|
|
|
pResetReq->MsgFlags = 0;
|
|
|
|
pResetReq->Reserved2 = 0;
|
|
|
|
|
|
|
|
mpt_put_msg_frame(LanCtx, priv->mpt_dev, mf);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
|
|
|
|
static int
|
|
|
|
mpt_lan_close(struct net_device *dev)
|
|
|
|
{
|
|
|
|
struct mpt_lan_priv *priv = netdev_priv(dev);
|
|
|
|
MPT_ADAPTER *mpt_dev = priv->mpt_dev;
|
2005-11-07 09:01:19 +00:00
|
|
|
unsigned long timeout;
|
2005-04-16 22:20:36 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
dlprintk((KERN_INFO MYNAM ": mpt_lan_close called\n"));
|
|
|
|
|
|
|
|
mpt_event_deregister(LanCtx);
|
|
|
|
|
|
|
|
dlprintk((KERN_INFO MYNAM ":lan_close: Posted %d buckets "
|
|
|
|
"since driver was loaded, %d still out\n",
|
|
|
|
priv->total_posted,atomic_read(&priv->buckets_out)));
|
|
|
|
|
|
|
|
netif_stop_queue(dev);
|
|
|
|
|
|
|
|
mpt_lan_reset(dev);
|
|
|
|
|
2005-11-07 09:01:19 +00:00
|
|
|
timeout = jiffies + 2 * HZ;
|
|
|
|
while (atomic_read(&priv->buckets_out) && time_before(jiffies, timeout))
|
|
|
|
schedule_timeout_interruptible(1);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
for (i = 0; i < priv->max_buckets_out; i++) {
|
|
|
|
if (priv->RcvCtl[i].skb != NULL) {
|
|
|
|
/**/ dlprintk((KERN_INFO MYNAM "/lan_close: bucket %05x "
|
|
|
|
/**/ "is still out\n", i));
|
2022-01-06 21:54:05 +00:00
|
|
|
dma_unmap_single(&mpt_dev->pcidev->dev,
|
|
|
|
priv->RcvCtl[i].dma,
|
|
|
|
priv->RcvCtl[i].len, DMA_FROM_DEVICE);
|
2005-04-16 22:20:36 +00:00
|
|
|
dev_kfree_skb(priv->RcvCtl[i].skb);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-05-11 23:37:26 +00:00
|
|
|
kfree(priv->RcvCtl);
|
|
|
|
kfree(priv->mpt_rxfidx);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
for (i = 0; i < priv->tx_max_out; i++) {
|
|
|
|
if (priv->SendCtl[i].skb != NULL) {
|
2022-01-06 21:54:05 +00:00
|
|
|
dma_unmap_single(&mpt_dev->pcidev->dev,
|
|
|
|
priv->SendCtl[i].dma,
|
|
|
|
priv->SendCtl[i].len, DMA_TO_DEVICE);
|
2005-04-16 22:20:36 +00:00
|
|
|
dev_kfree_skb(priv->SendCtl[i].skb);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
kfree(priv->SendCtl);
|
|
|
|
kfree(priv->mpt_txfidx);
|
|
|
|
|
|
|
|
atomic_set(&priv->buckets_out, 0);
|
|
|
|
|
|
|
|
printk(KERN_INFO MYNAM ": %s/%s: interface down & inactive\n",
|
|
|
|
IOC_AND_NETDEV_NAMES_s_s(dev));
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
|
|
|
|
/* Tx timeout handler. */
|
|
|
|
static void
|
netdev: pass the stuck queue to the timeout handler
This allows incrementing the correct timeout statistic without any mess.
Down the road, devices can learn to reset just the specific queue.
The patch was generated with the following script:
use strict;
use warnings;
our $^I = '.bak';
my @work = (
["arch/m68k/emu/nfeth.c", "nfeth_tx_timeout"],
["arch/um/drivers/net_kern.c", "uml_net_tx_timeout"],
["arch/um/drivers/vector_kern.c", "vector_net_tx_timeout"],
["arch/xtensa/platforms/iss/network.c", "iss_net_tx_timeout"],
["drivers/char/pcmcia/synclink_cs.c", "hdlcdev_tx_timeout"],
["drivers/infiniband/ulp/ipoib/ipoib_main.c", "ipoib_timeout"],
["drivers/infiniband/ulp/ipoib/ipoib_main.c", "ipoib_timeout"],
["drivers/message/fusion/mptlan.c", "mpt_lan_tx_timeout"],
["drivers/misc/sgi-xp/xpnet.c", "xpnet_dev_tx_timeout"],
["drivers/net/appletalk/cops.c", "cops_timeout"],
["drivers/net/arcnet/arcdevice.h", "arcnet_timeout"],
["drivers/net/arcnet/arcnet.c", "arcnet_timeout"],
["drivers/net/arcnet/com20020.c", "arcnet_timeout"],
["drivers/net/ethernet/3com/3c509.c", "el3_tx_timeout"],
["drivers/net/ethernet/3com/3c515.c", "corkscrew_timeout"],
["drivers/net/ethernet/3com/3c574_cs.c", "el3_tx_timeout"],
["drivers/net/ethernet/3com/3c589_cs.c", "el3_tx_timeout"],
["drivers/net/ethernet/3com/3c59x.c", "vortex_tx_timeout"],
["drivers/net/ethernet/3com/3c59x.c", "vortex_tx_timeout"],
["drivers/net/ethernet/3com/typhoon.c", "typhoon_tx_timeout"],
["drivers/net/ethernet/8390/8390.h", "ei_tx_timeout"],
["drivers/net/ethernet/8390/8390.h", "eip_tx_timeout"],
["drivers/net/ethernet/8390/8390.c", "ei_tx_timeout"],
["drivers/net/ethernet/8390/8390p.c", "eip_tx_timeout"],
["drivers/net/ethernet/8390/ax88796.c", "ax_ei_tx_timeout"],
["drivers/net/ethernet/8390/axnet_cs.c", "axnet_tx_timeout"],
["drivers/net/ethernet/8390/etherh.c", "__ei_tx_timeout"],
["drivers/net/ethernet/8390/hydra.c", "__ei_tx_timeout"],
["drivers/net/ethernet/8390/mac8390.c", "__ei_tx_timeout"],
["drivers/net/ethernet/8390/mcf8390.c", "__ei_tx_timeout"],
["drivers/net/ethernet/8390/lib8390.c", "__ei_tx_timeout"],
["drivers/net/ethernet/8390/ne2k-pci.c", "ei_tx_timeout"],
["drivers/net/ethernet/8390/pcnet_cs.c", "ei_tx_timeout"],
["drivers/net/ethernet/8390/smc-ultra.c", "ei_tx_timeout"],
["drivers/net/ethernet/8390/wd.c", "ei_tx_timeout"],
["drivers/net/ethernet/8390/zorro8390.c", "__ei_tx_timeout"],
["drivers/net/ethernet/adaptec/starfire.c", "tx_timeout"],
["drivers/net/ethernet/agere/et131x.c", "et131x_tx_timeout"],
["drivers/net/ethernet/allwinner/sun4i-emac.c", "emac_timeout"],
["drivers/net/ethernet/alteon/acenic.c", "ace_watchdog"],
["drivers/net/ethernet/amazon/ena/ena_netdev.c", "ena_tx_timeout"],
["drivers/net/ethernet/amd/7990.h", "lance_tx_timeout"],
["drivers/net/ethernet/amd/7990.c", "lance_tx_timeout"],
["drivers/net/ethernet/amd/a2065.c", "lance_tx_timeout"],
["drivers/net/ethernet/amd/am79c961a.c", "am79c961_timeout"],
["drivers/net/ethernet/amd/amd8111e.c", "amd8111e_tx_timeout"],
["drivers/net/ethernet/amd/ariadne.c", "ariadne_tx_timeout"],
["drivers/net/ethernet/amd/atarilance.c", "lance_tx_timeout"],
["drivers/net/ethernet/amd/au1000_eth.c", "au1000_tx_timeout"],
["drivers/net/ethernet/amd/declance.c", "lance_tx_timeout"],
["drivers/net/ethernet/amd/lance.c", "lance_tx_timeout"],
["drivers/net/ethernet/amd/mvme147.c", "lance_tx_timeout"],
["drivers/net/ethernet/amd/ni65.c", "ni65_timeout"],
["drivers/net/ethernet/amd/nmclan_cs.c", "mace_tx_timeout"],
["drivers/net/ethernet/amd/pcnet32.c", "pcnet32_tx_timeout"],
["drivers/net/ethernet/amd/sunlance.c", "lance_tx_timeout"],
["drivers/net/ethernet/amd/xgbe/xgbe-drv.c", "xgbe_tx_timeout"],
["drivers/net/ethernet/apm/xgene-v2/main.c", "xge_timeout"],
["drivers/net/ethernet/apm/xgene/xgene_enet_main.c", "xgene_enet_timeout"],
["drivers/net/ethernet/apple/macmace.c", "mace_tx_timeout"],
["drivers/net/ethernet/atheros/ag71xx.c", "ag71xx_tx_timeout"],
["drivers/net/ethernet/atheros/alx/main.c", "alx_tx_timeout"],
["drivers/net/ethernet/atheros/atl1c/atl1c_main.c", "atl1c_tx_timeout"],
["drivers/net/ethernet/atheros/atl1e/atl1e_main.c", "atl1e_tx_timeout"],
["drivers/net/ethernet/atheros/atlx/atl.c", "atlx_tx_timeout"],
["drivers/net/ethernet/atheros/atlx/atl1.c", "atlx_tx_timeout"],
["drivers/net/ethernet/atheros/atlx/atl2.c", "atl2_tx_timeout"],
["drivers/net/ethernet/broadcom/b44.c", "b44_tx_timeout"],
["drivers/net/ethernet/broadcom/bcmsysport.c", "bcm_sysport_tx_timeout"],
["drivers/net/ethernet/broadcom/bnx2.c", "bnx2_tx_timeout"],
["drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h", "bnx2x_tx_timeout"],
["drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c", "bnx2x_tx_timeout"],
["drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c", "bnx2x_tx_timeout"],
["drivers/net/ethernet/broadcom/bnxt/bnxt.c", "bnxt_tx_timeout"],
["drivers/net/ethernet/broadcom/genet/bcmgenet.c", "bcmgenet_timeout"],
["drivers/net/ethernet/broadcom/sb1250-mac.c", "sbmac_tx_timeout"],
["drivers/net/ethernet/broadcom/tg3.c", "tg3_tx_timeout"],
["drivers/net/ethernet/calxeda/xgmac.c", "xgmac_tx_timeout"],
["drivers/net/ethernet/cavium/liquidio/lio_main.c", "liquidio_tx_timeout"],
["drivers/net/ethernet/cavium/liquidio/lio_vf_main.c", "liquidio_tx_timeout"],
["drivers/net/ethernet/cavium/liquidio/lio_vf_rep.c", "lio_vf_rep_tx_timeout"],
["drivers/net/ethernet/cavium/thunder/nicvf_main.c", "nicvf_tx_timeout"],
["drivers/net/ethernet/cirrus/cs89x0.c", "net_timeout"],
["drivers/net/ethernet/cisco/enic/enic_main.c", "enic_tx_timeout"],
["drivers/net/ethernet/cisco/enic/enic_main.c", "enic_tx_timeout"],
["drivers/net/ethernet/cortina/gemini.c", "gmac_tx_timeout"],
["drivers/net/ethernet/davicom/dm9000.c", "dm9000_timeout"],
["drivers/net/ethernet/dec/tulip/de2104x.c", "de_tx_timeout"],
["drivers/net/ethernet/dec/tulip/tulip_core.c", "tulip_tx_timeout"],
["drivers/net/ethernet/dec/tulip/winbond-840.c", "tx_timeout"],
["drivers/net/ethernet/dlink/dl2k.c", "rio_tx_timeout"],
["drivers/net/ethernet/dlink/sundance.c", "tx_timeout"],
["drivers/net/ethernet/emulex/benet/be_main.c", "be_tx_timeout"],
["drivers/net/ethernet/ethoc.c", "ethoc_tx_timeout"],
["drivers/net/ethernet/faraday/ftgmac100.c", "ftgmac100_tx_timeout"],
["drivers/net/ethernet/fealnx.c", "fealnx_tx_timeout"],
["drivers/net/ethernet/freescale/dpaa/dpaa_eth.c", "dpaa_tx_timeout"],
["drivers/net/ethernet/freescale/fec_main.c", "fec_timeout"],
["drivers/net/ethernet/freescale/fec_mpc52xx.c", "mpc52xx_fec_tx_timeout"],
["drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c", "fs_timeout"],
["drivers/net/ethernet/freescale/gianfar.c", "gfar_timeout"],
["drivers/net/ethernet/freescale/ucc_geth.c", "ucc_geth_timeout"],
["drivers/net/ethernet/fujitsu/fmvj18x_cs.c", "fjn_tx_timeout"],
["drivers/net/ethernet/google/gve/gve_main.c", "gve_tx_timeout"],
["drivers/net/ethernet/hisilicon/hip04_eth.c", "hip04_timeout"],
["drivers/net/ethernet/hisilicon/hix5hd2_gmac.c", "hix5hd2_net_timeout"],
["drivers/net/ethernet/hisilicon/hns/hns_enet.c", "hns_nic_net_timeout"],
["drivers/net/ethernet/hisilicon/hns3/hns3_enet.c", "hns3_nic_net_timeout"],
["drivers/net/ethernet/huawei/hinic/hinic_main.c", "hinic_tx_timeout"],
["drivers/net/ethernet/i825xx/82596.c", "i596_tx_timeout"],
["drivers/net/ethernet/i825xx/ether1.c", "ether1_timeout"],
["drivers/net/ethernet/i825xx/lib82596.c", "i596_tx_timeout"],
["drivers/net/ethernet/i825xx/sun3_82586.c", "sun3_82586_timeout"],
["drivers/net/ethernet/ibm/ehea/ehea_main.c", "ehea_tx_watchdog"],
["drivers/net/ethernet/ibm/emac/core.c", "emac_tx_timeout"],
["drivers/net/ethernet/ibm/emac/core.c", "emac_tx_timeout"],
["drivers/net/ethernet/ibm/ibmvnic.c", "ibmvnic_tx_timeout"],
["drivers/net/ethernet/intel/e100.c", "e100_tx_timeout"],
["drivers/net/ethernet/intel/e1000/e1000_main.c", "e1000_tx_timeout"],
["drivers/net/ethernet/intel/e1000e/netdev.c", "e1000_tx_timeout"],
["drivers/net/ethernet/intel/fm10k/fm10k_netdev.c", "fm10k_tx_timeout"],
["drivers/net/ethernet/intel/i40e/i40e_main.c", "i40e_tx_timeout"],
["drivers/net/ethernet/intel/iavf/iavf_main.c", "iavf_tx_timeout"],
["drivers/net/ethernet/intel/ice/ice_main.c", "ice_tx_timeout"],
["drivers/net/ethernet/intel/ice/ice_main.c", "ice_tx_timeout"],
["drivers/net/ethernet/intel/igb/igb_main.c", "igb_tx_timeout"],
["drivers/net/ethernet/intel/igbvf/netdev.c", "igbvf_tx_timeout"],
["drivers/net/ethernet/intel/ixgb/ixgb_main.c", "ixgb_tx_timeout"],
["drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c", "adapter->netdev->netdev_ops->ndo_tx_timeout(adapter->netdev);"],
["drivers/net/ethernet/intel/ixgbe/ixgbe_main.c", "ixgbe_tx_timeout"],
["drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c", "ixgbevf_tx_timeout"],
["drivers/net/ethernet/jme.c", "jme_tx_timeout"],
["drivers/net/ethernet/korina.c", "korina_tx_timeout"],
["drivers/net/ethernet/lantiq_etop.c", "ltq_etop_tx_timeout"],
["drivers/net/ethernet/marvell/mv643xx_eth.c", "mv643xx_eth_tx_timeout"],
["drivers/net/ethernet/marvell/pxa168_eth.c", "pxa168_eth_tx_timeout"],
["drivers/net/ethernet/marvell/skge.c", "skge_tx_timeout"],
["drivers/net/ethernet/marvell/sky2.c", "sky2_tx_timeout"],
["drivers/net/ethernet/marvell/sky2.c", "sky2_tx_timeout"],
["drivers/net/ethernet/mediatek/mtk_eth_soc.c", "mtk_tx_timeout"],
["drivers/net/ethernet/mellanox/mlx4/en_netdev.c", "mlx4_en_tx_timeout"],
["drivers/net/ethernet/mellanox/mlx4/en_netdev.c", "mlx4_en_tx_timeout"],
["drivers/net/ethernet/mellanox/mlx5/core/en_main.c", "mlx5e_tx_timeout"],
["drivers/net/ethernet/micrel/ks8842.c", "ks8842_tx_timeout"],
["drivers/net/ethernet/micrel/ksz884x.c", "netdev_tx_timeout"],
["drivers/net/ethernet/microchip/enc28j60.c", "enc28j60_tx_timeout"],
["drivers/net/ethernet/microchip/encx24j600.c", "encx24j600_tx_timeout"],
["drivers/net/ethernet/natsemi/sonic.h", "sonic_tx_timeout"],
["drivers/net/ethernet/natsemi/sonic.c", "sonic_tx_timeout"],
["drivers/net/ethernet/natsemi/jazzsonic.c", "sonic_tx_timeout"],
["drivers/net/ethernet/natsemi/macsonic.c", "sonic_tx_timeout"],
["drivers/net/ethernet/natsemi/natsemi.c", "ns_tx_timeout"],
["drivers/net/ethernet/natsemi/ns83820.c", "ns83820_tx_timeout"],
["drivers/net/ethernet/natsemi/xtsonic.c", "sonic_tx_timeout"],
["drivers/net/ethernet/neterion/s2io.h", "s2io_tx_watchdog"],
["drivers/net/ethernet/neterion/s2io.c", "s2io_tx_watchdog"],
["drivers/net/ethernet/neterion/vxge/vxge-main.c", "vxge_tx_watchdog"],
["drivers/net/ethernet/netronome/nfp/nfp_net_common.c", "nfp_net_tx_timeout"],
["drivers/net/ethernet/nvidia/forcedeth.c", "nv_tx_timeout"],
["drivers/net/ethernet/nvidia/forcedeth.c", "nv_tx_timeout"],
["drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c", "pch_gbe_tx_timeout"],
["drivers/net/ethernet/packetengines/hamachi.c", "hamachi_tx_timeout"],
["drivers/net/ethernet/packetengines/yellowfin.c", "yellowfin_tx_timeout"],
["drivers/net/ethernet/pensando/ionic/ionic_lif.c", "ionic_tx_timeout"],
["drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c", "netxen_tx_timeout"],
["drivers/net/ethernet/qlogic/qla3xxx.c", "ql3xxx_tx_timeout"],
["drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c", "qlcnic_tx_timeout"],
["drivers/net/ethernet/qualcomm/emac/emac.c", "emac_tx_timeout"],
["drivers/net/ethernet/qualcomm/qca_spi.c", "qcaspi_netdev_tx_timeout"],
["drivers/net/ethernet/qualcomm/qca_uart.c", "qcauart_netdev_tx_timeout"],
["drivers/net/ethernet/rdc/r6040.c", "r6040_tx_timeout"],
["drivers/net/ethernet/realtek/8139cp.c", "cp_tx_timeout"],
["drivers/net/ethernet/realtek/8139too.c", "rtl8139_tx_timeout"],
["drivers/net/ethernet/realtek/atp.c", "tx_timeout"],
["drivers/net/ethernet/realtek/r8169_main.c", "rtl8169_tx_timeout"],
["drivers/net/ethernet/renesas/ravb_main.c", "ravb_tx_timeout"],
["drivers/net/ethernet/renesas/sh_eth.c", "sh_eth_tx_timeout"],
["drivers/net/ethernet/renesas/sh_eth.c", "sh_eth_tx_timeout"],
["drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c", "sxgbe_tx_timeout"],
["drivers/net/ethernet/seeq/ether3.c", "ether3_timeout"],
["drivers/net/ethernet/seeq/sgiseeq.c", "timeout"],
["drivers/net/ethernet/sfc/efx.c", "efx_watchdog"],
["drivers/net/ethernet/sfc/falcon/efx.c", "ef4_watchdog"],
["drivers/net/ethernet/sgi/ioc3-eth.c", "ioc3_timeout"],
["drivers/net/ethernet/sgi/meth.c", "meth_tx_timeout"],
["drivers/net/ethernet/silan/sc92031.c", "sc92031_tx_timeout"],
["drivers/net/ethernet/sis/sis190.c", "sis190_tx_timeout"],
["drivers/net/ethernet/sis/sis900.c", "sis900_tx_timeout"],
["drivers/net/ethernet/smsc/epic100.c", "epic_tx_timeout"],
["drivers/net/ethernet/smsc/smc911x.c", "smc911x_timeout"],
["drivers/net/ethernet/smsc/smc9194.c", "smc_timeout"],
["drivers/net/ethernet/smsc/smc91c92_cs.c", "smc_tx_timeout"],
["drivers/net/ethernet/smsc/smc91x.c", "smc_timeout"],
["drivers/net/ethernet/stmicro/stmmac/stmmac_main.c", "stmmac_tx_timeout"],
["drivers/net/ethernet/sun/cassini.c", "cas_tx_timeout"],
["drivers/net/ethernet/sun/ldmvsw.c", "sunvnet_tx_timeout_common"],
["drivers/net/ethernet/sun/niu.c", "niu_tx_timeout"],
["drivers/net/ethernet/sun/sunbmac.c", "bigmac_tx_timeout"],
["drivers/net/ethernet/sun/sungem.c", "gem_tx_timeout"],
["drivers/net/ethernet/sun/sunhme.c", "happy_meal_tx_timeout"],
["drivers/net/ethernet/sun/sunqe.c", "qe_tx_timeout"],
["drivers/net/ethernet/sun/sunvnet.c", "sunvnet_tx_timeout_common"],
["drivers/net/ethernet/sun/sunvnet_common.c", "sunvnet_tx_timeout_common"],
["drivers/net/ethernet/sun/sunvnet_common.h", "sunvnet_tx_timeout_common"],
["drivers/net/ethernet/synopsys/dwc-xlgmac-net.c", "xlgmac_tx_timeout"],
["drivers/net/ethernet/ti/cpmac.c", "cpmac_tx_timeout"],
["drivers/net/ethernet/ti/cpsw.c", "cpsw_ndo_tx_timeout"],
["drivers/net/ethernet/ti/cpsw_priv.c", "cpsw_ndo_tx_timeout"],
["drivers/net/ethernet/ti/cpsw_priv.h", "cpsw_ndo_tx_timeout"],
["drivers/net/ethernet/ti/davinci_emac.c", "emac_dev_tx_timeout"],
["drivers/net/ethernet/ti/netcp_core.c", "netcp_ndo_tx_timeout"],
["drivers/net/ethernet/ti/tlan.c", "tlan_tx_timeout"],
["drivers/net/ethernet/toshiba/ps3_gelic_net.h", "gelic_net_tx_timeout"],
["drivers/net/ethernet/toshiba/ps3_gelic_net.c", "gelic_net_tx_timeout"],
["drivers/net/ethernet/toshiba/ps3_gelic_wireless.c", "gelic_net_tx_timeout"],
["drivers/net/ethernet/toshiba/spider_net.c", "spider_net_tx_timeout"],
["drivers/net/ethernet/toshiba/tc35815.c", "tc35815_tx_timeout"],
["drivers/net/ethernet/via/via-rhine.c", "rhine_tx_timeout"],
["drivers/net/ethernet/wiznet/w5100.c", "w5100_tx_timeout"],
["drivers/net/ethernet/wiznet/w5300.c", "w5300_tx_timeout"],
["drivers/net/ethernet/xilinx/xilinx_emaclite.c", "xemaclite_tx_timeout"],
["drivers/net/ethernet/xircom/xirc2ps_cs.c", "xirc_tx_timeout"],
["drivers/net/fjes/fjes_main.c", "fjes_tx_retry"],
["drivers/net/slip/slip.c", "sl_tx_timeout"],
["include/linux/usb/usbnet.h", "usbnet_tx_timeout"],
["drivers/net/usb/aqc111.c", "usbnet_tx_timeout"],
["drivers/net/usb/asix_devices.c", "usbnet_tx_timeout"],
["drivers/net/usb/asix_devices.c", "usbnet_tx_timeout"],
["drivers/net/usb/asix_devices.c", "usbnet_tx_timeout"],
["drivers/net/usb/ax88172a.c", "usbnet_tx_timeout"],
["drivers/net/usb/ax88179_178a.c", "usbnet_tx_timeout"],
["drivers/net/usb/catc.c", "catc_tx_timeout"],
["drivers/net/usb/cdc_mbim.c", "usbnet_tx_timeout"],
["drivers/net/usb/cdc_ncm.c", "usbnet_tx_timeout"],
["drivers/net/usb/dm9601.c", "usbnet_tx_timeout"],
["drivers/net/usb/hso.c", "hso_net_tx_timeout"],
["drivers/net/usb/int51x1.c", "usbnet_tx_timeout"],
["drivers/net/usb/ipheth.c", "ipheth_tx_timeout"],
["drivers/net/usb/kaweth.c", "kaweth_tx_timeout"],
["drivers/net/usb/lan78xx.c", "lan78xx_tx_timeout"],
["drivers/net/usb/mcs7830.c", "usbnet_tx_timeout"],
["drivers/net/usb/pegasus.c", "pegasus_tx_timeout"],
["drivers/net/usb/qmi_wwan.c", "usbnet_tx_timeout"],
["drivers/net/usb/r8152.c", "rtl8152_tx_timeout"],
["drivers/net/usb/rndis_host.c", "usbnet_tx_timeout"],
["drivers/net/usb/rtl8150.c", "rtl8150_tx_timeout"],
["drivers/net/usb/sierra_net.c", "usbnet_tx_timeout"],
["drivers/net/usb/smsc75xx.c", "usbnet_tx_timeout"],
["drivers/net/usb/smsc95xx.c", "usbnet_tx_timeout"],
["drivers/net/usb/sr9700.c", "usbnet_tx_timeout"],
["drivers/net/usb/sr9800.c", "usbnet_tx_timeout"],
["drivers/net/usb/usbnet.c", "usbnet_tx_timeout"],
["drivers/net/vmxnet3/vmxnet3_drv.c", "vmxnet3_tx_timeout"],
["drivers/net/wan/cosa.c", "cosa_net_timeout"],
["drivers/net/wan/farsync.c", "fst_tx_timeout"],
["drivers/net/wan/fsl_ucc_hdlc.c", "uhdlc_tx_timeout"],
["drivers/net/wan/lmc/lmc_main.c", "lmc_driver_timeout"],
["drivers/net/wan/x25_asy.c", "x25_asy_timeout"],
["drivers/net/wimax/i2400m/netdev.c", "i2400m_tx_timeout"],
["drivers/net/wireless/intel/ipw2x00/ipw2100.c", "ipw2100_tx_timeout"],
["drivers/net/wireless/intersil/hostap/hostap_main.c", "prism2_tx_timeout"],
["drivers/net/wireless/intersil/hostap/hostap_main.c", "prism2_tx_timeout"],
["drivers/net/wireless/intersil/hostap/hostap_main.c", "prism2_tx_timeout"],
["drivers/net/wireless/intersil/orinoco/main.c", "orinoco_tx_timeout"],
["drivers/net/wireless/intersil/orinoco/orinoco_usb.c", "orinoco_tx_timeout"],
["drivers/net/wireless/intersil/orinoco/orinoco.h", "orinoco_tx_timeout"],
["drivers/net/wireless/intersil/prism54/islpci_dev.c", "islpci_eth_tx_timeout"],
["drivers/net/wireless/intersil/prism54/islpci_eth.c", "islpci_eth_tx_timeout"],
["drivers/net/wireless/intersil/prism54/islpci_eth.h", "islpci_eth_tx_timeout"],
["drivers/net/wireless/marvell/mwifiex/main.c", "mwifiex_tx_timeout"],
["drivers/net/wireless/quantenna/qtnfmac/core.c", "qtnf_netdev_tx_timeout"],
["drivers/net/wireless/quantenna/qtnfmac/core.h", "qtnf_netdev_tx_timeout"],
["drivers/net/wireless/rndis_wlan.c", "usbnet_tx_timeout"],
["drivers/net/wireless/wl3501_cs.c", "wl3501_tx_timeout"],
["drivers/net/wireless/zydas/zd1201.c", "zd1201_tx_timeout"],
["drivers/s390/net/qeth_core.h", "qeth_tx_timeout"],
["drivers/s390/net/qeth_core_main.c", "qeth_tx_timeout"],
["drivers/s390/net/qeth_l2_main.c", "qeth_tx_timeout"],
["drivers/s390/net/qeth_l2_main.c", "qeth_tx_timeout"],
["drivers/s390/net/qeth_l3_main.c", "qeth_tx_timeout"],
["drivers/s390/net/qeth_l3_main.c", "qeth_tx_timeout"],
["drivers/staging/ks7010/ks_wlan_net.c", "ks_wlan_tx_timeout"],
["drivers/staging/qlge/qlge_main.c", "qlge_tx_timeout"],
["drivers/staging/rtl8192e/rtl8192e/rtl_core.c", "_rtl92e_tx_timeout"],
["drivers/staging/rtl8192u/r8192U_core.c", "tx_timeout"],
["drivers/staging/unisys/visornic/visornic_main.c", "visornic_xmit_timeout"],
["drivers/staging/wlan-ng/p80211netdev.c", "p80211knetdev_tx_timeout"],
["drivers/tty/n_gsm.c", "gsm_mux_net_tx_timeout"],
["drivers/tty/synclink.c", "hdlcdev_tx_timeout"],
["drivers/tty/synclink_gt.c", "hdlcdev_tx_timeout"],
["drivers/tty/synclinkmp.c", "hdlcdev_tx_timeout"],
["net/atm/lec.c", "lec_tx_timeout"],
["net/bluetooth/bnep/netdev.c", "bnep_net_timeout"]
);
for my $p (@work) {
my @pair = @$p;
my $file = $pair[0];
my $func = $pair[1];
print STDERR $file , ": ", $func,"\n";
our @ARGV = ($file);
while (<ARGV>) {
if (m/($func\s*\(struct\s+net_device\s+\*[A-Za-z_]?[A-Za-z-0-9_]*)(\))/) {
print STDERR "found $1+$2 in $file\n";
}
if (s/($func\s*\(struct\s+net_device\s+\*[A-Za-z_]?[A-Za-z-0-9_]*)(\))/$1, unsigned int txqueue$2/) {
print STDERR "$func found in $file\n";
}
print;
}
}
where the list of files and functions is simply from:
git grep ndo_tx_timeout, with manual addition of headers
in the rare cases where the function is from a header,
then manually changing the few places which actually
call ndo_tx_timeout.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Heiner Kallweit <hkallweit1@gmail.com>
Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Acked-by: Shannon Nelson <snelson@pensando.io>
Reviewed-by: Martin Habets <mhabets@solarflare.com>
changes from v9:
fixup a forward declaration
changes from v9:
more leftovers from v3 change
changes from v8:
fix up a missing direct call to timeout
rebased on net-next
changes from v7:
fixup leftovers from v3 change
changes from v6:
fix typo in rtl driver
changes from v5:
add missing files (allow any net device argument name)
changes from v4:
add a missing driver header
changes from v3:
change queue # to unsigned
Changes from v2:
added headers
Changes from v1:
Fix errors found by kbuild:
generalize the pattern a bit, to pick up
a couple of instances missed by the previous
version.
Signed-off-by: David S. Miller <davem@davemloft.net>
2019-12-10 14:23:51 +00:00
|
|
|
mpt_lan_tx_timeout(struct net_device *dev, unsigned int txqueue)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct mpt_lan_priv *priv = netdev_priv(dev);
|
|
|
|
MPT_ADAPTER *mpt_dev = priv->mpt_dev;
|
|
|
|
|
|
|
|
if (mpt_dev->active) {
|
|
|
|
dlprintk (("mptlan/tx_timeout: calling netif_wake_queue for %s.\n", dev->name));
|
|
|
|
netif_wake_queue(dev);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
|
|
|
|
//static inline int
|
|
|
|
static int
|
|
|
|
mpt_lan_send_turbo(struct net_device *dev, u32 tmsg)
|
|
|
|
{
|
|
|
|
struct mpt_lan_priv *priv = netdev_priv(dev);
|
|
|
|
MPT_ADAPTER *mpt_dev = priv->mpt_dev;
|
|
|
|
struct sk_buff *sent;
|
|
|
|
unsigned long flags;
|
|
|
|
u32 ctx;
|
|
|
|
|
|
|
|
ctx = GET_LAN_BUFFER_CONTEXT(tmsg);
|
|
|
|
sent = priv->SendCtl[ctx].skb;
|
|
|
|
|
2009-01-08 02:04:45 +00:00
|
|
|
dev->stats.tx_packets++;
|
|
|
|
dev->stats.tx_bytes += sent->len;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
dioprintk((KERN_INFO MYNAM ": %s/%s: @%s, skb %p sent.\n",
|
|
|
|
IOC_AND_NETDEV_NAMES_s_s(dev),
|
2008-07-04 06:47:27 +00:00
|
|
|
__func__, sent));
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
priv->SendCtl[ctx].skb = NULL;
|
2022-01-06 21:54:05 +00:00
|
|
|
dma_unmap_single(&mpt_dev->pcidev->dev, priv->SendCtl[ctx].dma,
|
|
|
|
priv->SendCtl[ctx].len, DMA_TO_DEVICE);
|
2005-04-16 22:20:36 +00:00
|
|
|
dev_kfree_skb_irq(sent);
|
|
|
|
|
|
|
|
spin_lock_irqsave(&priv->txfidx_lock, flags);
|
|
|
|
priv->mpt_txfidx[++priv->mpt_txfidx_tail] = ctx;
|
|
|
|
spin_unlock_irqrestore(&priv->txfidx_lock, flags);
|
|
|
|
|
|
|
|
netif_wake_queue(dev);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
|
|
|
|
static int
|
|
|
|
mpt_lan_send_reply(struct net_device *dev, LANSendReply_t *pSendRep)
|
|
|
|
{
|
|
|
|
struct mpt_lan_priv *priv = netdev_priv(dev);
|
|
|
|
MPT_ADAPTER *mpt_dev = priv->mpt_dev;
|
|
|
|
struct sk_buff *sent;
|
|
|
|
unsigned long flags;
|
|
|
|
int FreeReqFrame = 0;
|
|
|
|
u32 *pContext;
|
|
|
|
u32 ctx;
|
|
|
|
u8 count;
|
|
|
|
|
|
|
|
count = pSendRep->NumberOfContexts;
|
|
|
|
|
|
|
|
dioprintk((KERN_INFO MYNAM ": send_reply: IOCStatus: %04x\n",
|
|
|
|
le16_to_cpu(pSendRep->IOCStatus)));
|
|
|
|
|
|
|
|
/* Add check for Loginfo Flag in IOCStatus */
|
|
|
|
|
|
|
|
switch (le16_to_cpu(pSendRep->IOCStatus) & MPI_IOCSTATUS_MASK) {
|
|
|
|
case MPI_IOCSTATUS_SUCCESS:
|
2009-01-08 02:04:45 +00:00
|
|
|
dev->stats.tx_packets += count;
|
2005-04-16 22:20:36 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MPI_IOCSTATUS_LAN_CANCELED:
|
|
|
|
case MPI_IOCSTATUS_LAN_TRANSMIT_ABORTED:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MPI_IOCSTATUS_INVALID_SGL:
|
2009-01-08 02:04:45 +00:00
|
|
|
dev->stats.tx_errors += count;
|
2005-04-16 22:20:36 +00:00
|
|
|
printk (KERN_ERR MYNAM ": %s/%s: ERROR - Invalid SGL sent to IOC!\n",
|
|
|
|
IOC_AND_NETDEV_NAMES_s_s(dev));
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
default:
|
2009-01-08 02:04:45 +00:00
|
|
|
dev->stats.tx_errors += count;
|
2005-04-16 22:20:36 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
pContext = &pSendRep->BufferContext;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&priv->txfidx_lock, flags);
|
|
|
|
while (count > 0) {
|
|
|
|
ctx = GET_LAN_BUFFER_CONTEXT(le32_to_cpu(*pContext));
|
|
|
|
|
|
|
|
sent = priv->SendCtl[ctx].skb;
|
2009-01-08 02:04:45 +00:00
|
|
|
dev->stats.tx_bytes += sent->len;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
dioprintk((KERN_INFO MYNAM ": %s/%s: @%s, skb %p sent.\n",
|
|
|
|
IOC_AND_NETDEV_NAMES_s_s(dev),
|
2008-07-04 06:47:27 +00:00
|
|
|
__func__, sent));
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
priv->SendCtl[ctx].skb = NULL;
|
2022-01-06 21:54:05 +00:00
|
|
|
dma_unmap_single(&mpt_dev->pcidev->dev,
|
|
|
|
priv->SendCtl[ctx].dma,
|
|
|
|
priv->SendCtl[ctx].len, DMA_TO_DEVICE);
|
2005-04-16 22:20:36 +00:00
|
|
|
dev_kfree_skb_irq(sent);
|
|
|
|
|
|
|
|
priv->mpt_txfidx[++priv->mpt_txfidx_tail] = ctx;
|
|
|
|
|
|
|
|
pContext++;
|
|
|
|
count--;
|
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(&priv->txfidx_lock, flags);
|
|
|
|
|
|
|
|
out:
|
|
|
|
if (!(pSendRep->MsgFlags & MPI_MSGFLAGS_CONTINUATION_REPLY))
|
|
|
|
FreeReqFrame = 1;
|
|
|
|
|
|
|
|
netif_wake_queue(dev);
|
|
|
|
return FreeReqFrame;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
|
2018-04-24 13:15:58 +00:00
|
|
|
static netdev_tx_t
|
2005-04-16 22:20:36 +00:00
|
|
|
mpt_lan_sdu_send (struct sk_buff *skb, struct net_device *dev)
|
|
|
|
{
|
|
|
|
struct mpt_lan_priv *priv = netdev_priv(dev);
|
|
|
|
MPT_ADAPTER *mpt_dev = priv->mpt_dev;
|
|
|
|
MPT_FRAME_HDR *mf;
|
|
|
|
LANSendRequest_t *pSendReq;
|
|
|
|
SGETransaction32_t *pTrans;
|
|
|
|
SGESimple64_t *pSimple;
|
2007-03-19 22:33:04 +00:00
|
|
|
const unsigned char *mac;
|
2005-04-16 22:20:36 +00:00
|
|
|
dma_addr_t dma;
|
|
|
|
unsigned long flags;
|
|
|
|
int ctx;
|
|
|
|
u16 cur_naa = 0x1000;
|
|
|
|
|
|
|
|
dioprintk((KERN_INFO MYNAM ": %s called, skb_addr = %p\n",
|
2008-07-04 06:47:27 +00:00
|
|
|
__func__, skb));
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
spin_lock_irqsave(&priv->txfidx_lock, flags);
|
|
|
|
if (priv->mpt_txfidx_tail < 0) {
|
|
|
|
netif_stop_queue(dev);
|
|
|
|
spin_unlock_irqrestore(&priv->txfidx_lock, flags);
|
|
|
|
|
|
|
|
printk (KERN_ERR "%s: no tx context available: %u\n",
|
2008-07-04 06:47:27 +00:00
|
|
|
__func__, priv->mpt_txfidx_tail);
|
2009-06-12 06:22:29 +00:00
|
|
|
return NETDEV_TX_BUSY;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
mf = mpt_get_msg_frame(LanCtx, mpt_dev);
|
|
|
|
if (mf == NULL) {
|
|
|
|
netif_stop_queue(dev);
|
|
|
|
spin_unlock_irqrestore(&priv->txfidx_lock, flags);
|
|
|
|
|
|
|
|
printk (KERN_ERR "%s: Unable to alloc request frame\n",
|
2008-07-04 06:47:27 +00:00
|
|
|
__func__);
|
2009-06-12 06:22:29 +00:00
|
|
|
return NETDEV_TX_BUSY;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ctx = priv->mpt_txfidx[priv->mpt_txfidx_tail--];
|
|
|
|
spin_unlock_irqrestore(&priv->txfidx_lock, flags);
|
|
|
|
|
|
|
|
// dioprintk((KERN_INFO MYNAM ": %s/%s: Creating new msg frame (send).\n",
|
|
|
|
// IOC_AND_NETDEV_NAMES_s_s(dev)));
|
|
|
|
|
|
|
|
pSendReq = (LANSendRequest_t *) mf;
|
|
|
|
|
|
|
|
/* Set the mac.raw pointer, since this apparently isn't getting
|
|
|
|
* done before we get the skb. Pull the data pointer past the mac data.
|
|
|
|
*/
|
2007-03-19 22:30:44 +00:00
|
|
|
skb_reset_mac_header(skb);
|
2005-04-16 22:20:36 +00:00
|
|
|
skb_pull(skb, 12);
|
|
|
|
|
2022-01-06 21:54:05 +00:00
|
|
|
dma = dma_map_single(&mpt_dev->pcidev->dev, skb->data, skb->len,
|
|
|
|
DMA_TO_DEVICE);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
priv->SendCtl[ctx].skb = skb;
|
|
|
|
priv->SendCtl[ctx].dma = dma;
|
|
|
|
priv->SendCtl[ctx].len = skb->len;
|
|
|
|
|
|
|
|
/* Message Header */
|
|
|
|
pSendReq->Reserved = 0;
|
|
|
|
pSendReq->Function = MPI_FUNCTION_LAN_SEND;
|
|
|
|
pSendReq->ChainOffset = 0;
|
|
|
|
pSendReq->Reserved2 = 0;
|
|
|
|
pSendReq->MsgFlags = 0;
|
|
|
|
pSendReq->PortNumber = priv->pnum;
|
|
|
|
|
|
|
|
/* Transaction Context Element */
|
|
|
|
pTrans = (SGETransaction32_t *) pSendReq->SG_List;
|
|
|
|
|
|
|
|
/* No Flags, 8 bytes of Details, 32bit Context (bloody turbo replies) */
|
|
|
|
pTrans->ContextSize = sizeof(u32);
|
|
|
|
pTrans->DetailsLength = 2 * sizeof(u32);
|
|
|
|
pTrans->Flags = 0;
|
2021-03-24 23:33:44 +00:00
|
|
|
pTrans->TransactionContext = cpu_to_le32(ctx);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
// dioprintk((KERN_INFO MYNAM ": %s/%s: BC = %08x, skb = %p, buff = %p\n",
|
|
|
|
// IOC_AND_NETDEV_NAMES_s_s(dev),
|
|
|
|
// ctx, skb, skb->data));
|
|
|
|
|
2007-03-19 22:33:04 +00:00
|
|
|
mac = skb_mac_header(skb);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
pTrans->TransactionDetails[0] = cpu_to_le32((cur_naa << 16) |
|
2007-03-19 22:33:04 +00:00
|
|
|
(mac[0] << 8) |
|
|
|
|
(mac[1] << 0));
|
|
|
|
pTrans->TransactionDetails[1] = cpu_to_le32((mac[2] << 24) |
|
|
|
|
(mac[3] << 16) |
|
|
|
|
(mac[4] << 8) |
|
|
|
|
(mac[5] << 0));
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
pSimple = (SGESimple64_t *) &pTrans->TransactionDetails[2];
|
|
|
|
|
|
|
|
/* If we ever decide to send more than one Simple SGE per LANSend, then
|
|
|
|
we will need to make sure that LAST_ELEMENT only gets set on the
|
|
|
|
last one. Otherwise, bad voodoo and evil funkiness will commence. */
|
|
|
|
pSimple->FlagsLength = cpu_to_le32(
|
|
|
|
((MPI_SGE_FLAGS_LAST_ELEMENT |
|
|
|
|
MPI_SGE_FLAGS_END_OF_BUFFER |
|
|
|
|
MPI_SGE_FLAGS_SIMPLE_ELEMENT |
|
|
|
|
MPI_SGE_FLAGS_SYSTEM_ADDRESS |
|
|
|
|
MPI_SGE_FLAGS_HOST_TO_IOC |
|
|
|
|
MPI_SGE_FLAGS_64_BIT_ADDRESSING |
|
|
|
|
MPI_SGE_FLAGS_END_OF_LIST) << MPI_SGE_FLAGS_SHIFT) |
|
|
|
|
skb->len);
|
|
|
|
pSimple->Address.Low = cpu_to_le32((u32) dma);
|
|
|
|
if (sizeof(dma_addr_t) > sizeof(u32))
|
|
|
|
pSimple->Address.High = cpu_to_le32((u32) ((u64) dma >> 32));
|
|
|
|
else
|
|
|
|
pSimple->Address.High = 0;
|
|
|
|
|
|
|
|
mpt_put_msg_frame (LanCtx, mpt_dev, mf);
|
2016-05-03 14:33:13 +00:00
|
|
|
netif_trans_update(dev);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
dioprintk((KERN_INFO MYNAM ": %s/%s: Sending packet. FlagsLength = %08x.\n",
|
|
|
|
IOC_AND_NETDEV_NAMES_s_s(dev),
|
|
|
|
le32_to_cpu(pSimple->FlagsLength)));
|
|
|
|
|
2009-06-23 06:03:08 +00:00
|
|
|
return NETDEV_TX_OK;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
|
2006-01-14 21:20:43 +00:00
|
|
|
static void
|
2005-04-16 22:20:36 +00:00
|
|
|
mpt_lan_wake_post_buckets_task(struct net_device *dev, int priority)
|
|
|
|
/*
|
|
|
|
* @priority: 0 = put it on the timer queue, 1 = put it on the immediate queue
|
|
|
|
*/
|
|
|
|
{
|
2008-12-04 05:13:37 +00:00
|
|
|
struct mpt_lan_priv *priv = netdev_priv(dev);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if (test_and_set_bit(0, &priv->post_buckets_active) == 0) {
|
|
|
|
if (priority) {
|
2006-11-22 14:57:56 +00:00
|
|
|
schedule_delayed_work(&priv->post_buckets_task, 0);
|
2005-04-16 22:20:36 +00:00
|
|
|
} else {
|
|
|
|
schedule_delayed_work(&priv->post_buckets_task, 1);
|
|
|
|
dioprintk((KERN_INFO MYNAM ": post_buckets queued on "
|
|
|
|
"timer.\n"));
|
|
|
|
}
|
|
|
|
dioprintk((KERN_INFO MYNAM ": %s/%s: Queued post_buckets task.\n",
|
|
|
|
IOC_AND_NETDEV_NAMES_s_s(dev) ));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
|
2006-01-14 21:20:43 +00:00
|
|
|
static int
|
2005-04-16 22:20:36 +00:00
|
|
|
mpt_lan_receive_skb(struct net_device *dev, struct sk_buff *skb)
|
|
|
|
{
|
2008-12-04 05:13:37 +00:00
|
|
|
struct mpt_lan_priv *priv = netdev_priv(dev);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
skb->protocol = mpt_lan_type_trans(skb, dev);
|
|
|
|
|
|
|
|
dioprintk((KERN_INFO MYNAM ": %s/%s: Incoming packet (%d bytes) "
|
|
|
|
"delivered to upper level.\n",
|
|
|
|
IOC_AND_NETDEV_NAMES_s_s(dev), skb->len));
|
|
|
|
|
2009-01-08 02:04:45 +00:00
|
|
|
dev->stats.rx_bytes += skb->len;
|
|
|
|
dev->stats.rx_packets++;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
skb->dev = dev;
|
|
|
|
netif_rx(skb);
|
|
|
|
|
|
|
|
dioprintk((MYNAM "/receive_skb: %d buckets remaining\n",
|
|
|
|
atomic_read(&priv->buckets_out)));
|
|
|
|
|
|
|
|
if (atomic_read(&priv->buckets_out) < priv->bucketthresh)
|
|
|
|
mpt_lan_wake_post_buckets_task(dev, 1);
|
|
|
|
|
|
|
|
dioprintk((KERN_INFO MYNAM "/receive_post_reply: %d buckets "
|
|
|
|
"remaining, %d received back since sod\n",
|
|
|
|
atomic_read(&priv->buckets_out), priv->total_received));
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
|
|
|
|
//static inline int
|
|
|
|
static int
|
|
|
|
mpt_lan_receive_post_turbo(struct net_device *dev, u32 tmsg)
|
|
|
|
{
|
2008-12-04 05:13:37 +00:00
|
|
|
struct mpt_lan_priv *priv = netdev_priv(dev);
|
2005-04-16 22:20:36 +00:00
|
|
|
MPT_ADAPTER *mpt_dev = priv->mpt_dev;
|
|
|
|
struct sk_buff *skb, *old_skb;
|
|
|
|
unsigned long flags;
|
|
|
|
u32 ctx, len;
|
|
|
|
|
|
|
|
ctx = GET_LAN_BUCKET_CONTEXT(tmsg);
|
|
|
|
skb = priv->RcvCtl[ctx].skb;
|
|
|
|
|
|
|
|
len = GET_LAN_PACKET_LENGTH(tmsg);
|
|
|
|
|
|
|
|
if (len < MPT_LAN_RX_COPYBREAK) {
|
|
|
|
old_skb = skb;
|
|
|
|
|
|
|
|
skb = (struct sk_buff *)dev_alloc_skb(len);
|
|
|
|
if (!skb) {
|
|
|
|
printk (KERN_ERR MYNAM ": %s/%s: ERROR - Can't allocate skb! (%s@%d)\n",
|
|
|
|
IOC_AND_NETDEV_NAMES_s_s(dev),
|
|
|
|
__FILE__, __LINE__);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
2022-01-06 21:54:05 +00:00
|
|
|
dma_sync_single_for_cpu(&mpt_dev->pcidev->dev,
|
|
|
|
priv->RcvCtl[ctx].dma,
|
|
|
|
priv->RcvCtl[ctx].len,
|
|
|
|
DMA_FROM_DEVICE);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2007-03-27 21:55:52 +00:00
|
|
|
skb_copy_from_linear_data(old_skb, skb_put(skb, len), len);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2022-01-06 21:54:05 +00:00
|
|
|
dma_sync_single_for_device(&mpt_dev->pcidev->dev,
|
|
|
|
priv->RcvCtl[ctx].dma,
|
|
|
|
priv->RcvCtl[ctx].len,
|
|
|
|
DMA_FROM_DEVICE);
|
2005-04-16 22:20:36 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
skb_put(skb, len);
|
|
|
|
|
|
|
|
priv->RcvCtl[ctx].skb = NULL;
|
|
|
|
|
2022-01-06 21:54:05 +00:00
|
|
|
dma_unmap_single(&mpt_dev->pcidev->dev, priv->RcvCtl[ctx].dma,
|
|
|
|
priv->RcvCtl[ctx].len, DMA_FROM_DEVICE);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
out:
|
|
|
|
spin_lock_irqsave(&priv->rxfidx_lock, flags);
|
|
|
|
priv->mpt_rxfidx[++priv->mpt_rxfidx_tail] = ctx;
|
|
|
|
spin_unlock_irqrestore(&priv->rxfidx_lock, flags);
|
|
|
|
|
|
|
|
atomic_dec(&priv->buckets_out);
|
|
|
|
priv->total_received++;
|
|
|
|
|
|
|
|
return mpt_lan_receive_skb(dev, skb);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
|
|
|
|
static int
|
|
|
|
mpt_lan_receive_post_free(struct net_device *dev,
|
|
|
|
LANReceivePostReply_t *pRecvRep)
|
|
|
|
{
|
2008-12-04 05:13:37 +00:00
|
|
|
struct mpt_lan_priv *priv = netdev_priv(dev);
|
2005-04-16 22:20:36 +00:00
|
|
|
MPT_ADAPTER *mpt_dev = priv->mpt_dev;
|
|
|
|
unsigned long flags;
|
|
|
|
struct sk_buff *skb;
|
|
|
|
u32 ctx;
|
|
|
|
int count;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
count = pRecvRep->NumberOfContexts;
|
|
|
|
|
|
|
|
/**/ dlprintk((KERN_INFO MYNAM "/receive_post_reply: "
|
|
|
|
"IOC returned %d buckets, freeing them...\n", count));
|
|
|
|
|
|
|
|
spin_lock_irqsave(&priv->rxfidx_lock, flags);
|
|
|
|
for (i = 0; i < count; i++) {
|
|
|
|
ctx = le32_to_cpu(pRecvRep->BucketContext[i]);
|
|
|
|
|
|
|
|
skb = priv->RcvCtl[ctx].skb;
|
|
|
|
|
|
|
|
// dlprintk((KERN_INFO MYNAM ": %s: dev_name = %s\n",
|
|
|
|
// IOC_AND_NETDEV_NAMES_s_s(dev)));
|
|
|
|
// dlprintk((KERN_INFO MYNAM "@rpr[2], priv = %p, buckets_out addr = %p",
|
|
|
|
// priv, &(priv->buckets_out)));
|
|
|
|
// dlprintk((KERN_INFO MYNAM "@rpr[2] TC + 3\n"));
|
|
|
|
|
|
|
|
priv->RcvCtl[ctx].skb = NULL;
|
2022-01-06 21:54:05 +00:00
|
|
|
dma_unmap_single(&mpt_dev->pcidev->dev, priv->RcvCtl[ctx].dma,
|
|
|
|
priv->RcvCtl[ctx].len, DMA_FROM_DEVICE);
|
2005-04-16 22:20:36 +00:00
|
|
|
dev_kfree_skb_any(skb);
|
|
|
|
|
|
|
|
priv->mpt_rxfidx[++priv->mpt_rxfidx_tail] = ctx;
|
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(&priv->rxfidx_lock, flags);
|
|
|
|
|
|
|
|
atomic_sub(count, &priv->buckets_out);
|
|
|
|
|
|
|
|
// for (i = 0; i < priv->max_buckets_out; i++)
|
|
|
|
// if (priv->RcvCtl[i].skb != NULL)
|
|
|
|
// dlprintk((KERN_INFO MYNAM "@rpr: bucket %03x "
|
|
|
|
// "is still out\n", i));
|
|
|
|
|
|
|
|
/* dlprintk((KERN_INFO MYNAM "/receive_post_reply: freed %d buckets\n",
|
|
|
|
count));
|
|
|
|
*/
|
|
|
|
/**/ dlprintk((KERN_INFO MYNAM "@receive_post_reply: %d buckets "
|
|
|
|
/**/ "remaining, %d received back since sod.\n",
|
|
|
|
/**/ atomic_read(&priv->buckets_out), priv->total_received));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
|
|
|
|
static int
|
|
|
|
mpt_lan_receive_post_reply(struct net_device *dev,
|
|
|
|
LANReceivePostReply_t *pRecvRep)
|
|
|
|
{
|
2008-12-04 05:13:37 +00:00
|
|
|
struct mpt_lan_priv *priv = netdev_priv(dev);
|
2005-04-16 22:20:36 +00:00
|
|
|
MPT_ADAPTER *mpt_dev = priv->mpt_dev;
|
|
|
|
struct sk_buff *skb, *old_skb;
|
|
|
|
unsigned long flags;
|
|
|
|
u32 len, ctx, offset;
|
|
|
|
u32 remaining = le32_to_cpu(pRecvRep->BucketsRemaining);
|
|
|
|
int count;
|
|
|
|
int i, l;
|
|
|
|
|
|
|
|
dioprintk((KERN_INFO MYNAM ": mpt_lan_receive_post_reply called\n"));
|
|
|
|
dioprintk((KERN_INFO MYNAM ": receive_post_reply: IOCStatus: %04x\n",
|
|
|
|
le16_to_cpu(pRecvRep->IOCStatus)));
|
|
|
|
|
|
|
|
if ((le16_to_cpu(pRecvRep->IOCStatus) & MPI_IOCSTATUS_MASK) ==
|
|
|
|
MPI_IOCSTATUS_LAN_CANCELED)
|
|
|
|
return mpt_lan_receive_post_free(dev, pRecvRep);
|
|
|
|
|
|
|
|
len = le32_to_cpu(pRecvRep->PacketLength);
|
|
|
|
if (len == 0) {
|
|
|
|
printk (KERN_ERR MYNAM ": %s/%s: ERROR - Got a non-TURBO "
|
|
|
|
"ReceivePostReply w/ PacketLength zero!\n",
|
|
|
|
IOC_AND_NETDEV_NAMES_s_s(dev));
|
|
|
|
printk (KERN_ERR MYNAM ": MsgFlags = %02x, IOCStatus = %04x\n",
|
|
|
|
pRecvRep->MsgFlags, le16_to_cpu(pRecvRep->IOCStatus));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
ctx = le32_to_cpu(pRecvRep->BucketContext[0]);
|
|
|
|
count = pRecvRep->NumberOfContexts;
|
|
|
|
skb = priv->RcvCtl[ctx].skb;
|
|
|
|
|
|
|
|
offset = le32_to_cpu(pRecvRep->PacketOffset);
|
|
|
|
// if (offset != 0) {
|
|
|
|
// printk (KERN_INFO MYNAM ": %s/%s: Got a ReceivePostReply "
|
|
|
|
// "w/ PacketOffset %u\n",
|
|
|
|
// IOC_AND_NETDEV_NAMES_s_s(dev),
|
|
|
|
// offset);
|
|
|
|
// }
|
|
|
|
|
|
|
|
dioprintk((KERN_INFO MYNAM ": %s/%s: @rpr, offset = %d, len = %d\n",
|
|
|
|
IOC_AND_NETDEV_NAMES_s_s(dev),
|
|
|
|
offset, len));
|
|
|
|
|
|
|
|
if (count > 1) {
|
|
|
|
int szrem = len;
|
|
|
|
|
|
|
|
// dioprintk((KERN_INFO MYNAM ": %s/%s: Multiple buckets returned "
|
|
|
|
// "for single packet, concatenating...\n",
|
|
|
|
// IOC_AND_NETDEV_NAMES_s_s(dev)));
|
|
|
|
|
|
|
|
skb = (struct sk_buff *)dev_alloc_skb(len);
|
|
|
|
if (!skb) {
|
|
|
|
printk (KERN_ERR MYNAM ": %s/%s: ERROR - Can't allocate skb! (%s@%d)\n",
|
|
|
|
IOC_AND_NETDEV_NAMES_s_s(dev),
|
|
|
|
__FILE__, __LINE__);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
spin_lock_irqsave(&priv->rxfidx_lock, flags);
|
|
|
|
for (i = 0; i < count; i++) {
|
|
|
|
|
|
|
|
ctx = le32_to_cpu(pRecvRep->BucketContext[i]);
|
|
|
|
old_skb = priv->RcvCtl[ctx].skb;
|
|
|
|
|
|
|
|
l = priv->RcvCtl[ctx].len;
|
|
|
|
if (szrem < l)
|
|
|
|
l = szrem;
|
|
|
|
|
|
|
|
// dioprintk((KERN_INFO MYNAM ": %s/%s: Buckets = %d, len = %u\n",
|
|
|
|
// IOC_AND_NETDEV_NAMES_s_s(dev),
|
|
|
|
// i, l));
|
|
|
|
|
2022-01-06 21:54:05 +00:00
|
|
|
dma_sync_single_for_cpu(&mpt_dev->pcidev->dev,
|
|
|
|
priv->RcvCtl[ctx].dma,
|
|
|
|
priv->RcvCtl[ctx].len,
|
|
|
|
DMA_FROM_DEVICE);
|
2007-03-27 21:55:52 +00:00
|
|
|
skb_copy_from_linear_data(old_skb, skb_put(skb, l), l);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2022-01-06 21:54:05 +00:00
|
|
|
dma_sync_single_for_device(&mpt_dev->pcidev->dev,
|
|
|
|
priv->RcvCtl[ctx].dma,
|
|
|
|
priv->RcvCtl[ctx].len,
|
|
|
|
DMA_FROM_DEVICE);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
priv->mpt_rxfidx[++priv->mpt_rxfidx_tail] = ctx;
|
|
|
|
szrem -= l;
|
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(&priv->rxfidx_lock, flags);
|
|
|
|
|
|
|
|
} else if (len < MPT_LAN_RX_COPYBREAK) {
|
|
|
|
|
|
|
|
old_skb = skb;
|
|
|
|
|
|
|
|
skb = (struct sk_buff *)dev_alloc_skb(len);
|
|
|
|
if (!skb) {
|
|
|
|
printk (KERN_ERR MYNAM ": %s/%s: ERROR - Can't allocate skb! (%s@%d)\n",
|
|
|
|
IOC_AND_NETDEV_NAMES_s_s(dev),
|
|
|
|
__FILE__, __LINE__);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
2022-01-06 21:54:05 +00:00
|
|
|
dma_sync_single_for_cpu(&mpt_dev->pcidev->dev,
|
|
|
|
priv->RcvCtl[ctx].dma,
|
|
|
|
priv->RcvCtl[ctx].len,
|
|
|
|
DMA_FROM_DEVICE);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2007-03-27 21:55:52 +00:00
|
|
|
skb_copy_from_linear_data(old_skb, skb_put(skb, len), len);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2022-01-06 21:54:05 +00:00
|
|
|
dma_sync_single_for_device(&mpt_dev->pcidev->dev,
|
|
|
|
priv->RcvCtl[ctx].dma,
|
|
|
|
priv->RcvCtl[ctx].len,
|
|
|
|
DMA_FROM_DEVICE);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
spin_lock_irqsave(&priv->rxfidx_lock, flags);
|
|
|
|
priv->mpt_rxfidx[++priv->mpt_rxfidx_tail] = ctx;
|
|
|
|
spin_unlock_irqrestore(&priv->rxfidx_lock, flags);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
spin_lock_irqsave(&priv->rxfidx_lock, flags);
|
|
|
|
|
|
|
|
priv->RcvCtl[ctx].skb = NULL;
|
|
|
|
|
2022-01-06 21:54:05 +00:00
|
|
|
dma_unmap_single(&mpt_dev->pcidev->dev, priv->RcvCtl[ctx].dma,
|
|
|
|
priv->RcvCtl[ctx].len, DMA_FROM_DEVICE);
|
2005-04-16 22:20:36 +00:00
|
|
|
priv->RcvCtl[ctx].dma = 0;
|
|
|
|
|
|
|
|
priv->mpt_rxfidx[++priv->mpt_rxfidx_tail] = ctx;
|
|
|
|
spin_unlock_irqrestore(&priv->rxfidx_lock, flags);
|
|
|
|
|
|
|
|
skb_put(skb,len);
|
|
|
|
}
|
|
|
|
|
|
|
|
atomic_sub(count, &priv->buckets_out);
|
|
|
|
priv->total_received += count;
|
|
|
|
|
|
|
|
if (priv->mpt_rxfidx_tail >= MPT_LAN_MAX_BUCKETS_OUT) {
|
|
|
|
printk (KERN_ERR MYNAM ": %s/%s: Yoohoo! mpt_rxfidx_tail = %d, "
|
|
|
|
"MPT_LAN_MAX_BUCKETS_OUT = %d\n",
|
|
|
|
IOC_AND_NETDEV_NAMES_s_s(dev),
|
|
|
|
priv->mpt_rxfidx_tail,
|
|
|
|
MPT_LAN_MAX_BUCKETS_OUT);
|
|
|
|
|
2006-02-03 00:20:05 +00:00
|
|
|
return -1;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (remaining == 0)
|
|
|
|
printk (KERN_WARNING MYNAM ": %s/%s: WARNING - IOC out of buckets! "
|
|
|
|
"(priv->buckets_out = %d)\n",
|
|
|
|
IOC_AND_NETDEV_NAMES_s_s(dev),
|
|
|
|
atomic_read(&priv->buckets_out));
|
|
|
|
else if (remaining < 10)
|
|
|
|
printk (KERN_INFO MYNAM ": %s/%s: IOC says %d buckets left. "
|
|
|
|
"(priv->buckets_out = %d)\n",
|
|
|
|
IOC_AND_NETDEV_NAMES_s_s(dev),
|
|
|
|
remaining, atomic_read(&priv->buckets_out));
|
|
|
|
|
|
|
|
if ((remaining < priv->bucketthresh) &&
|
|
|
|
((atomic_read(&priv->buckets_out) - remaining) >
|
|
|
|
MPT_LAN_BUCKETS_REMAIN_MISMATCH_THRESH)) {
|
|
|
|
|
|
|
|
printk (KERN_WARNING MYNAM " Mismatch between driver's "
|
|
|
|
"buckets_out count and fw's BucketsRemaining "
|
|
|
|
"count has crossed the threshold, issuing a "
|
|
|
|
"LanReset to clear the fw's hashtable. You may "
|
|
|
|
"want to check your /var/log/messages for \"CRC "
|
|
|
|
"error\" event notifications.\n");
|
|
|
|
|
|
|
|
mpt_lan_reset(dev);
|
|
|
|
mpt_lan_wake_post_buckets_task(dev, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
return mpt_lan_receive_skb(dev, skb);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
|
|
|
|
/* Simple SGE's only at the moment */
|
|
|
|
|
|
|
|
static void
|
2006-11-22 14:57:56 +00:00
|
|
|
mpt_lan_post_receive_buckets(struct mpt_lan_priv *priv)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2006-11-22 14:57:56 +00:00
|
|
|
struct net_device *dev = priv->dev;
|
2005-04-16 22:20:36 +00:00
|
|
|
MPT_ADAPTER *mpt_dev = priv->mpt_dev;
|
|
|
|
MPT_FRAME_HDR *mf;
|
|
|
|
LANReceivePostRequest_t *pRecvReq;
|
|
|
|
SGETransaction32_t *pTrans;
|
|
|
|
SGESimple64_t *pSimple;
|
|
|
|
struct sk_buff *skb;
|
|
|
|
dma_addr_t dma;
|
|
|
|
u32 curr, buckets, count, max;
|
|
|
|
u32 len = (dev->mtu + dev->hard_header_len + 4);
|
|
|
|
unsigned long flags;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
curr = atomic_read(&priv->buckets_out);
|
|
|
|
buckets = (priv->max_buckets_out - curr);
|
|
|
|
|
|
|
|
dioprintk((KERN_INFO MYNAM ": %s/%s: @%s, Start_buckets = %u, buckets_out = %u\n",
|
|
|
|
IOC_AND_NETDEV_NAMES_s_s(dev),
|
2008-07-04 06:47:27 +00:00
|
|
|
__func__, buckets, curr));
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
max = (mpt_dev->req_sz - MPT_LAN_RECEIVE_POST_REQUEST_SIZE) /
|
2021-03-24 23:33:44 +00:00
|
|
|
(sizeof(SGETransaction32_t) + sizeof(SGESimple64_t));
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
while (buckets) {
|
|
|
|
mf = mpt_get_msg_frame(LanCtx, mpt_dev);
|
|
|
|
if (mf == NULL) {
|
|
|
|
printk (KERN_ERR "%s: Unable to alloc request frame\n",
|
2008-07-04 06:47:27 +00:00
|
|
|
__func__);
|
2005-04-16 22:20:36 +00:00
|
|
|
dioprintk((KERN_ERR "%s: %u buckets remaining\n",
|
2008-07-04 06:47:27 +00:00
|
|
|
__func__, buckets));
|
2005-04-16 22:20:36 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
pRecvReq = (LANReceivePostRequest_t *) mf;
|
|
|
|
|
2007-09-29 16:17:49 +00:00
|
|
|
i = le16_to_cpu(mf->u.frame.hwhdr.msgctxu.fld.req_idx);
|
|
|
|
mpt_dev->RequestNB[i] = 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
count = buckets;
|
|
|
|
if (count > max)
|
|
|
|
count = max;
|
|
|
|
|
|
|
|
pRecvReq->Function = MPI_FUNCTION_LAN_RECEIVE;
|
|
|
|
pRecvReq->ChainOffset = 0;
|
|
|
|
pRecvReq->MsgFlags = 0;
|
|
|
|
pRecvReq->PortNumber = priv->pnum;
|
|
|
|
|
|
|
|
pTrans = (SGETransaction32_t *) pRecvReq->SG_List;
|
|
|
|
pSimple = NULL;
|
|
|
|
|
|
|
|
for (i = 0; i < count; i++) {
|
|
|
|
int ctx;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&priv->rxfidx_lock, flags);
|
|
|
|
if (priv->mpt_rxfidx_tail < 0) {
|
|
|
|
printk (KERN_ERR "%s: Can't alloc context\n",
|
2008-07-04 06:47:27 +00:00
|
|
|
__func__);
|
2005-04-16 22:20:36 +00:00
|
|
|
spin_unlock_irqrestore(&priv->rxfidx_lock,
|
|
|
|
flags);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ctx = priv->mpt_rxfidx[priv->mpt_rxfidx_tail--];
|
|
|
|
|
|
|
|
skb = priv->RcvCtl[ctx].skb;
|
|
|
|
if (skb && (priv->RcvCtl[ctx].len != len)) {
|
2022-01-06 21:54:05 +00:00
|
|
|
dma_unmap_single(&mpt_dev->pcidev->dev,
|
2005-04-16 22:20:36 +00:00
|
|
|
priv->RcvCtl[ctx].dma,
|
|
|
|
priv->RcvCtl[ctx].len,
|
2022-01-06 21:54:05 +00:00
|
|
|
DMA_FROM_DEVICE);
|
2005-04-16 22:20:36 +00:00
|
|
|
dev_kfree_skb(priv->RcvCtl[ctx].skb);
|
|
|
|
skb = priv->RcvCtl[ctx].skb = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (skb == NULL) {
|
|
|
|
skb = dev_alloc_skb(len);
|
|
|
|
if (skb == NULL) {
|
|
|
|
printk (KERN_WARNING
|
|
|
|
MYNAM "/%s: Can't alloc skb\n",
|
2008-07-04 06:47:27 +00:00
|
|
|
__func__);
|
2005-04-16 22:20:36 +00:00
|
|
|
priv->mpt_rxfidx[++priv->mpt_rxfidx_tail] = ctx;
|
|
|
|
spin_unlock_irqrestore(&priv->rxfidx_lock, flags);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2022-01-06 21:54:05 +00:00
|
|
|
dma = dma_map_single(&mpt_dev->pcidev->dev,
|
|
|
|
skb->data, len,
|
|
|
|
DMA_FROM_DEVICE);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
priv->RcvCtl[ctx].skb = skb;
|
|
|
|
priv->RcvCtl[ctx].dma = dma;
|
|
|
|
priv->RcvCtl[ctx].len = len;
|
|
|
|
}
|
|
|
|
|
|
|
|
spin_unlock_irqrestore(&priv->rxfidx_lock, flags);
|
|
|
|
|
|
|
|
pTrans->ContextSize = sizeof(u32);
|
|
|
|
pTrans->DetailsLength = 0;
|
|
|
|
pTrans->Flags = 0;
|
2021-03-24 23:33:44 +00:00
|
|
|
pTrans->TransactionContext = cpu_to_le32(ctx);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
pSimple = (SGESimple64_t *) pTrans->TransactionDetails;
|
|
|
|
|
|
|
|
pSimple->FlagsLength = cpu_to_le32(
|
|
|
|
((MPI_SGE_FLAGS_END_OF_BUFFER |
|
|
|
|
MPI_SGE_FLAGS_SIMPLE_ELEMENT |
|
|
|
|
MPI_SGE_FLAGS_64_BIT_ADDRESSING) << MPI_SGE_FLAGS_SHIFT) | len);
|
|
|
|
pSimple->Address.Low = cpu_to_le32((u32) priv->RcvCtl[ctx].dma);
|
|
|
|
if (sizeof(dma_addr_t) > sizeof(u32))
|
|
|
|
pSimple->Address.High = cpu_to_le32((u32) ((u64) priv->RcvCtl[ctx].dma >> 32));
|
|
|
|
else
|
|
|
|
pSimple->Address.High = 0;
|
|
|
|
|
|
|
|
pTrans = (SGETransaction32_t *) (pSimple + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pSimple == NULL) {
|
|
|
|
/**/ printk (KERN_WARNING MYNAM "/%s: No buckets posted\n",
|
2008-07-04 06:47:27 +00:00
|
|
|
/**/ __func__);
|
2005-04-16 22:20:36 +00:00
|
|
|
mpt_free_msg_frame(mpt_dev, mf);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
pSimple->FlagsLength |= cpu_to_le32(MPI_SGE_FLAGS_END_OF_LIST << MPI_SGE_FLAGS_SHIFT);
|
|
|
|
|
|
|
|
pRecvReq->BucketCount = cpu_to_le32(i);
|
|
|
|
|
|
|
|
/* printk(KERN_INFO MYNAM ": posting buckets\n ");
|
|
|
|
* for (i = 0; i < j + 2; i ++)
|
|
|
|
* printk (" %08x", le32_to_cpu(msg[i]));
|
|
|
|
* printk ("\n");
|
|
|
|
*/
|
|
|
|
|
|
|
|
mpt_put_msg_frame(LanCtx, mpt_dev, mf);
|
|
|
|
|
|
|
|
priv->total_posted += i;
|
|
|
|
buckets -= i;
|
|
|
|
atomic_add(i, &priv->buckets_out);
|
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
|
|
|
dioprintk((KERN_INFO MYNAM "/%s: End_buckets = %u, priv->buckets_out = %u\n",
|
2008-07-04 06:47:27 +00:00
|
|
|
__func__, buckets, atomic_read(&priv->buckets_out)));
|
2005-04-16 22:20:36 +00:00
|
|
|
dioprintk((KERN_INFO MYNAM "/%s: Posted %u buckets and received %u back\n",
|
2008-07-04 06:47:27 +00:00
|
|
|
__func__, priv->total_posted, priv->total_received));
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
clear_bit(0, &priv->post_buckets_active);
|
|
|
|
}
|
|
|
|
|
2006-11-22 14:57:56 +00:00
|
|
|
static void
|
|
|
|
mpt_lan_post_receive_buckets_work(struct work_struct *work)
|
|
|
|
{
|
|
|
|
mpt_lan_post_receive_buckets(container_of(work, struct mpt_lan_priv,
|
|
|
|
post_buckets_task.work));
|
|
|
|
}
|
|
|
|
|
2009-01-08 02:04:45 +00:00
|
|
|
static const struct net_device_ops mpt_netdev_ops = {
|
|
|
|
.ndo_open = mpt_lan_open,
|
|
|
|
.ndo_stop = mpt_lan_close,
|
|
|
|
.ndo_start_xmit = mpt_lan_sdu_send,
|
|
|
|
.ndo_tx_timeout = mpt_lan_tx_timeout,
|
|
|
|
};
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
|
|
|
|
static struct net_device *
|
|
|
|
mpt_register_lan_device (MPT_ADAPTER *mpt_dev, int pnum)
|
|
|
|
{
|
2007-08-10 21:50:53 +00:00
|
|
|
struct net_device *dev;
|
|
|
|
struct mpt_lan_priv *priv;
|
2005-04-16 22:20:36 +00:00
|
|
|
u8 HWaddr[FC_ALEN], *a;
|
|
|
|
|
2007-08-10 21:50:53 +00:00
|
|
|
dev = alloc_fcdev(sizeof(struct mpt_lan_priv));
|
2005-04-16 22:20:36 +00:00
|
|
|
if (!dev)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
dev->mtu = MPT_LAN_MTU;
|
|
|
|
|
|
|
|
priv = netdev_priv(dev);
|
|
|
|
|
2006-11-22 14:57:56 +00:00
|
|
|
priv->dev = dev;
|
2005-04-16 22:20:36 +00:00
|
|
|
priv->mpt_dev = mpt_dev;
|
|
|
|
priv->pnum = pnum;
|
|
|
|
|
2006-11-22 14:57:56 +00:00
|
|
|
INIT_DELAYED_WORK(&priv->post_buckets_task,
|
|
|
|
mpt_lan_post_receive_buckets_work);
|
2005-04-16 22:20:36 +00:00
|
|
|
priv->post_buckets_active = 0;
|
|
|
|
|
|
|
|
dlprintk((KERN_INFO MYNAM "@%d: bucketlen = %d\n",
|
|
|
|
__LINE__, dev->mtu + dev->hard_header_len + 4));
|
|
|
|
|
|
|
|
atomic_set(&priv->buckets_out, 0);
|
|
|
|
priv->total_posted = 0;
|
|
|
|
priv->total_received = 0;
|
|
|
|
priv->max_buckets_out = max_buckets_out;
|
|
|
|
if (mpt_dev->pfacts[0].MaxLanBuckets < max_buckets_out)
|
|
|
|
priv->max_buckets_out = mpt_dev->pfacts[0].MaxLanBuckets;
|
|
|
|
|
|
|
|
dlprintk((KERN_INFO MYNAM "@%d: MaxLanBuckets=%d, max_buckets_out/priv=%d/%d\n",
|
|
|
|
__LINE__,
|
|
|
|
mpt_dev->pfacts[0].MaxLanBuckets,
|
|
|
|
max_buckets_out,
|
|
|
|
priv->max_buckets_out));
|
|
|
|
|
|
|
|
priv->bucketthresh = priv->max_buckets_out * 2 / 3;
|
|
|
|
spin_lock_init(&priv->txfidx_lock);
|
|
|
|
spin_lock_init(&priv->rxfidx_lock);
|
|
|
|
|
|
|
|
/* Grab pre-fetched LANPage1 stuff. :-) */
|
|
|
|
a = (u8 *) &mpt_dev->lan_cnfg_page1.HardwareAddressLow;
|
|
|
|
|
|
|
|
HWaddr[0] = a[5];
|
|
|
|
HWaddr[1] = a[4];
|
|
|
|
HWaddr[2] = a[3];
|
|
|
|
HWaddr[3] = a[2];
|
|
|
|
HWaddr[4] = a[1];
|
|
|
|
HWaddr[5] = a[0];
|
|
|
|
|
|
|
|
dev->addr_len = FC_ALEN;
|
2021-10-26 17:55:00 +00:00
|
|
|
dev_addr_set(dev, HWaddr);
|
2005-04-16 22:20:36 +00:00
|
|
|
memset(dev->broadcast, 0xff, FC_ALEN);
|
|
|
|
|
|
|
|
/* The Tx queue is 127 deep on the 909.
|
|
|
|
* Give ourselves some breathing room.
|
|
|
|
*/
|
|
|
|
priv->tx_max_out = (tx_max_out_p <= MPT_TX_MAX_OUT_LIM) ?
|
|
|
|
tx_max_out_p : MPT_TX_MAX_OUT_LIM;
|
|
|
|
|
2009-01-08 02:04:45 +00:00
|
|
|
dev->netdev_ops = &mpt_netdev_ops;
|
2005-04-16 22:20:36 +00:00
|
|
|
dev->watchdog_timeo = MPT_LAN_TX_TIMEOUT;
|
|
|
|
|
net: use core MTU range checking in misc drivers
firewire-net:
- set min/max_mtu
- remove fwnet_change_mtu
nes:
- set max_mtu
- clean up nes_netdev_change_mtu
xpnet:
- set min/max_mtu
- remove xpnet_dev_change_mtu
hippi:
- set min/max_mtu
- remove hippi_change_mtu
batman-adv:
- set max_mtu
- remove batadv_interface_change_mtu
- initialization is a little async, not 100% certain that max_mtu is set
in the optimal place, don't have hardware to test with
rionet:
- set min/max_mtu
- remove rionet_change_mtu
slip:
- set min/max_mtu
- streamline sl_change_mtu
um/net_kern:
- remove pointless ndo_change_mtu
hsi/clients/ssi_protocol:
- use core MTU range checking
- remove now redundant ssip_pn_set_mtu
ipoib:
- set a default max MTU value
- Note: ipoib's actual max MTU can vary, depending on if the device is in
connected mode or not, so we'll just set the max_mtu value to the max
possible, and let the ndo_change_mtu function continue to validate any new
MTU change requests with checks for CM or not. Note that ipoib has no
min_mtu set, and thus, the network core's mtu > 0 check is the only lower
bounds here.
mptlan:
- use net core MTU range checking
- remove now redundant mpt_lan_change_mtu
fddi:
- min_mtu = 21, max_mtu = 4470
- remove now redundant fddi_change_mtu (including export)
fjes:
- min_mtu = 8192, max_mtu = 65536
- The max_mtu value is actually one over IP_MAX_MTU here, but the idea is to
get past the core net MTU range checks so fjes_change_mtu can validate a
new MTU against what it supports (see fjes_support_mtu in fjes_hw.c)
hsr:
- min_mtu = 0 (calls ether_setup, max_mtu is 1500)
f_phonet:
- min_mtu = 6, max_mtu = 65541
u_ether:
- min_mtu = 14, max_mtu = 15412
phonet/pep-gprs:
- min_mtu = 576, max_mtu = 65530
- remove redundant gprs_set_mtu
CC: netdev@vger.kernel.org
CC: linux-rdma@vger.kernel.org
CC: Stefan Richter <stefanr@s5r6.in-berlin.de>
CC: Faisal Latif <faisal.latif@intel.com>
CC: linux-rdma@vger.kernel.org
CC: Cliff Whickman <cpw@sgi.com>
CC: Robin Holt <robinmholt@gmail.com>
CC: Jes Sorensen <jes@trained-monkey.org>
CC: Marek Lindner <mareklindner@neomailbox.ch>
CC: Simon Wunderlich <sw@simonwunderlich.de>
CC: Antonio Quartulli <a@unstable.cc>
CC: Sathya Prakash <sathya.prakash@broadcom.com>
CC: Chaitra P B <chaitra.basappa@broadcom.com>
CC: Suganath Prabu Subramani <suganath-prabu.subramani@broadcom.com>
CC: MPT-FusionLinux.pdl@broadcom.com
CC: Sebastian Reichel <sre@kernel.org>
CC: Felipe Balbi <balbi@kernel.org>
CC: Arvid Brodin <arvid.brodin@alten.se>
CC: Remi Denis-Courmont <courmisch@gmail.com>
Signed-off-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-10-20 17:55:22 +00:00
|
|
|
/* MTU range: 96 - 65280 */
|
|
|
|
dev->min_mtu = MPT_LAN_MIN_MTU;
|
|
|
|
dev->max_mtu = MPT_LAN_MAX_MTU;
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
dlprintk((KERN_INFO MYNAM ": Finished registering dev "
|
|
|
|
"and setting initial values\n"));
|
|
|
|
|
|
|
|
if (register_netdev(dev) != 0) {
|
|
|
|
free_netdev(dev);
|
|
|
|
dev = NULL;
|
|
|
|
}
|
|
|
|
return dev;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2021-10-04 12:59:32 +00:00
|
|
|
mptlan_probe(struct pci_dev *pdev)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
MPT_ADAPTER *ioc = pci_get_drvdata(pdev);
|
|
|
|
struct net_device *dev;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < ioc->facts.NumberOfPorts; i++) {
|
|
|
|
printk(KERN_INFO MYNAM ": %s: PortNum=%x, "
|
|
|
|
"ProtocolFlags=%02Xh (%c%c%c%c)\n",
|
|
|
|
ioc->name, ioc->pfacts[i].PortNumber,
|
|
|
|
ioc->pfacts[i].ProtocolFlags,
|
|
|
|
MPT_PROTOCOL_FLAGS_c_c_c_c(
|
|
|
|
ioc->pfacts[i].ProtocolFlags));
|
|
|
|
|
|
|
|
if (!(ioc->pfacts[i].ProtocolFlags &
|
|
|
|
MPI_PORTFACTS_PROTOCOL_LAN)) {
|
|
|
|
printk(KERN_INFO MYNAM ": %s: Hmmm... LAN protocol "
|
|
|
|
"seems to be disabled on this adapter port!\n",
|
|
|
|
ioc->name);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
dev = mpt_register_lan_device(ioc, i);
|
|
|
|
if (!dev) {
|
|
|
|
printk(KERN_ERR MYNAM ": %s: Unable to register "
|
|
|
|
"port%d as a LAN device\n", ioc->name,
|
|
|
|
ioc->pfacts[i].PortNumber);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
printk(KERN_INFO MYNAM ": %s: Fusion MPT LAN device "
|
|
|
|
"registered as '%s'\n", ioc->name, dev->name);
|
|
|
|
printk(KERN_INFO MYNAM ": %s/%s: "
|
2008-10-28 00:47:26 +00:00
|
|
|
"LanAddr = %pM\n",
|
2005-04-16 22:20:36 +00:00
|
|
|
IOC_AND_NETDEV_NAMES_s_s(dev),
|
2008-10-28 00:47:26 +00:00
|
|
|
dev->dev_addr);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
ioc->netdev = dev;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
mptlan_remove(struct pci_dev *pdev)
|
|
|
|
{
|
|
|
|
MPT_ADAPTER *ioc = pci_get_drvdata(pdev);
|
|
|
|
struct net_device *dev = ioc->netdev;
|
|
|
|
|
|
|
|
if(dev != NULL) {
|
|
|
|
unregister_netdev(dev);
|
|
|
|
free_netdev(dev);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct mpt_pci_driver mptlan_driver = {
|
|
|
|
.probe = mptlan_probe,
|
|
|
|
.remove = mptlan_remove,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int __init mpt_lan_init (void)
|
|
|
|
{
|
|
|
|
show_mptmod_ver(LANAME, LANVER);
|
|
|
|
|
2010-07-26 13:27:36 +00:00
|
|
|
LanCtx = mpt_register(lan_reply, MPTLAN_DRIVER,
|
|
|
|
"lan_reply");
|
|
|
|
if (LanCtx <= 0) {
|
2005-04-16 22:20:36 +00:00
|
|
|
printk (KERN_ERR MYNAM ": Failed to register with MPT base driver\n");
|
|
|
|
return -EBUSY;
|
|
|
|
}
|
|
|
|
|
|
|
|
dlprintk((KERN_INFO MYNAM ": assigned context of %d\n", LanCtx));
|
|
|
|
|
|
|
|
if (mpt_reset_register(LanCtx, mpt_lan_ioc_reset)) {
|
|
|
|
printk(KERN_ERR MYNAM ": Eieee! unable to register a reset "
|
|
|
|
"handler with mptbase! The world is at an end! "
|
|
|
|
"Everything is fading to black! Goodbye.\n");
|
|
|
|
return -EBUSY;
|
|
|
|
}
|
|
|
|
|
|
|
|
dlprintk((KERN_INFO MYNAM ": Registered for IOC reset notifications\n"));
|
|
|
|
|
2007-07-24 10:17:41 +00:00
|
|
|
mpt_device_driver_register(&mptlan_driver, MPTLAN_DRIVER);
|
2005-04-16 22:20:36 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit mpt_lan_exit(void)
|
|
|
|
{
|
|
|
|
mpt_device_driver_deregister(MPTLAN_DRIVER);
|
|
|
|
mpt_reset_deregister(LanCtx);
|
|
|
|
|
2007-08-14 10:42:53 +00:00
|
|
|
if (LanCtx) {
|
2005-04-16 22:20:36 +00:00
|
|
|
mpt_deregister(LanCtx);
|
2007-08-14 10:42:53 +00:00
|
|
|
LanCtx = MPT_MAX_PROTOCOL_DRIVERS;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module_init(mpt_lan_init);
|
|
|
|
module_exit(mpt_lan_exit);
|
|
|
|
|
|
|
|
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
|
|
|
|
static unsigned short
|
|
|
|
mpt_lan_type_trans(struct sk_buff *skb, struct net_device *dev)
|
|
|
|
{
|
|
|
|
struct mpt_lan_ohdr *fch = (struct mpt_lan_ohdr *)skb->data;
|
|
|
|
struct fcllc *fcllc;
|
|
|
|
|
2007-03-19 22:30:44 +00:00
|
|
|
skb_reset_mac_header(skb);
|
2005-04-16 22:20:36 +00:00
|
|
|
skb_pull(skb, sizeof(struct mpt_lan_ohdr));
|
|
|
|
|
|
|
|
if (fch->dtype == htons(0xffff)) {
|
|
|
|
u32 *p = (u32 *) fch;
|
|
|
|
|
|
|
|
swab32s(p + 0);
|
|
|
|
swab32s(p + 1);
|
|
|
|
swab32s(p + 2);
|
|
|
|
swab32s(p + 3);
|
|
|
|
|
|
|
|
printk (KERN_WARNING MYNAM ": %s: WARNING - Broadcast swap F/W bug detected!\n",
|
|
|
|
NETDEV_PTR_TO_IOC_NAME_s(dev));
|
2008-10-28 00:47:26 +00:00
|
|
|
printk (KERN_WARNING MYNAM ": Please update sender @ MAC_addr = %pM\n",
|
|
|
|
fch->saddr);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (*fch->daddr & 1) {
|
|
|
|
if (!memcmp(fch->daddr, dev->broadcast, FC_ALEN)) {
|
|
|
|
skb->pkt_type = PACKET_BROADCAST;
|
|
|
|
} else {
|
|
|
|
skb->pkt_type = PACKET_MULTICAST;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (memcmp(fch->daddr, dev->dev_addr, FC_ALEN)) {
|
|
|
|
skb->pkt_type = PACKET_OTHERHOST;
|
|
|
|
} else {
|
|
|
|
skb->pkt_type = PACKET_HOST;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fcllc = (struct fcllc *)skb->data;
|
|
|
|
|
|
|
|
/* Strip the SNAP header from ARP packets since we don't
|
|
|
|
* pass them through to the 802.2/SNAP layers.
|
|
|
|
*/
|
|
|
|
if (fcllc->dsap == EXTENDED_SAP &&
|
|
|
|
(fcllc->ethertype == htons(ETH_P_IP) ||
|
|
|
|
fcllc->ethertype == htons(ETH_P_ARP))) {
|
|
|
|
skb_pull(skb, sizeof(struct fcllc));
|
|
|
|
return fcllc->ethertype;
|
|
|
|
}
|
|
|
|
|
|
|
|
return htons(ETH_P_802_2);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
|