1 /* Copyright (c) 2012 - 2015 UNISYS CORPORATION
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
11 * NON INFRINGEMENT. See the GNU General Public License for more
15 /* This driver lives in a spar partition, and registers to ethernet io
16 * channels from the visorbus driver. It creates netdev devices and
17 * forwards transmit to the IO channel and accepts rcvs from the IO
18 * Partition via the IO channel.
21 #include <linux/debugfs.h>
22 #include <linux/netdevice.h>
23 #include <linux/etherdevice.h>
24 #include <linux/skbuff.h>
25 #include <linux/kthread.h>
28 #include "iochannel.h"
30 #define VISORNIC_INFINITE_RESPONSE_WAIT 0
31 #define VISORNICSOPENMAX 32
32 #define MAXDEVICES 16384
34 /* MAX_BUF = 64 lines x 32 MAXVNIC x 80 characters
37 #define MAX_BUF 163840
39 static spinlock_t dev_num_pool_lock;
40 static void *dev_num_pool; /**< pool to grab device numbers from */
42 static int visornic_probe(struct visor_device *dev);
43 static void visornic_remove(struct visor_device *dev);
44 static int visornic_pause(struct visor_device *dev,
45 visorbus_state_complete_func complete_func);
46 static int visornic_resume(struct visor_device *dev,
47 visorbus_state_complete_func complete_func);
49 /* DEBUGFS declarations */
50 static ssize_t info_debugfs_read(struct file *file, char __user *buf,
51 size_t len, loff_t *offset);
52 static ssize_t enable_ints_write(struct file *file, const char __user *buf,
53 size_t len, loff_t *ppos);
54 static struct dentry *visornic_debugfs_dir;
55 static const struct file_operations debugfs_info_fops = {
56 .read = info_debugfs_read,
59 static const struct file_operations debugfs_enable_ints_fops = {
60 .write = enable_ints_write,
63 static struct workqueue_struct *visornic_serverdown_workqueue;
64 static struct workqueue_struct *visornic_timeout_reset_workqueue;
66 /* GUIDS for director channel type supported by this driver. */
67 static struct visor_channeltype_descriptor visornic_channel_types[] = {
68 /* Note that the only channel type we expect to be reported by the
69 * bus driver is the SPAR_VNIC channel.
71 { SPAR_VNIC_CHANNEL_PROTOCOL_UUID, "ultravnic" },
72 { NULL_UUID_LE, NULL }
75 /* This is used to tell the visor bus driver which types of visor devices
76 * we support, and what functions to call when a visor device that we support
77 * is attached or removed.
79 static struct visor_driver visornic_driver = {
84 .channel_types = visornic_channel_types,
85 .probe = visornic_probe,
86 .remove = visornic_remove,
87 .pause = visornic_pause,
88 .resume = visornic_resume,
89 .channel_interrupt = NULL,
92 struct visor_thread_info {
93 struct task_struct *task;
94 struct completion has_stopped;
99 unsigned long got_rcv;
100 unsigned long got_enbdisack;
101 unsigned long got_xmit_done;
102 unsigned long xmit_fail;
103 unsigned long sent_enbdis;
104 unsigned long sent_promisc;
105 unsigned long sent_post;
106 unsigned long sent_xmit;
107 unsigned long reject_count;
108 unsigned long extra_rcvbufs_sent;
111 struct visornic_devdata {
114 unsigned short enabled; /* 0 disabled 1 enabled to receive */
115 unsigned short enab_dis_acked; /* NET_RCV_ENABLE/DISABLE acked by
118 struct visor_device *dev;
120 struct list_head list_all; /* < link within list_all_devices list */
121 struct net_device *netdev;
122 struct net_device_stats net_stats;
123 atomic_t interrupt_rcvd;
124 wait_queue_head_t rsp_queue;
125 struct sk_buff **rcvbuf;
126 u64 uniquenum; /* TODO figure out why not used */
127 unsigned short old_flags; /* flags as they were prior to
130 atomic_t usage; /* count of users */
131 int num_rcv_bufs; /* indicates how many rcv buffers
134 int num_rcv_bufs_could_not_alloc;
135 atomic_t num_rcvbuf_in_iovm;
136 unsigned long alloc_failed_in_if_needed_cnt;
137 unsigned long alloc_failed_in_repost_rtn_cnt;
138 int max_outstanding_net_xmits; /* absolute max number of outstanding
139 * xmits - should never hit this
141 int upper_threshold_net_xmits; /* high water mark for calling
144 int lower_threshold_net_xmits; /* high water mark for calling
147 struct sk_buff_head xmitbufhead; /* xmitbufhead is the head of the
148 * xmit buffer list that have been
149 * sent to the IOPART end
151 struct work_struct serverdown_completion;
152 visorbus_state_complete_func server_down_complete_func;
153 struct work_struct timeout_reset;
154 struct uiscmdrsp *cmdrsp_rcv; /* cmdrsp_rcv is used for
155 * posting/unposting rcv buffers
157 struct uiscmdrsp *xmit_cmdrsp; /* used to issue NET_XMIT - there is
158 * never more that one xmit in
161 bool server_down; /* IOPART is down */
162 bool server_change_state; /* Processing SERVER_CHANGESTATE msg */
163 bool going_away; /* device is being torn down */
164 struct dentry *eth_debugfs_dir;
165 struct visor_thread_info threadinfo;
167 u64 interrupts_notme;
168 u64 interrupts_disabled;
170 spinlock_t priv_lock; /* spinlock to access devdata structures */
172 /* flow control counter */
173 u64 flow_control_upper_hits;
174 u64 flow_control_lower_hits;
177 unsigned long n_rcv0; /* # rcvs of 0 buffers */
178 unsigned long n_rcv1; /* # rcvs of 1 buffers */
179 unsigned long n_rcv2; /* # rcvs of 2 buffers */
180 unsigned long n_rcvx; /* # rcvs of >2 buffers */
181 unsigned long found_repost_rcvbuf_cnt; /* # times we called
184 unsigned long repost_found_skb_cnt; /* # times found the skb */
185 unsigned long n_repost_deficit; /* # times we couldn't find
186 * all of the rcv buffers
188 unsigned long bad_rcv_buf; /* # times we negleted to
189 * free the rcv skb because
190 * we didn't know where it
193 unsigned long n_rcv_packets_not_accepted;/* # bogs rcv packets */
195 int queuefullmsg_logged;
196 struct chanstat chstat;
199 /* array of open devices maintained by open() and close() */
200 static struct net_device *num_visornic_open[VISORNICSOPENMAX];
202 /* List of all visornic_devdata structs,
203 * linked via the list_all member
205 static LIST_HEAD(list_all_devices);
206 static DEFINE_SPINLOCK(lock_all_devices);
209 * visor_copy_fragsinfo_from_skb(
210 * @skb_in: skbuff that we are pulling the frags from
211 * @firstfraglen: length of first fragment in skb
212 * @frags_max: max len of frags array
213 * @frags: frags array filled in on output
215 * Copy the fragment list in the SKB to a phys_info
216 * array that the IOPART understands.
217 * Return value indicates number of entries filled in frags
218 * Negative values indicate an error.
221 visor_copy_fragsinfo_from_skb(struct sk_buff *skb, unsigned int firstfraglen,
222 unsigned int frags_max,
223 struct phys_info frags[])
225 unsigned int count = 0, ii, size, offset = 0, numfrags;
227 numfrags = skb_shinfo(skb)->nr_frags;
229 while (firstfraglen) {
230 if (count == frags_max)
233 frags[count].pi_pfn =
234 page_to_pfn(virt_to_page(skb->data + offset));
235 frags[count].pi_off =
236 (unsigned long)(skb->data + offset) & PI_PAGE_MASK;
237 size = min_t(unsigned int, firstfraglen,
238 PI_PAGE_SIZE - frags[count].pi_off);
240 /* can take smallest of firstfraglen (what's left) OR
241 * bytes left in the page
243 frags[count].pi_len = size;
244 firstfraglen -= size;
249 if ((count + numfrags) > frags_max)
252 for (ii = 0; ii < numfrags; ii++) {
253 count = add_physinfo_entries(page_to_pfn(
254 skb_frag_page(&skb_shinfo(skb)->frags[ii])),
255 skb_shinfo(skb)->frags[ii].
257 skb_shinfo(skb)->frags[ii].
258 size, count, frags_max, frags);
263 if (skb_shinfo(skb)->frag_list) {
264 struct sk_buff *skbinlist;
267 for (skbinlist = skb_shinfo(skb)->frag_list; skbinlist;
268 skbinlist = skbinlist->next) {
269 c = visor_copy_fragsinfo_from_skb(skbinlist,
283 * visort_thread_start - starts thread for the device
284 * @thrinfo: The thread to start
285 * @threadfn: Function the thread starts
286 * @thrcontext: Context to pass to the thread, i.e. devdata
287 * @name: string describing name of thread
289 * Starts a thread for the device, currently only thread is
290 * process_incoming_rsps
291 * Returns 0 on success;
293 static int visor_thread_start(struct visor_thread_info *thrinfo,
294 int (*threadfn)(void *),
295 void *thrcontext, char *name)
297 /* used to stop the thread */
298 init_completion(&thrinfo->has_stopped);
299 thrinfo->task = kthread_run(threadfn, thrcontext, name);
300 if (IS_ERR(thrinfo->task)) {
301 pr_debug("%s failed (%ld)\n",
302 __func__, PTR_ERR(thrinfo->task));
306 thrinfo->id = thrinfo->task->pid;
311 * visor_thread_stop - stop a thread for the device
312 * @thrinfo: The thread to stop
314 * Stop the thread and wait for completion for a minute
317 static void visor_thread_stop(struct visor_thread_info *thrinfo)
320 return; /* thread not running */
322 kthread_stop(thrinfo->task);
323 /* give up if the thread has NOT died in 1 minute */
324 if (wait_for_completion_timeout(&thrinfo->has_stopped, 60 * HZ))
329 static ssize_t info_debugfs_read(struct file *file, char __user *buf,
330 size_t len, loff_t *offset)
333 ssize_t bytes_read = 0;
335 struct visornic_devdata *devdata;
340 vbuf = kzalloc(len, GFP_KERNEL);
344 /* for each vnic channel
345 * dump out channel specific data
347 for (i = 0; i < VISORNICSOPENMAX; i++) {
348 if (!num_visornic_open[i])
351 devdata = netdev_priv(num_visornic_open[i]);
352 str_pos += scnprintf(vbuf + str_pos, len - str_pos,
354 str_pos += scnprintf(vbuf + str_pos, len - str_pos,
355 "netdev = %s (0x%p), MAC Addr %pM\n",
356 num_visornic_open[i]->name,
357 num_visornic_open[i],
358 num_visornic_open[i]->dev_addr);
359 str_pos += scnprintf(vbuf + str_pos, len - str_pos,
360 "VisorNic Dev Info = 0x%p\n", devdata);
361 str_pos += scnprintf(vbuf + str_pos, len - str_pos,
362 " num_rcv_bufs = %d\n",
363 devdata->num_rcv_bufs);
364 str_pos += scnprintf(vbuf + str_pos, len - str_pos,
365 " max_oustanding_next_xmits = %d\n",
366 devdata->max_outstanding_net_xmits);
367 str_pos += scnprintf(vbuf + str_pos, len - str_pos,
368 " upper_threshold_net_xmits = %d\n",
369 devdata->upper_threshold_net_xmits);
370 str_pos += scnprintf(vbuf + str_pos, len - str_pos,
371 " lower_threshold_net_xmits = %d\n",
372 devdata->lower_threshold_net_xmits);
373 str_pos += scnprintf(vbuf + str_pos, len - str_pos,
374 " queuefullmsg_logged = %d\n",
375 devdata->queuefullmsg_logged);
376 str_pos += scnprintf(vbuf + str_pos, len - str_pos,
377 " chstat.got_rcv = %lu\n",
378 devdata->chstat.got_rcv);
379 str_pos += scnprintf(vbuf + str_pos, len - str_pos,
380 " chstat.got_enbdisack = %lu\n",
381 devdata->chstat.got_enbdisack);
382 str_pos += scnprintf(vbuf + str_pos, len - str_pos,
383 " chstat.got_xmit_done = %lu\n",
384 devdata->chstat.got_xmit_done);
385 str_pos += scnprintf(vbuf + str_pos, len - str_pos,
386 " chstat.xmit_fail = %lu\n",
387 devdata->chstat.xmit_fail);
388 str_pos += scnprintf(vbuf + str_pos, len - str_pos,
389 " chstat.sent_enbdis = %lu\n",
390 devdata->chstat.sent_enbdis);
391 str_pos += scnprintf(vbuf + str_pos, len - str_pos,
392 " chstat.sent_promisc = %lu\n",
393 devdata->chstat.sent_promisc);
394 str_pos += scnprintf(vbuf + str_pos, len - str_pos,
395 " chstat.sent_post = %lu\n",
396 devdata->chstat.sent_post);
397 str_pos += scnprintf(vbuf + str_pos, len - str_pos,
398 " chstat.sent_xmit = %lu\n",
399 devdata->chstat.sent_xmit);
400 str_pos += scnprintf(vbuf + str_pos, len - str_pos,
401 " chstat.reject_count = %lu\n",
402 devdata->chstat.reject_count);
403 str_pos += scnprintf(vbuf + str_pos, len - str_pos,
404 " chstat.extra_rcvbufs_sent = %lu\n",
405 devdata->chstat.extra_rcvbufs_sent);
406 str_pos += scnprintf(vbuf + str_pos, len - str_pos,
407 " n_rcv0 = %lu\n", devdata->n_rcv0);
408 str_pos += scnprintf(vbuf + str_pos, len - str_pos,
409 " n_rcv1 = %lu\n", devdata->n_rcv1);
410 str_pos += scnprintf(vbuf + str_pos, len - str_pos,
411 " n_rcv2 = %lu\n", devdata->n_rcv2);
412 str_pos += scnprintf(vbuf + str_pos, len - str_pos,
413 " n_rcvx = %lu\n", devdata->n_rcvx);
414 str_pos += scnprintf(vbuf + str_pos, len - str_pos,
415 " num_rcvbuf_in_iovm = %d\n",
416 atomic_read(&devdata->num_rcvbuf_in_iovm));
417 str_pos += scnprintf(vbuf + str_pos, len - str_pos,
418 " alloc_failed_in_if_needed_cnt = %lu\n",
419 devdata->alloc_failed_in_if_needed_cnt);
420 str_pos += scnprintf(vbuf + str_pos, len - str_pos,
421 " alloc_failed_in_repost_rtn_cnt = %lu\n",
422 devdata->alloc_failed_in_repost_rtn_cnt);
423 /* str_pos += scnprintf(vbuf + str_pos, len - str_pos,
424 * " inner_loop_limit_reached_cnt = %lu\n",
425 * devdata->inner_loop_limit_reached_cnt);
427 str_pos += scnprintf(vbuf + str_pos, len - str_pos,
428 " found_repost_rcvbuf_cnt = %lu\n",
429 devdata->found_repost_rcvbuf_cnt);
430 str_pos += scnprintf(vbuf + str_pos, len - str_pos,
431 " repost_found_skb_cnt = %lu\n",
432 devdata->repost_found_skb_cnt);
433 str_pos += scnprintf(vbuf + str_pos, len - str_pos,
434 " n_repost_deficit = %lu\n",
435 devdata->n_repost_deficit);
436 str_pos += scnprintf(vbuf + str_pos, len - str_pos,
437 " bad_rcv_buf = %lu\n",
438 devdata->bad_rcv_buf);
439 str_pos += scnprintf(vbuf + str_pos, len - str_pos,
440 " n_rcv_packets_not_accepted = %lu\n",
441 devdata->n_rcv_packets_not_accepted);
442 str_pos += scnprintf(vbuf + str_pos, len - str_pos,
443 " interrupts_rcvd = %llu\n",
444 devdata->interrupts_rcvd);
445 str_pos += scnprintf(vbuf + str_pos, len - str_pos,
446 " interrupts_notme = %llu\n",
447 devdata->interrupts_notme);
448 str_pos += scnprintf(vbuf + str_pos, len - str_pos,
449 " interrupts_disabled = %llu\n",
450 devdata->interrupts_disabled);
451 str_pos += scnprintf(vbuf + str_pos, len - str_pos,
452 " busy_cnt = %llu\n",
454 str_pos += scnprintf(vbuf + str_pos, len - str_pos,
455 " flow_control_upper_hits = %llu\n",
456 devdata->flow_control_upper_hits);
457 str_pos += scnprintf(vbuf + str_pos, len - str_pos,
458 " flow_control_lower_hits = %llu\n",
459 devdata->flow_control_lower_hits);
460 str_pos += scnprintf(vbuf + str_pos, len - str_pos,
461 " thread_wait_ms = %d\n",
462 devdata->thread_wait_ms);
463 str_pos += scnprintf(vbuf + str_pos, len - str_pos,
464 " netif_queue = %s\n",
465 netif_queue_stopped(devdata->netdev) ?
466 "stopped" : "running");
468 bytes_read = simple_read_from_buffer(buf, len, offset, vbuf, str_pos);
473 static ssize_t enable_ints_write(struct file *file,
474 const char __user *buffer,
475 size_t count, loff_t *ppos)
479 struct visornic_devdata *devdata;
481 if (count >= ARRAY_SIZE(buf))
485 if (copy_from_user(buf, buffer, count))
488 i = kstrtoint(buf, 10, &new_value);
492 /* set all counts to new_value usually 0 */
493 for (i = 0; i < VISORNICSOPENMAX; i++) {
494 if (num_visornic_open[i]) {
495 devdata = netdev_priv(num_visornic_open[i]);
496 /* TODO update features bit in channel */
504 * visornic_serverdown_complete - IOPART went down, need to pause
506 * @work: Work queue it was scheduled on
508 * The IO partition has gone down and we need to do some cleanup
509 * for when it comes back. Treat the IO partition as the link
514 visornic_serverdown_complete(struct work_struct *work)
516 struct visornic_devdata *devdata;
517 struct net_device *netdev;
519 int i = 0, count = 0;
521 devdata = container_of(work, struct visornic_devdata,
522 serverdown_completion);
523 netdev = devdata->netdev;
525 /* Stop using datachan */
526 visor_thread_stop(&devdata->threadinfo);
528 /* Inform Linux that the link is down */
529 netif_carrier_off(netdev);
530 netif_stop_queue(netdev);
532 /* Free the skb for XMITs that haven't been serviced by the server
533 * We shouldn't have to inform Linux about these IOs because they
534 * are "lost in the ethernet"
536 skb_queue_purge(&devdata->xmitbufhead);
538 spin_lock_irqsave(&devdata->priv_lock, flags);
539 /* free rcv buffers */
540 for (i = 0; i < devdata->num_rcv_bufs; i++) {
541 if (devdata->rcvbuf[i]) {
542 kfree_skb(devdata->rcvbuf[i]);
543 devdata->rcvbuf[i] = NULL;
547 atomic_set(&devdata->num_rcvbuf_in_iovm, 0);
548 spin_unlock_irqrestore(&devdata->priv_lock, flags);
550 if (devdata->server_down_complete_func)
551 (*devdata->server_down_complete_func)(devdata->dev, 0);
553 devdata->server_down = true;
554 devdata->server_change_state = false;
555 devdata->server_down_complete_func = NULL;
559 * visornic_serverdown - Command has notified us that IOPARt is down
560 * @devdata: device that is being managed by IOPART
562 * Schedule the work needed to handle the server down request. Make
563 * sure we haven't already handled the server change state event.
564 * Returns 0 if we scheduled the work, -EINVAL on error.
567 visornic_serverdown(struct visornic_devdata *devdata,
568 visorbus_state_complete_func complete_func)
572 spin_lock_irqsave(&devdata->priv_lock, flags);
573 if (!devdata->server_down && !devdata->server_change_state) {
574 if (devdata->going_away) {
575 spin_unlock_irqrestore(&devdata->priv_lock, flags);
576 dev_dbg(&devdata->dev->device,
577 "%s aborting because device removal pending\n",
581 devdata->server_change_state = true;
582 devdata->server_down_complete_func = complete_func;
583 queue_work(visornic_serverdown_workqueue,
584 &devdata->serverdown_completion);
585 } else if (devdata->server_change_state) {
586 dev_dbg(&devdata->dev->device, "%s changing state\n",
588 spin_unlock_irqrestore(&devdata->priv_lock, flags);
591 spin_unlock_irqrestore(&devdata->priv_lock, flags);
596 * alloc_rcv_buf - alloc rcv buffer to be given to the IO Partition.
597 * @netdev: network adapter the rcv bufs are attached too.
599 * Create an sk_buff (rcv_buf) that will be passed to the IO Partition
600 * so that it can write rcv data into our memory space.
601 * Return pointer to sk_buff
603 static struct sk_buff *
604 alloc_rcv_buf(struct net_device *netdev)
608 /* NOTE: the first fragment in each rcv buffer is pointed to by
609 * rcvskb->data. For now all rcv buffers will be RCVPOST_BUF_SIZE
610 * in length, so the firstfrag is large enough to hold 1514.
612 skb = alloc_skb(RCVPOST_BUF_SIZE, GFP_ATOMIC);
616 skb->len = RCVPOST_BUF_SIZE;
617 /* current value of mtu doesn't come into play here; large
618 * packets will just end up using multiple rcv buffers all of
621 skb->data_len = 0; /* dev_alloc_skb already zeroes it out
628 * post_skb - post a skb to the IO Partition.
629 * @cmdrsp: cmdrsp packet to be send to the IO Partition
630 * @devdata: visornic_devdata to post the skb too
631 * @skb: skb to give to the IO partition
633 * Send the skb to the IO Partition.
637 post_skb(struct uiscmdrsp *cmdrsp,
638 struct visornic_devdata *devdata, struct sk_buff *skb)
640 cmdrsp->net.buf = skb;
641 cmdrsp->net.rcvpost.frag.pi_pfn = page_to_pfn(virt_to_page(skb->data));
642 cmdrsp->net.rcvpost.frag.pi_off =
643 (unsigned long)skb->data & PI_PAGE_MASK;
644 cmdrsp->net.rcvpost.frag.pi_len = skb->len;
645 cmdrsp->net.rcvpost.unique_num = devdata->uniquenum;
647 if ((cmdrsp->net.rcvpost.frag.pi_off + skb->len) <= PI_PAGE_SIZE) {
648 cmdrsp->net.type = NET_RCV_POST;
649 cmdrsp->cmdtype = CMD_NET_TYPE;
650 visorchannel_signalinsert(devdata->dev->visorchannel,
653 atomic_inc(&devdata->num_rcvbuf_in_iovm);
654 devdata->chstat.sent_post++;
659 * send_enbdis - send NET_RCV_ENBDIS to IO Partition
660 * @netdev: netdevice we are enable/disable, used as context
662 * @state: enable = 1/disable = 0
663 * @devdata: visornic device we are enabling/disabling
665 * Send the enable/disable message to the IO Partition.
669 send_enbdis(struct net_device *netdev, int state,
670 struct visornic_devdata *devdata)
672 devdata->cmdrsp_rcv->net.enbdis.enable = state;
673 devdata->cmdrsp_rcv->net.enbdis.context = netdev;
674 devdata->cmdrsp_rcv->net.type = NET_RCV_ENBDIS;
675 devdata->cmdrsp_rcv->cmdtype = CMD_NET_TYPE;
676 visorchannel_signalinsert(devdata->dev->visorchannel,
678 devdata->cmdrsp_rcv);
679 devdata->chstat.sent_enbdis++;
683 * visornic_disable_with_timeout - Disable network adapter
684 * @netdev: netdevice to disale
685 * @timeout: timeout to wait for disable
687 * Disable the network adapter and inform the IO Partition that we
688 * are disabled, reclaim memory from rcv bufs.
689 * Returns 0 on success, negative for failure of IO Partition
694 visornic_disable_with_timeout(struct net_device *netdev, const int timeout)
696 struct visornic_devdata *devdata = netdev_priv(netdev);
701 /* stop the transmit queue so nothing more can be transmitted */
702 netif_stop_queue(netdev);
704 /* send a msg telling the other end we are stopping incoming pkts */
705 spin_lock_irqsave(&devdata->priv_lock, flags);
706 devdata->enabled = 0;
707 devdata->enab_dis_acked = 0; /* must wait for ack */
708 spin_unlock_irqrestore(&devdata->priv_lock, flags);
710 /* send disable and wait for ack -- don't hold lock when sending
711 * disable because if the queue is full, insert might sleep.
713 send_enbdis(netdev, 0, devdata);
715 /* wait for ack to arrive before we try to free rcv buffers
716 * NOTE: the other end automatically unposts the rcv buffers when
717 * when it gets a disable.
719 spin_lock_irqsave(&devdata->priv_lock, flags);
720 while ((timeout == VISORNIC_INFINITE_RESPONSE_WAIT) ||
722 if (devdata->enab_dis_acked)
724 if (devdata->server_down || devdata->server_change_state) {
725 spin_unlock_irqrestore(&devdata->priv_lock, flags);
726 dev_dbg(&netdev->dev, "%s server went away\n",
730 set_current_state(TASK_INTERRUPTIBLE);
731 spin_unlock_irqrestore(&devdata->priv_lock, flags);
732 wait += schedule_timeout(msecs_to_jiffies(10));
733 spin_lock_irqsave(&devdata->priv_lock, flags);
736 /* Wait for usage to go to 1 (no other users) before freeing
739 if (atomic_read(&devdata->usage) > 1) {
741 set_current_state(TASK_INTERRUPTIBLE);
742 spin_unlock_irqrestore(&devdata->priv_lock, flags);
743 schedule_timeout(msecs_to_jiffies(10));
744 spin_lock_irqsave(&devdata->priv_lock, flags);
745 if (atomic_read(&devdata->usage))
750 /* we've set enabled to 0, so we can give up the lock. */
751 spin_unlock_irqrestore(&devdata->priv_lock, flags);
753 /* Free rcv buffers - other end has automatically unposed them on
756 for (i = 0; i < devdata->num_rcv_bufs; i++) {
757 if (devdata->rcvbuf[i]) {
758 kfree_skb(devdata->rcvbuf[i]);
759 devdata->rcvbuf[i] = NULL;
763 /* remove references from array */
764 for (i = 0; i < VISORNICSOPENMAX; i++)
765 if (num_visornic_open[i] == netdev) {
766 num_visornic_open[i] = NULL;
774 * init_rcv_bufs -- initialize receive bufs and send them to the IO Part
775 * @netdev: struct netdevice
776 * @devdata: visornic_devdata
778 * Allocate rcv buffers and post them to the IO Partition.
779 * Return 0 for success, and negative for failure.
782 init_rcv_bufs(struct net_device *netdev, struct visornic_devdata *devdata)
786 /* allocate fixed number of receive buffers to post to uisnic
787 * post receive buffers after we've allocated a required amount
789 for (i = 0; i < devdata->num_rcv_bufs; i++) {
790 devdata->rcvbuf[i] = alloc_rcv_buf(netdev);
791 if (!devdata->rcvbuf[i])
792 break; /* if we failed to allocate one let us stop */
794 if (i == 0) /* couldn't even allocate one -- bail out */
798 /* Ensure we can alloc 2/3rd of the requeested number of buffers.
799 * 2/3 is an arbitrary choice; used also in ndis init.c
801 if (count < ((2 * devdata->num_rcv_bufs) / 3)) {
802 /* free receive buffers we did alloc and then bail out */
803 for (i = 0; i < count; i++) {
804 kfree_skb(devdata->rcvbuf[i]);
805 devdata->rcvbuf[i] = NULL;
810 /* post receive buffers to receive incoming input - without holding
811 * lock - we've not enabled nor started the queue so there shouldn't
812 * be any rcv or xmit activity
814 for (i = 0; i < count; i++)
815 post_skb(devdata->cmdrsp_rcv, devdata, devdata->rcvbuf[i]);
821 * visornic_enable_with_timeout - send enable to IO Part
822 * @netdev: struct net_device
823 * @timeout: Time to wait for the ACK from the enable
825 * Sends enable to IOVM, inits, and posts receive buffers to IOVM
826 * timeout is defined in msecs (timeout of 0 specifies infinite wait)
827 * Return 0 for success, negavite for failure.
830 visornic_enable_with_timeout(struct net_device *netdev, const int timeout)
833 struct visornic_devdata *devdata = netdev_priv(netdev);
837 /* NOTE: the other end automatically unposts the rcv buffers when it
840 i = init_rcv_bufs(netdev, devdata);
842 dev_err(&netdev->dev,
843 "%s failed to init rcv bufs (%d)\n", __func__, i);
847 spin_lock_irqsave(&devdata->priv_lock, flags);
848 devdata->enabled = 1;
850 /* now we're ready, let's send an ENB to uisnic but until we get
851 * an ACK back from uisnic, we'll drop the packets
853 devdata->n_rcv_packets_not_accepted = 0;
854 spin_unlock_irqrestore(&devdata->priv_lock, flags);
856 /* send enable and wait for ack -- don't hold lock when sending enable
857 * because if the queue is full, insert might sleep.
859 send_enbdis(netdev, 1, devdata);
861 spin_lock_irqsave(&devdata->priv_lock, flags);
862 while ((timeout == VISORNIC_INFINITE_RESPONSE_WAIT) ||
864 if (devdata->enab_dis_acked)
866 if (devdata->server_down || devdata->server_change_state) {
867 spin_unlock_irqrestore(&devdata->priv_lock, flags);
868 dev_dbg(&netdev->dev, "%s server went away\n",
872 set_current_state(TASK_INTERRUPTIBLE);
873 spin_unlock_irqrestore(&devdata->priv_lock, flags);
874 wait += schedule_timeout(msecs_to_jiffies(10));
875 spin_lock_irqsave(&devdata->priv_lock, flags);
878 spin_unlock_irqrestore(&devdata->priv_lock, flags);
880 if (!devdata->enab_dis_acked) {
881 dev_err(&netdev->dev, "%s missing ACK\n", __func__);
885 /* find an open slot in the array to save off VisorNic references
888 for (i = 0; i < VISORNICSOPENMAX; i++) {
889 if (!num_visornic_open[i]) {
890 num_visornic_open[i] = netdev;
899 * visornic_timeout_reset - handle xmit timeout resets
900 * @work work item that scheduled the work
902 * Transmit Timeouts are typically handled by resetting the
903 * device for our virtual NIC we will send a Disable and Enable
904 * to the IOVM. If it doesn't respond we will trigger a serverdown.
907 visornic_timeout_reset(struct work_struct *work)
909 struct visornic_devdata *devdata;
910 struct net_device *netdev;
913 devdata = container_of(work, struct visornic_devdata, timeout_reset);
914 netdev = devdata->netdev;
916 netif_stop_queue(netdev);
917 response = visornic_disable_with_timeout(netdev, 100);
919 goto call_serverdown;
921 response = visornic_enable_with_timeout(netdev, 100);
923 goto call_serverdown;
924 netif_wake_queue(netdev);
929 visornic_serverdown(devdata, NULL);
933 * visornic_open - Enable the visornic device and mark the queue started
934 * @netdev: netdevice to start
936 * Enable the device and start the transmit queue.
937 * Return 0 for success
940 visornic_open(struct net_device *netdev)
942 visornic_enable_with_timeout(netdev, VISORNIC_INFINITE_RESPONSE_WAIT);
944 /* start the interface's transmit queue, allowing it to accept
945 * packets for transmission
947 netif_start_queue(netdev);
953 * visornic_close - Disables the visornic device and stops the queues
954 * @netdev: netdevice to start
956 * Disable the device and stop the transmit queue.
957 * Return 0 for success
960 visornic_close(struct net_device *netdev)
962 netif_stop_queue(netdev);
963 visornic_disable_with_timeout(netdev, VISORNIC_INFINITE_RESPONSE_WAIT);
969 * visornic_xmit - send a packet to the IO Partition
970 * @skb: Packet to be sent
971 * @netdev: net device the packet is being sent from
973 * Convert the skb to a cmdrsp so the IO Partition can undersand it.
974 * Send the XMIT command to the IO Partition for processing. This
975 * function is protected from concurrent calls by a spinlock xmit_lock
976 * in the net_device struct, but as soon as the function returns it
977 * can be called again.
978 * Returns NETDEV_TX_OK for success, NETDEV_TX_BUSY for error.
981 visornic_xmit(struct sk_buff *skb, struct net_device *netdev)
983 struct visornic_devdata *devdata;
984 int len, firstfraglen, padlen;
985 struct uiscmdrsp *cmdrsp = NULL;
988 devdata = netdev_priv(netdev);
989 spin_lock_irqsave(&devdata->priv_lock, flags);
991 if (netif_queue_stopped(netdev) || devdata->server_down ||
992 devdata->server_change_state) {
993 spin_unlock_irqrestore(&devdata->priv_lock, flags);
995 dev_dbg(&netdev->dev,
996 "%s busy - queue stopped\n", __func__);
997 return NETDEV_TX_BUSY;
1000 /* sk_buff struct is used to host network data throughout all the
1001 * linux network subsystems
1005 /* skb->len is the FULL length of data (including fragmentary portion)
1006 * skb->data_len is the length of the fragment portion in frags
1007 * skb->len - skb->data_len is size of the 1st fragment in skb->data
1008 * calculate the length of the first fragment that skb->data is
1011 firstfraglen = skb->len - skb->data_len;
1012 if (firstfraglen < ETH_HEADER_SIZE) {
1013 spin_unlock_irqrestore(&devdata->priv_lock, flags);
1014 devdata->busy_cnt++;
1015 dev_err(&netdev->dev,
1016 "%s busy - first frag too small (%d)\n",
1017 __func__, firstfraglen);
1018 return NETDEV_TX_BUSY;
1021 if ((len < ETH_MIN_PACKET_SIZE) &&
1022 ((skb_end_pointer(skb) - skb->data) >= ETH_MIN_PACKET_SIZE)) {
1023 /* pad the packet out to minimum size */
1024 padlen = ETH_MIN_PACKET_SIZE - len;
1025 memset(&skb->data[len], 0, padlen);
1026 skb->tail += padlen;
1029 firstfraglen += padlen;
1032 cmdrsp = devdata->xmit_cmdrsp;
1034 memset(cmdrsp, 0, SIZEOF_CMDRSP);
1035 cmdrsp->net.type = NET_XMIT;
1036 cmdrsp->cmdtype = CMD_NET_TYPE;
1038 /* save the pointer to skb -- we'll need it for completion */
1039 cmdrsp->net.buf = skb;
1041 if (((devdata->chstat.sent_xmit >= devdata->chstat.got_xmit_done) &&
1042 (devdata->chstat.sent_xmit - devdata->chstat.got_xmit_done >=
1043 devdata->max_outstanding_net_xmits)) ||
1044 ((devdata->chstat.sent_xmit < devdata->chstat.got_xmit_done) &&
1045 (ULONG_MAX - devdata->chstat.got_xmit_done +
1046 devdata->chstat.sent_xmit >=
1047 devdata->max_outstanding_net_xmits))) {
1048 /* too many NET_XMITs queued over to IOVM - need to wait
1050 devdata->chstat.reject_count++;
1051 if (!devdata->queuefullmsg_logged &&
1052 ((devdata->chstat.reject_count & 0x3ff) == 1))
1053 devdata->queuefullmsg_logged = 1;
1054 netif_stop_queue(netdev);
1055 spin_unlock_irqrestore(&devdata->priv_lock, flags);
1056 devdata->busy_cnt++;
1057 dev_dbg(&netdev->dev,
1058 "%s busy - waiting for iovm to catch up\n",
1060 return NETDEV_TX_BUSY;
1062 if (devdata->queuefullmsg_logged)
1063 devdata->queuefullmsg_logged = 0;
1065 if (skb->ip_summed == CHECKSUM_UNNECESSARY) {
1066 cmdrsp->net.xmt.lincsum.valid = 1;
1067 cmdrsp->net.xmt.lincsum.protocol = skb->protocol;
1068 if (skb_transport_header(skb) > skb->data) {
1069 cmdrsp->net.xmt.lincsum.hrawoff =
1070 skb_transport_header(skb) - skb->data;
1071 cmdrsp->net.xmt.lincsum.hrawoff = 1;
1073 if (skb_network_header(skb) > skb->data) {
1074 cmdrsp->net.xmt.lincsum.nhrawoff =
1075 skb_network_header(skb) - skb->data;
1076 cmdrsp->net.xmt.lincsum.nhrawoffv = 1;
1078 cmdrsp->net.xmt.lincsum.csum = skb->csum;
1080 cmdrsp->net.xmt.lincsum.valid = 0;
1083 /* save off the length of the entire data packet */
1084 cmdrsp->net.xmt.len = len;
1086 /* copy ethernet header from first frag into ocmdrsp
1087 * - everything else will be pass in frags & DMA'ed
1089 memcpy(cmdrsp->net.xmt.ethhdr, skb->data, ETH_HEADER_SIZE);
1090 /* copy frags info - from skb->data we need to only provide access
1093 cmdrsp->net.xmt.num_frags =
1094 visor_copy_fragsinfo_from_skb(skb, firstfraglen,
1096 cmdrsp->net.xmt.frags);
1097 if (cmdrsp->net.xmt.num_frags == -1) {
1098 spin_unlock_irqrestore(&devdata->priv_lock, flags);
1099 devdata->busy_cnt++;
1100 dev_err(&netdev->dev,
1101 "%s busy - copy frags failed\n", __func__);
1102 return NETDEV_TX_BUSY;
1105 if (!visorchannel_signalinsert(devdata->dev->visorchannel,
1106 IOCHAN_TO_IOPART, cmdrsp)) {
1107 netif_stop_queue(netdev);
1108 spin_unlock_irqrestore(&devdata->priv_lock, flags);
1109 devdata->busy_cnt++;
1110 dev_dbg(&netdev->dev,
1111 "%s busy - signalinsert failed\n", __func__);
1112 return NETDEV_TX_BUSY;
1115 /* Track the skbs that have been sent to the IOVM for XMIT */
1116 skb_queue_head(&devdata->xmitbufhead, skb);
1118 /* set the last transmission start time
1119 * linux doc says: Do not forget to update netdev->trans_start to
1120 * jiffies after each new tx packet is given to the hardware.
1122 netdev->trans_start = jiffies;
1124 /* update xmt stats */
1125 devdata->net_stats.tx_packets++;
1126 devdata->net_stats.tx_bytes += skb->len;
1127 devdata->chstat.sent_xmit++;
1129 /* check to see if we have hit the high watermark for
1130 * netif_stop_queue()
1132 if (((devdata->chstat.sent_xmit >= devdata->chstat.got_xmit_done) &&
1133 (devdata->chstat.sent_xmit - devdata->chstat.got_xmit_done >=
1134 devdata->upper_threshold_net_xmits)) ||
1135 ((devdata->chstat.sent_xmit < devdata->chstat.got_xmit_done) &&
1136 (ULONG_MAX - devdata->chstat.got_xmit_done +
1137 devdata->chstat.sent_xmit >=
1138 devdata->upper_threshold_net_xmits))) {
1139 /* too many NET_XMITs queued over to IOVM - need to wait */
1140 netif_stop_queue(netdev); /* calling stop queue - call
1141 * netif_wake_queue() after lower
1144 dev_dbg(&netdev->dev,
1145 "%s busy - invoking iovm flow control\n",
1147 devdata->flow_control_upper_hits++;
1149 spin_unlock_irqrestore(&devdata->priv_lock, flags);
1151 /* skb will be freed when we get back NET_XMIT_DONE */
1152 return NETDEV_TX_OK;
1156 * visornic_get_stats - returns net_stats of the visornic device
1157 * @netdev: netdevice
1159 * Returns the net_device_stats for the device
1161 static struct net_device_stats *
1162 visornic_get_stats(struct net_device *netdev)
1164 struct visornic_devdata *devdata = netdev_priv(netdev);
1166 return &devdata->net_stats;
1170 * visornic_ioctl - ioctl function for netdevice.
1171 * @netdev: netdevice
1175 * Currently not supported.
1176 * Returns EOPNOTSUPP
1179 visornic_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
1185 * visornic_change_mtu - changes mtu of device.
1186 * @netdev: netdevice
1187 * @new_mtu: value of new mtu
1189 * MTU cannot be changed by system, must be changed via
1190 * CONTROLVM message. All vnics and pnics in a switch have
1191 * to have the same MTU for everything to work.
1192 * Currently not supported.
1196 visornic_change_mtu(struct net_device *netdev, int new_mtu)
1202 * visornic_set_multi - changes mtu of device.
1203 * @netdev: netdevice
1205 * Only flag we support currently is IFF_PROMISC
1209 visornic_set_multi(struct net_device *netdev)
1211 struct uiscmdrsp *cmdrsp;
1212 struct visornic_devdata *devdata = netdev_priv(netdev);
1214 /* any filtering changes */
1215 if (devdata->old_flags != netdev->flags) {
1216 if ((netdev->flags & IFF_PROMISC) !=
1217 (devdata->old_flags & IFF_PROMISC)) {
1218 cmdrsp = kmalloc(SIZEOF_CMDRSP, GFP_ATOMIC);
1221 cmdrsp->cmdtype = CMD_NET_TYPE;
1222 cmdrsp->net.type = NET_RCV_PROMISC;
1223 cmdrsp->net.enbdis.context = netdev;
1224 cmdrsp->net.enbdis.enable =
1225 (netdev->flags & IFF_PROMISC);
1226 visorchannel_signalinsert(devdata->dev->visorchannel,
1231 devdata->old_flags = netdev->flags;
1236 * visornic_xmit_timeout - request to timeout the xmit
1239 * Queue the work and return. Make sure we have not already
1240 * been informed the IO Partition is gone, if it is gone
1241 * we will already timeout the xmits.
1244 visornic_xmit_timeout(struct net_device *netdev)
1246 struct visornic_devdata *devdata = netdev_priv(netdev);
1247 unsigned long flags;
1249 spin_lock_irqsave(&devdata->priv_lock, flags);
1250 if (devdata->going_away) {
1251 spin_unlock_irqrestore(&devdata->priv_lock, flags);
1252 dev_dbg(&devdata->dev->device,
1253 "%s aborting because device removal pending\n",
1258 /* Ensure that a ServerDown message hasn't been received */
1259 if (!devdata->enabled ||
1260 (devdata->server_down && !devdata->server_change_state)) {
1261 dev_dbg(&netdev->dev, "%s no processing\n",
1263 spin_unlock_irqrestore(&devdata->priv_lock, flags);
1266 queue_work(visornic_timeout_reset_workqueue, &devdata->timeout_reset);
1267 spin_unlock_irqrestore(&devdata->priv_lock, flags);
1271 * repost_return - repost rcv bufs that have come back
1272 * @cmdrsp: io channel command struct to post
1273 * @devdata: visornic devdata for the device
1275 * @netdev: netdevice
1277 * Repost rcv buffers that have been returned to us when
1278 * we are finished with them.
1279 * Returns 0 for success, -1 for error.
1282 repost_return(struct uiscmdrsp *cmdrsp, struct visornic_devdata *devdata,
1283 struct sk_buff *skb, struct net_device *netdev)
1285 struct net_pkt_rcv copy;
1286 int i = 0, cc, numreposted;
1290 copy = cmdrsp->net.rcv;
1291 switch (copy.numrcvbufs) {
1305 for (cc = 0, numreposted = 0; cc < copy.numrcvbufs; cc++) {
1306 for (i = 0; i < devdata->num_rcv_bufs; i++) {
1307 if (devdata->rcvbuf[i] != copy.rcvbuf[cc])
1310 if ((skb) && devdata->rcvbuf[i] == skb) {
1311 devdata->found_repost_rcvbuf_cnt++;
1313 devdata->repost_found_skb_cnt++;
1315 devdata->rcvbuf[i] = alloc_rcv_buf(netdev);
1316 if (!devdata->rcvbuf[i]) {
1317 devdata->num_rcv_bufs_could_not_alloc++;
1318 devdata->alloc_failed_in_repost_rtn_cnt++;
1322 post_skb(cmdrsp, devdata, devdata->rcvbuf[i]);
1327 if (numreposted != copy.numrcvbufs) {
1328 devdata->n_repost_deficit++;
1336 devdata->bad_rcv_buf++;
1339 atomic_dec(&devdata->usage);
1344 * visornic_rx - Handle receive packets coming back from IO Part
1345 * @cmdrsp: Receive packet returned from IO Part
1347 * Got a receive packet back from the IO Part, handle it and send
1352 visornic_rx(struct uiscmdrsp *cmdrsp)
1354 struct visornic_devdata *devdata;
1355 struct sk_buff *skb, *prev, *curr;
1356 struct net_device *netdev;
1357 int cc, currsize, off, status;
1359 unsigned long flags;
1361 struct phys_info testfrags[MAX_PHYS_INFO];
1364 /* post new rcv buf to the other end using the cmdrsp we have at hand
1365 * post it without holding lock - but we'll use the signal lock to
1366 * synchronize the queue insert the cmdrsp that contains the net.rcv
1367 * is the one we are using to repost, so copy the info we need from it.
1369 skb = cmdrsp->net.buf;
1373 /* We must have previously downed this network device and
1374 * this skb and device is no longer valid. This also means
1375 * the skb reference was removed from devdata->rcvbuf so no
1376 * need to search for it.
1377 * All we can do is free the skb and return.
1378 * Note: We crash if we try to log this here.
1384 devdata = netdev_priv(netdev);
1386 spin_lock_irqsave(&devdata->priv_lock, flags);
1387 atomic_dec(&devdata->num_rcvbuf_in_iovm);
1389 /* update rcv stats - call it with priv_lock held */
1390 devdata->net_stats.rx_packets++;
1391 devdata->net_stats.rx_bytes = skb->len;
1393 atomic_inc(&devdata->usage); /* don't want a close to happen before
1397 /* set length to how much was ACTUALLY received -
1398 * NOTE: rcv_done_len includes actual length of data rcvd
1401 skb->len = cmdrsp->net.rcv.rcv_done_len;
1403 /* test enabled while holding lock */
1404 if (!(devdata->enabled && devdata->enab_dis_acked)) {
1405 /* don't process it unless we're in enable mode and until
1406 * we've gotten an ACK saying the other end got our RCV enable
1408 spin_unlock_irqrestore(&devdata->priv_lock, flags);
1409 repost_return(cmdrsp, devdata, skb, netdev);
1413 spin_unlock_irqrestore(&devdata->priv_lock, flags);
1415 /* when skb was allocated, skb->dev, skb->data, skb->len and
1416 * skb->data_len were setup. AND, data has already put into the
1417 * skb (both first frag and in frags pages)
1418 * NOTE: firstfragslen is the amount of data in skb->data and that
1419 * which is not in nr_frags or frag_list. This is now simply
1420 * RCVPOST_BUF_SIZE. bump tail to show how much data is in
1421 * firstfrag & set data_len to show rest see if we have to chain
1424 if (skb->len > RCVPOST_BUF_SIZE) { /* do PRECAUTIONARY check */
1425 if (cmdrsp->net.rcv.numrcvbufs < 2) {
1426 if (repost_return(cmdrsp, devdata, skb, netdev) < 0)
1427 dev_err(&devdata->netdev->dev,
1428 "repost_return failed");
1431 /* length rcvd is greater than firstfrag in this skb rcv buf */
1432 skb->tail += RCVPOST_BUF_SIZE; /* amount in skb->data */
1433 skb->data_len = skb->len - RCVPOST_BUF_SIZE; /* amount that
1437 /* data fits in this skb - no chaining - do
1438 * PRECAUTIONARY check
1440 if (cmdrsp->net.rcv.numrcvbufs != 1) { /* should be 1 */
1441 if (repost_return(cmdrsp, devdata, skb, netdev) < 0)
1442 dev_err(&devdata->netdev->dev,
1443 "repost_return failed");
1446 skb->tail += skb->len;
1447 skb->data_len = 0; /* nothing rcvd in frag_list */
1449 off = skb_tail_pointer(skb) - skb->data;
1451 /* amount we bumped tail by in the head skb
1452 * it is used to calculate the size of each chained skb below
1453 * it is also used to index into bufline to continue the copy
1454 * (for chansocktwopc)
1455 * if necessary chain the rcv skbs together.
1456 * NOTE: index 0 has the same as cmdrsp->net.rcv.skb; we need to
1457 * chain the rest to that one.
1458 * - do PRECAUTIONARY check
1460 if (cmdrsp->net.rcv.rcvbuf[0] != skb) {
1461 if (repost_return(cmdrsp, devdata, skb, netdev) < 0)
1462 dev_err(&devdata->netdev->dev, "repost_return failed");
1466 if (cmdrsp->net.rcv.numrcvbufs > 1) {
1467 /* chain the various rcv buffers into the skb's frag_list. */
1468 /* Note: off was initialized above */
1469 for (cc = 1, prev = NULL;
1470 cc < cmdrsp->net.rcv.numrcvbufs; cc++) {
1471 curr = (struct sk_buff *)cmdrsp->net.rcv.rcvbuf[cc];
1473 if (!prev) /* start of list- set head */
1474 skb_shinfo(skb)->frag_list = curr;
1479 /* should we set skb->len and skb->data_len for each
1480 * buffer being chained??? can't hurt!
1482 currsize = min(skb->len - off,
1483 (unsigned int)RCVPOST_BUF_SIZE);
1484 curr->len = currsize;
1485 curr->tail += currsize;
1490 /* assert skb->len == off */
1491 if (skb->len != off) {
1492 dev_err(&devdata->netdev->dev,
1493 "%s something wrong; skb->len:%d != off:%d\n",
1494 netdev->name, skb->len, off);
1497 cc = util_copy_fragsinfo_from_skb("rcvchaintest", skb,
1499 MAX_PHYS_INFO, testfrags);
1500 if (cc != cmdrsp->net.rcv.numrcvbufs) {
1501 dev_err(&devdata->netdev->dev,
1502 "**** %s Something wrong; rcvd chain length %d different from one we calculated %d\n",
1503 netdev->name, cmdrsp->net.rcv.numrcvbufs, cc);
1505 for (i = 0; i < cc; i++) {
1506 dev_inf(&devdata->netdev->dev,
1507 "test:RCVPOST_BUF_SIZE:%d[%d] pfn:%llu off:0x%x len:%d\n",
1508 RCVPOST_BUF_SIZE, i, testfrags[i].pi_pfn,
1509 testfrags[i].pi_off, testfrags[i].pi_len);
1514 /* set up packet's protocl type using ethernet header - this
1515 * sets up skb->pkt_type & it also PULLS out the eth header
1517 skb->protocol = eth_type_trans(skb, netdev);
1522 skb->ip_summed = CHECKSUM_NONE;
1525 if (netdev->flags & IFF_PROMISC)
1526 break; /* accept all packets */
1527 if (skb->pkt_type == PACKET_BROADCAST) {
1528 if (netdev->flags & IFF_BROADCAST)
1529 break; /* accept all broadcast packets */
1530 } else if (skb->pkt_type == PACKET_MULTICAST) {
1531 if ((netdev->flags & IFF_MULTICAST) &&
1532 (netdev_mc_count(netdev))) {
1533 struct netdev_hw_addr *ha;
1536 /* only accept multicast packets that we can
1537 * find in our multicast address list
1539 netdev_for_each_mc_addr(ha, netdev) {
1540 if (ether_addr_equal(eth->h_dest,
1547 break; /* accept packet, dest
1551 } else if (skb->pkt_type == PACKET_HOST) {
1552 break; /* accept packet, h_dest must match vnic
1554 } else if (skb->pkt_type == PACKET_OTHERHOST) {
1555 /* something is not right */
1556 dev_err(&devdata->netdev->dev,
1557 "**** FAILED to deliver rcv packet to OS; name:%s Dest:%pM VNIC:%pM\n",
1558 netdev->name, eth->h_dest, netdev->dev_addr);
1560 /* drop packet - don't forward it up to OS */
1561 devdata->n_rcv_packets_not_accepted++;
1562 repost_return(cmdrsp, devdata, skb, netdev);
1566 status = netif_rx(skb);
1567 /* netif_rx returns various values, but "in practice most drivers
1568 * ignore the return value
1573 * whether the packet got dropped or handled, the skb is freed by
1574 * kernel code, so we shouldn't free it. but we should repost a
1577 repost_return(cmdrsp, devdata, skb, netdev);
1581 * devdata_initialize - Initialize devdata structure
1582 * @devdata: visornic_devdata structure to initialize
1583 * #dev: visorbus_deviced it belongs to
1585 * Setup initial values for the visornic based on channel and default
1587 * Returns a pointer to the devdata if successful, else NULL
1589 static struct visornic_devdata *
1590 devdata_initialize(struct visornic_devdata *devdata, struct visor_device *dev)
1596 memset(devdata, '\0', sizeof(struct visornic_devdata));
1597 spin_lock(&dev_num_pool_lock);
1598 devnum = find_first_zero_bit(dev_num_pool, MAXDEVICES);
1599 set_bit(devnum, dev_num_pool);
1600 spin_unlock(&dev_num_pool_lock);
1601 if (devnum == MAXDEVICES)
1605 devdata->devnum = devnum;
1607 strncpy(devdata->name, dev_name(&dev->device), sizeof(devdata->name));
1608 spin_lock(&lock_all_devices);
1609 list_add_tail(&devdata->list_all, &list_all_devices);
1610 spin_unlock(&lock_all_devices);
1615 * devdata_release - Frees up references in devdata
1616 * @devdata: struct to clean up
1618 * Frees up references in devdata.
1621 static void devdata_release(struct visornic_devdata *devdata)
1623 spin_lock(&dev_num_pool_lock);
1624 clear_bit(devdata->devnum, dev_num_pool);
1625 spin_unlock(&dev_num_pool_lock);
1626 spin_lock(&lock_all_devices);
1627 list_del(&devdata->list_all);
1628 spin_unlock(&lock_all_devices);
1629 kfree(devdata->rcvbuf);
1630 kfree(devdata->cmdrsp_rcv);
1631 kfree(devdata->xmit_cmdrsp);
1634 static const struct net_device_ops visornic_dev_ops = {
1635 .ndo_open = visornic_open,
1636 .ndo_stop = visornic_close,
1637 .ndo_start_xmit = visornic_xmit,
1638 .ndo_get_stats = visornic_get_stats,
1639 .ndo_do_ioctl = visornic_ioctl,
1640 .ndo_change_mtu = visornic_change_mtu,
1641 .ndo_tx_timeout = visornic_xmit_timeout,
1642 .ndo_set_rx_mode = visornic_set_multi,
1646 * send_rcv_posts_if_needed
1647 * @devdata: visornic device
1649 * Send receive buffers to the IO Partition.
1653 send_rcv_posts_if_needed(struct visornic_devdata *devdata)
1656 struct net_device *netdev;
1657 struct uiscmdrsp *cmdrsp = devdata->cmdrsp_rcv;
1658 int cur_num_rcv_bufs_to_alloc, rcv_bufs_allocated;
1660 /* don't do this until vnic is marked ready */
1661 if (!(devdata->enabled && devdata->enab_dis_acked))
1664 netdev = devdata->netdev;
1665 rcv_bufs_allocated = 0;
1666 /* this code is trying to prevent getting stuck here forever,
1667 * but still retry it if you cant allocate them all this time.
1669 cur_num_rcv_bufs_to_alloc = devdata->num_rcv_bufs_could_not_alloc;
1670 while (cur_num_rcv_bufs_to_alloc > 0) {
1671 cur_num_rcv_bufs_to_alloc--;
1672 for (i = 0; i < devdata->num_rcv_bufs; i++) {
1673 if (devdata->rcvbuf[i])
1675 devdata->rcvbuf[i] = alloc_rcv_buf(netdev);
1676 if (!devdata->rcvbuf[i]) {
1677 devdata->alloc_failed_in_if_needed_cnt++;
1680 rcv_bufs_allocated++;
1681 post_skb(cmdrsp, devdata, devdata->rcvbuf[i]);
1682 devdata->chstat.extra_rcvbufs_sent++;
1685 devdata->num_rcv_bufs_could_not_alloc -= rcv_bufs_allocated;
1689 * draing_queue - drains the response queue
1690 * @cmdrsp: io channel command response message
1691 * @devdata: visornic device to drain
1693 * Drain the respones queue of any responses from the IO partition.
1694 * Process the responses as we get them.
1695 * Returns when response queue is empty or when the threadd stops.
1698 drain_queue(struct uiscmdrsp *cmdrsp, struct visornic_devdata *devdata)
1700 unsigned long flags;
1701 struct net_device *netdev;
1705 /* TODO: CLIENT ACQUIRE -- Don't really need this at the
1707 if (!visorchannel_signalremove(devdata->dev->visorchannel,
1710 break; /* queue empty */
1712 switch (cmdrsp->net.type) {
1714 devdata->chstat.got_rcv++;
1715 /* process incoming packet */
1716 visornic_rx(cmdrsp);
1719 spin_lock_irqsave(&devdata->priv_lock, flags);
1720 devdata->chstat.got_xmit_done++;
1721 if (cmdrsp->net.xmtdone.xmt_done_result)
1722 devdata->chstat.xmit_fail++;
1723 /* only call queue wake if we stopped it */
1724 netdev = ((struct sk_buff *)cmdrsp->net.buf)->dev;
1725 /* ASSERT netdev == vnicinfo->netdev; */
1726 if ((netdev == devdata->netdev) &&
1727 netif_queue_stopped(netdev)) {
1728 /* check to see if we have crossed
1729 * the lower watermark for
1730 * netif_wake_queue()
1732 if (((devdata->chstat.sent_xmit >=
1733 devdata->chstat.got_xmit_done) &&
1734 (devdata->chstat.sent_xmit -
1735 devdata->chstat.got_xmit_done <=
1736 devdata->lower_threshold_net_xmits)) ||
1737 ((devdata->chstat.sent_xmit <
1738 devdata->chstat.got_xmit_done) &&
1739 (ULONG_MAX - devdata->chstat.got_xmit_done
1740 + devdata->chstat.sent_xmit <=
1741 devdata->lower_threshold_net_xmits))) {
1742 /* enough NET_XMITs completed
1743 * so can restart netif queue
1745 netif_wake_queue(netdev);
1746 devdata->flow_control_lower_hits++;
1749 skb_unlink(cmdrsp->net.buf, &devdata->xmitbufhead);
1750 spin_unlock_irqrestore(&devdata->priv_lock, flags);
1751 kfree_skb(cmdrsp->net.buf);
1753 case NET_RCV_ENBDIS_ACK:
1754 devdata->chstat.got_enbdisack++;
1755 netdev = (struct net_device *)
1756 cmdrsp->net.enbdis.context;
1757 spin_lock_irqsave(&devdata->priv_lock, flags);
1758 devdata->enab_dis_acked = 1;
1759 spin_unlock_irqrestore(&devdata->priv_lock, flags);
1761 if (devdata->server_down &&
1762 devdata->server_change_state) {
1763 /* Inform Linux that the link is up */
1764 devdata->server_down = false;
1765 devdata->server_change_state = false;
1766 netif_wake_queue(netdev);
1767 netif_carrier_on(netdev);
1770 case NET_CONNECT_STATUS:
1771 netdev = devdata->netdev;
1772 if (cmdrsp->net.enbdis.enable == 1) {
1773 spin_lock_irqsave(&devdata->priv_lock, flags);
1774 devdata->enabled = cmdrsp->net.enbdis.enable;
1775 spin_unlock_irqrestore(&devdata->priv_lock,
1777 netif_wake_queue(netdev);
1778 netif_carrier_on(netdev);
1780 netif_stop_queue(netdev);
1781 netif_carrier_off(netdev);
1782 spin_lock_irqsave(&devdata->priv_lock, flags);
1783 devdata->enabled = cmdrsp->net.enbdis.enable;
1784 spin_unlock_irqrestore(&devdata->priv_lock,
1791 /* cmdrsp is now available for reuse */
1793 if (kthread_should_stop())
1799 * process_incoming_rsps - Checks the status of the response queue.
1800 * @v: void pointer to the visronic devdata
1802 * Main function of the vnic_incoming thread. Peridocially check the
1803 * response queue and drain it if needed.
1804 * Returns when thread has stopped.
1807 process_incoming_rsps(void *v)
1809 struct visornic_devdata *devdata = v;
1810 struct uiscmdrsp *cmdrsp = NULL;
1811 const int SZ = SIZEOF_CMDRSP;
1813 cmdrsp = kmalloc(SZ, GFP_ATOMIC);
1815 complete_and_exit(&devdata->threadinfo.has_stopped, 0);
1818 wait_event_interruptible_timeout(
1819 devdata->rsp_queue, (atomic_read(
1820 &devdata->interrupt_rcvd) == 1),
1821 msecs_to_jiffies(devdata->thread_wait_ms));
1823 /* periodically check to see if there are any rcf bufs which
1824 * need to get sent to the IOSP. This can only happen if
1825 * we run out of memory when trying to allocate skbs.
1827 atomic_set(&devdata->interrupt_rcvd, 0);
1828 send_rcv_posts_if_needed(devdata);
1829 drain_queue(cmdrsp, devdata);
1830 if (kthread_should_stop())
1835 complete_and_exit(&devdata->threadinfo.has_stopped, 0);
1839 * visornic_probe - probe function for visornic devices
1840 * @dev: The visor device discovered
1842 * Called when visorbus discovers a visornic device on its
1843 * bus. It creates a new visornic ethernet adapter.
1844 * Returns 0 or negative for error.
1846 static int visornic_probe(struct visor_device *dev)
1848 struct visornic_devdata *devdata = NULL;
1849 struct net_device *netdev = NULL;
1851 int channel_offset = 0;
1854 netdev = alloc_etherdev(sizeof(struct visornic_devdata));
1856 dev_err(&dev->device,
1857 "%s alloc_etherdev failed\n", __func__);
1861 netdev->netdev_ops = &visornic_dev_ops;
1862 netdev->watchdog_timeo = (5 * HZ);
1863 SET_NETDEV_DEV(netdev, &dev->device);
1865 /* Get MAC adddress from channel and read it into the device. */
1866 netdev->addr_len = ETH_ALEN;
1867 channel_offset = offsetof(struct spar_io_channel_protocol,
1869 err = visorbus_read_channel(dev, channel_offset, netdev->dev_addr,
1872 dev_err(&dev->device,
1873 "%s failed to get mac addr from chan (%d)\n",
1875 goto cleanup_netdev;
1878 devdata = devdata_initialize(netdev_priv(netdev), dev);
1880 dev_err(&dev->device,
1881 "%s devdata_initialize failed\n", __func__);
1883 goto cleanup_netdev;
1886 devdata->netdev = netdev;
1887 dev_set_drvdata(&dev->device, devdata);
1888 init_waitqueue_head(&devdata->rsp_queue);
1889 spin_lock_init(&devdata->priv_lock);
1890 devdata->enabled = 0; /* not yet */
1891 atomic_set(&devdata->usage, 1);
1893 /* Setup rcv bufs */
1894 channel_offset = offsetof(struct spar_io_channel_protocol,
1896 err = visorbus_read_channel(dev, channel_offset,
1897 &devdata->num_rcv_bufs, 4);
1899 dev_err(&dev->device,
1900 "%s failed to get #rcv bufs from chan (%d)\n",
1902 goto cleanup_netdev;
1905 devdata->rcvbuf = kzalloc(sizeof(struct sk_buff *) *
1906 devdata->num_rcv_bufs, GFP_KERNEL);
1907 if (!devdata->rcvbuf) {
1909 goto cleanup_rcvbuf;
1912 /* set the net_xmit outstanding threshold */
1913 /* always leave two slots open but you should have 3 at a minimum */
1914 devdata->max_outstanding_net_xmits =
1915 max(3, ((devdata->num_rcv_bufs / 3) - 2));
1916 devdata->upper_threshold_net_xmits =
1917 max(2, devdata->max_outstanding_net_xmits - 1);
1918 devdata->lower_threshold_net_xmits =
1919 max(1, devdata->max_outstanding_net_xmits / 2);
1921 skb_queue_head_init(&devdata->xmitbufhead);
1923 /* create a cmdrsp we can use to post and unpost rcv buffers */
1924 devdata->cmdrsp_rcv = kmalloc(SIZEOF_CMDRSP, GFP_ATOMIC);
1925 if (!devdata->cmdrsp_rcv) {
1927 goto cleanup_cmdrsp_rcv;
1929 devdata->xmit_cmdrsp = kmalloc(SIZEOF_CMDRSP, GFP_ATOMIC);
1930 if (!devdata->xmit_cmdrsp) {
1932 goto cleanup_xmit_cmdrsp;
1934 INIT_WORK(&devdata->serverdown_completion,
1935 visornic_serverdown_complete);
1936 INIT_WORK(&devdata->timeout_reset, visornic_timeout_reset);
1937 devdata->server_down = false;
1938 devdata->server_change_state = false;
1940 /*set the default mtu */
1941 channel_offset = offsetof(struct spar_io_channel_protocol,
1943 err = visorbus_read_channel(dev, channel_offset, &netdev->mtu, 4);
1945 dev_err(&dev->device,
1946 "%s failed to get mtu from chan (%d)\n",
1948 goto cleanup_xmit_cmdrsp;
1951 /* TODO: Setup Interrupt information */
1952 /* Let's start our threads to get responses */
1953 channel_offset = offsetof(struct spar_io_channel_protocol,
1954 channel_header.features);
1955 err = visorbus_read_channel(dev, channel_offset, &features, 8);
1957 dev_err(&dev->device,
1958 "%s failed to get features from chan (%d)\n",
1960 goto cleanup_xmit_cmdrsp;
1963 features |= ULTRA_IO_CHANNEL_IS_POLLING;
1964 err = visorbus_write_channel(dev, channel_offset, &features, 8);
1966 dev_err(&dev->device,
1967 "%s failed to set features in chan (%d)\n",
1969 goto cleanup_xmit_cmdrsp;
1972 err = register_netdev(netdev);
1974 dev_err(&dev->device,
1975 "%s register_netdev failed (%d)\n", __func__, err);
1976 goto cleanup_xmit_cmdrsp;
1979 /* create debgug/sysfs directories */
1980 devdata->eth_debugfs_dir = debugfs_create_dir(netdev->name,
1981 visornic_debugfs_dir);
1982 if (!devdata->eth_debugfs_dir) {
1983 dev_err(&dev->device,
1984 "%s debugfs_create_dir %s failed\n",
1985 __func__, netdev->name);
1987 goto cleanup_xmit_cmdrsp;
1990 devdata->thread_wait_ms = 2;
1991 visor_thread_start(&devdata->threadinfo, process_incoming_rsps,
1992 devdata, "vnic_incoming");
1994 dev_info(&dev->device, "%s success netdev=%s\n",
1995 __func__, netdev->name);
1998 cleanup_xmit_cmdrsp:
1999 kfree(devdata->xmit_cmdrsp);
2002 kfree(devdata->cmdrsp_rcv);
2005 kfree(devdata->rcvbuf);
2008 free_netdev(netdev);
2013 * host_side_disappeared - IO part is gone.
2014 * @devdata: device object
2016 * IO partition servicing this device is gone, do cleanup
2019 static void host_side_disappeared(struct visornic_devdata *devdata)
2021 unsigned long flags;
2023 spin_lock_irqsave(&devdata->priv_lock, flags);
2024 sprintf(devdata->name, "<dev#%d-history>", devdata->devnum);
2025 devdata->dev = NULL; /* indicate device destroyed */
2026 spin_unlock_irqrestore(&devdata->priv_lock, flags);
2030 * visornic_remove - Called when visornic dev goes away
2031 * @dev: visornic device that is being removed
2033 * Called when DEVICE_DESTROY gets called to remove device.
2036 static void visornic_remove(struct visor_device *dev)
2038 struct visornic_devdata *devdata = dev_get_drvdata(&dev->device);
2039 struct net_device *netdev;
2040 unsigned long flags;
2043 dev_err(&dev->device, "%s no devdata\n", __func__);
2046 spin_lock_irqsave(&devdata->priv_lock, flags);
2047 if (devdata->going_away) {
2048 spin_unlock_irqrestore(&devdata->priv_lock, flags);
2049 dev_err(&dev->device, "%s already being removed\n", __func__);
2052 devdata->going_away = true;
2053 spin_unlock_irqrestore(&devdata->priv_lock, flags);
2054 netdev = devdata->netdev;
2056 dev_err(&dev->device, "%s not net device\n", __func__);
2060 /* going_away prevents new items being added to the workqueues */
2061 flush_workqueue(visornic_serverdown_workqueue);
2062 flush_workqueue(visornic_timeout_reset_workqueue);
2064 debugfs_remove_recursive(devdata->eth_debugfs_dir);
2066 unregister_netdev(netdev); /* this will call visornic_close() */
2068 /* this had to wait until last because visornic_close() /
2069 * visornic_disable_with_timeout() polls waiting for state that is
2070 * only updated by the thread
2072 if (devdata->threadinfo.id) {
2073 visor_thread_stop(&devdata->threadinfo);
2074 if (devdata->threadinfo.id) {
2075 dev_err(&dev->device, "%s cannot stop worker thread\n",
2081 dev_set_drvdata(&dev->device, NULL);
2082 host_side_disappeared(devdata);
2083 devdata_release(devdata);
2084 free_netdev(netdev);
2088 * visornic_pause - Called when IO Part disappears
2089 * @dev: visornic device that is being serviced
2090 * @complete_func: call when finished.
2092 * Called when the IO Partition has gone down. Need to free
2093 * up resources and wait for IO partition to come back. Mark
2094 * link as down and don't attempt any DMA. When we have freed
2095 * memory call the complete_func so that Command knows we are
2096 * done. If we don't call complete_func, IO part will never
2098 * Returns 0 for success.
2100 static int visornic_pause(struct visor_device *dev,
2101 visorbus_state_complete_func complete_func)
2103 struct visornic_devdata *devdata = dev_get_drvdata(&dev->device);
2105 visornic_serverdown(devdata, complete_func);
2110 * visornic_resume - Called when IO part has recovered
2111 * @dev: visornic device that is being serviced
2112 * @compelte_func: call when finished
2114 * Called when the IO partition has recovered. Reestablish
2115 * connection to the IO part and set the link up. Okay to do
2117 * Returns 0 for success.
2119 static int visornic_resume(struct visor_device *dev,
2120 visorbus_state_complete_func complete_func)
2122 struct visornic_devdata *devdata;
2123 struct net_device *netdev;
2124 unsigned long flags;
2126 devdata = dev_get_drvdata(&dev->device);
2128 dev_err(&dev->device, "%s no devdata\n", __func__);
2132 netdev = devdata->netdev;
2134 if (devdata->server_down && !devdata->server_change_state) {
2135 devdata->server_change_state = true;
2136 /* Must transition channel to ATTACHED state BEFORE
2137 * we can start using the device again.
2138 * TODO: State transitions
2140 visor_thread_start(&devdata->threadinfo, process_incoming_rsps,
2141 devdata, "vnic_incoming");
2142 init_rcv_bufs(netdev, devdata);
2143 spin_lock_irqsave(&devdata->priv_lock, flags);
2144 devdata->enabled = 1;
2146 /* Now we're ready, let's send an ENB to uisnic but until
2147 * we get an ACK back from uisnic, we'll drop the packets
2149 devdata->enab_dis_acked = 0;
2150 spin_unlock_irqrestore(&devdata->priv_lock, flags);
2152 /* send enable and wait for ack - don't hold lock when
2153 * sending enable because if the queue if sull, insert
2156 send_enbdis(netdev, 1, devdata);
2157 } else if (devdata->server_change_state) {
2158 dev_err(&dev->device, "%s server_change_state\n",
2163 complete_func(dev, 0);
2168 * visornic_init - Init function
2170 * Init function for the visornic driver. Do initial driver setup
2171 * and wait for devices.
2172 * Returns 0 for success, negative for error.
2174 static int visornic_init(void)
2179 visornic_debugfs_dir = debugfs_create_dir("visornic", NULL);
2180 if (!visornic_debugfs_dir)
2183 ret = debugfs_create_file("info", S_IRUSR, visornic_debugfs_dir, NULL,
2184 &debugfs_info_fops);
2186 goto cleanup_debugfs;
2187 ret = debugfs_create_file("enable_ints", S_IWUSR, visornic_debugfs_dir,
2188 NULL, &debugfs_enable_ints_fops);
2190 goto cleanup_debugfs;
2192 /* create workqueue for serverdown completion */
2193 visornic_serverdown_workqueue =
2194 create_singlethread_workqueue("visornic_serverdown");
2195 if (!visornic_serverdown_workqueue)
2196 goto cleanup_debugfs;
2198 /* create workqueue for tx timeout reset */
2199 visornic_timeout_reset_workqueue =
2200 create_singlethread_workqueue("visornic_timeout_reset");
2201 if (!visornic_timeout_reset_workqueue)
2202 goto cleanup_workqueue;
2204 spin_lock_init(&dev_num_pool_lock);
2205 dev_num_pool = kzalloc(BITS_TO_LONGS(MAXDEVICES), GFP_KERNEL);
2207 goto cleanup_workqueue;
2209 visorbus_register_visor_driver(&visornic_driver);
2213 flush_workqueue(visornic_serverdown_workqueue);
2214 destroy_workqueue(visornic_serverdown_workqueue);
2215 if (visornic_timeout_reset_workqueue) {
2216 flush_workqueue(visornic_timeout_reset_workqueue);
2217 destroy_workqueue(visornic_timeout_reset_workqueue);
2220 debugfs_remove_recursive(visornic_debugfs_dir);
2226 * visornic_cleanup - driver exit routine
2228 * Unregister driver from the bus and free up memory.
2230 static void visornic_cleanup(void)
2232 visorbus_unregister_visor_driver(&visornic_driver);
2234 if (visornic_serverdown_workqueue) {
2235 flush_workqueue(visornic_serverdown_workqueue);
2236 destroy_workqueue(visornic_serverdown_workqueue);
2238 if (visornic_timeout_reset_workqueue) {
2239 flush_workqueue(visornic_timeout_reset_workqueue);
2240 destroy_workqueue(visornic_timeout_reset_workqueue);
2242 debugfs_remove_recursive(visornic_debugfs_dir);
2244 kfree(dev_num_pool);
2245 dev_num_pool = NULL;
2248 module_init(visornic_init);
2249 module_exit(visornic_cleanup);
2251 MODULE_AUTHOR("Unisys");
2252 MODULE_LICENSE("GPL");
2253 MODULE_DESCRIPTION("sPAR nic driver for sparlinux: ver 1.0.0.0");
2254 MODULE_VERSION("1.0.0.0");