/* * Copyright (c) 2008, 2009, 2010 QLogic Corporation. All rights reserved. * * This software is available to you under a choice of one of two * licenses. You may choose to be licensed under the terms of the GNU * General Public License (GPL) Version 2, available from the file * COPYING in the main directory of this source tree, or the * OpenIB.org BSD license below: * * Redistribution and use in source and binary forms, with or * without modification, are permitted provided that the following * conditions are met: * * - Redistributions of source code must retain the above * copyright notice, this list of conditions and the following * disclaimer. * * - Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials * provided with the distribution. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #include <linux/spinlock.h> #include <linux/pci.h> #include <linux/io.h> #include <linux/delay.h> #include <linux/netdevice.h> #include <linux/vmalloc.h> #include <linux/moduleparam.h> #include "qib.h" static unsigned qib_hol_timeout_ms = …; module_param_named(hol_timeout_ms, qib_hol_timeout_ms, uint, S_IRUGO); MODULE_PARM_DESC(…) …; unsigned qib_sdma_fetch_arb = …; module_param_named(fetch_arb, qib_sdma_fetch_arb, uint, S_IRUGO); MODULE_PARM_DESC(…) …; /** * qib_disarm_piobufs - cancel a range of PIO buffers * @dd: the qlogic_ib device * @first: the first PIO buffer to cancel * @cnt: the number of PIO buffers to cancel * * Cancel a range of PIO buffers. Used at user process close, * in case it died while writing to a PIO buffer. */ void qib_disarm_piobufs(struct qib_devdata *dd, unsigned first, unsigned cnt) { … } /* * This is called by a user process when it sees the DISARM_BUFS event * bit is set. */ int qib_disarm_piobufs_ifneeded(struct qib_ctxtdata *rcd) { … } static struct qib_pportdata *is_sdma_buf(struct qib_devdata *dd, unsigned i) { … } /* * Return true if send buffer is being used by a user context. * Sets _QIB_EVENT_DISARM_BUFS_BIT in user_event_mask as a side effect */ static int find_ctxt(struct qib_devdata *dd, unsigned bufn) { … } /* * Disarm a set of send buffers. If the buffer might be actively being * written to, mark the buffer to be disarmed later when it is not being * written to. * * This should only be called from the IRQ error handler. */ void qib_disarm_piobufs_set(struct qib_devdata *dd, unsigned long *mask, unsigned cnt) { … } /** * update_send_bufs - update shadow copy of the PIO availability map * @dd: the qlogic_ib device * * called whenever our local copy indicates we have run out of send buffers */ static void update_send_bufs(struct qib_devdata *dd) { … } /* * Debugging code and stats updates if no pio buffers available. */ static noinline void no_send_bufs(struct qib_devdata *dd) { … } /* * Common code for normal driver send buffer allocation, and reserved * allocation. * * Do appropriate marking as busy, etc. * Returns buffer pointer if one is found, otherwise NULL. */ u32 __iomem *qib_getsendbuf_range(struct qib_devdata *dd, u32 *pbufnum, u32 first, u32 last) { … } /* * Record that the caller is finished writing to the buffer so we don't * disarm it while it is being written and disarm it now if needed. */ void qib_sendbuf_done(struct qib_devdata *dd, unsigned n) { … } /** * qib_chg_pioavailkernel - change which send buffers are available for kernel * @dd: the qlogic_ib device * @start: the starting send buffer number * @len: the number of send buffers * @avail: true if the buffers are available for kernel use, false otherwise * @rcd: the context pointer */ void qib_chg_pioavailkernel(struct qib_devdata *dd, unsigned start, unsigned len, u32 avail, struct qib_ctxtdata *rcd) { … } /* * Flush all sends that might be in the ready to send state, as well as any * that are in the process of being sent. Used whenever we need to be * sure the send side is idle. Cleans up all buffer state by canceling * all pio buffers, and issuing an abort, which cleans up anything in the * launch fifo. The cancel is superfluous on some chip versions, but * it's safer to always do it. * PIOAvail bits are updated by the chip as if a normal send had happened. */ void qib_cancel_sends(struct qib_pportdata *ppd) { … } /* * Force an update of in-memory copy of the pioavail registers, when * needed for any of a variety of reasons. * If already off, this routine is a nop, on the assumption that the * caller (or set of callers) will "do the right thing". * This is a per-device operation, so just the first port. */ void qib_force_pio_avail_update(struct qib_devdata *dd) { … } void qib_hol_down(struct qib_pportdata *ppd) { … } /* * Link is at INIT. * We start the HoL timer so we can detect stuck packets blocking SMP replies. * Timer may already be running, so use mod_timer, not add_timer. */ void qib_hol_init(struct qib_pportdata *ppd) { … } /* * Link is up, continue any user processes, and ensure timer * is a nop, if running. Let timer keep running, if set; it * will nop when it sees the link is up. */ void qib_hol_up(struct qib_pportdata *ppd) { … } /* * This is only called via the timer. */ void qib_hol_event(struct timer_list *t) { … }