/* * This file is part of the Chelsio FCoE driver for Linux. * * Copyright (c) 2008-2012 Chelsio Communications, Inc. 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.
*/
/* Size of the egress queue status page */ staticinline uint32_t
csio_wr_qstat_pgsz(struct csio_hw *hw)
{ return (hw->wrm.sge.sge_control & EGRSTATUSPAGESIZE_F) ? 128 : 64;
}
/* Ring freelist doorbell */ staticinlinevoid
csio_wr_ring_fldb(struct csio_hw *hw, struct csio_q *flq)
{ /* * Ring the doorbell only when we have atleast CSIO_QCREDIT_SZ * number of bytes in the freelist queue. This translates to atleast * 8 freelist buffer pointers (since each pointer is 8 bytes).
*/ if (flq->inc_idx >= 8) {
csio_wr_reg32(hw, DBPRIO_F | QID_V(flq->un.fl.flid) |
PIDX_T5_V(flq->inc_idx / 8) | DBTYPE_F,
MYPF_REG(SGE_PF_KDOORBELL_A));
flq->inc_idx &= 7;
}
}
/* Write a 0 cidx increment value to enable SGE interrupts for this queue */ staticvoid
csio_wr_sge_intr_enable(struct csio_hw *hw, uint16_t iqid)
{
csio_wr_reg32(hw, CIDXINC_V(0) |
INGRESSQID_V(iqid) |
TIMERREG_V(X_TIMERREG_RESTART_COUNTER),
MYPF_REG(SGE_PF_GTS_A));
}
/* * csio_wr_fill_fl - Populate the FL buffers of a FL queue. * @hw: HW module. * @flq: Freelist queue. * * Fill up freelist buffer entries with buffers of size specified * in the size register. *
*/ staticint
csio_wr_fill_fl(struct csio_hw *hw, struct csio_q *flq)
{ struct csio_wrm *wrm = csio_hw_to_wrm(hw); struct csio_sge *sge = &wrm->sge;
__be64 *d = (__be64 *)(flq->vstart); struct csio_dma_buf *buf = &flq->un.fl.bufs[0];
uint64_t paddr; int sreg = flq->un.fl.sreg; int n = flq->credits;
while (n--) {
buf->len = sge->sge_fl_buf_size[sreg];
buf->vaddr = dma_alloc_coherent(&hw->pdev->dev, buf->len,
&buf->paddr, GFP_KERNEL); if (!buf->vaddr) {
csio_err(hw, "Could only fill %d buffers!\n", n + 1); return -ENOMEM;
}
/* * csio_wr_alloc_q - Allocate a WR queue and initialize it. * @hw: HW module * @qsize: Size of the queue in bytes * @wrsize: Since of WR in this queue, if fixed. * @type: Type of queue (Ingress/Egress/Freelist) * @owner: Module that owns this queue. * @nflb: Number of freelist buffers for FL. * @sreg: What is the FL buffer size register? * @iq_int_handler: Ingress queue handler in INTx mode. * * This function allocates and sets up a queue for the caller * of size qsize, aligned at the required boundary. This is subject to * be free entries being available in the queue array. If one is found, * it is initialized with the allocated queue, marked as being used (owner), * and a handle returned to the caller in form of the queue's index * into the q_arr array. * If user has indicated a freelist (by specifying nflb > 0), create * another queue (with its own index into q_arr) for the freelist. Allocate * memory for DMA buffer metadata (vaddr, len etc). Save off the freelist * idx in the ingress queue's flq.idx. This is how a Freelist is associated * with its owning ingress queue.
*/ int
csio_wr_alloc_q(struct csio_hw *hw, uint32_t qsize, uint32_t wrsize,
uint16_t type, void *owner, uint32_t nflb, int sreg,
iq_handler_t iq_intx_handler)
{ struct csio_wrm *wrm = csio_hw_to_wrm(hw); struct csio_q *q, *flq; int free_idx = wrm->free_qidx; int ret_idx = free_idx;
uint32_t qsz; int flq_idx;
if (free_idx >= wrm->num_q) {
csio_err(hw, "No more free queues.\n"); return -1;
}
switch (type) { case CSIO_EGRESS:
qsz = ALIGN(qsize, CSIO_QCREDIT_SZ) + csio_wr_qstat_pgsz(hw); break; case CSIO_INGRESS: switch (wrsize) { case 16: case 32: case 64: case 128: break; default:
csio_err(hw, "Invalid Ingress queue WR size:%d\n",
wrsize); return -1;
}
/* * Number of elements must be a multiple of 16 * So this includes status page size
*/
qsz = ALIGN(qsize/wrsize, 16) * wrsize;
/* Actual iq-id. */
iq_id = iqp.iqid - hw->wrm.fw_iq_start;
/* Set the iq-id to iq map table. */ if (iq_id >= CSIO_MAX_IQ) {
csio_err(hw, "Exceeding MAX_IQ(%d) supported!" " iqid:%d rel_iqid:%d FW iq_start:%d\n",
CSIO_MAX_IQ, iq_id, iqp.iqid, hw->wrm.fw_iq_start);
mempool_free(mbp, hw->mb_mempool); return -EINVAL;
}
csio_q_set_intr_map(hw, iq_idx, iq_id);
/* * During FW_IQ_CMD, FW sets interrupt_sent bit to 1 in the SGE * ingress context of this queue. This will block interrupts to * this queue until the next GTS write. Therefore, we do a * 0-cidx increment GTS write for this queue just to clear the * interrupt_sent bit. This will re-enable interrupts to this * queue.
*/
csio_wr_sge_intr_enable(hw, iqp.physiqid);
/* Now update SGE about the buffers allocated during init */
csio_wr_ring_fldb(hw, flq);
}
mempool_free(mbp, hw->mb_mempool);
return 0;
}
/* * csio_wr_iq_create - Configure an Ingress queue with FW. * @hw: The HW module. * @priv: Private data object. * @iq_idx: Ingress queue index in the WR module. * @vec: MSIX vector. * @portid: PCIE Channel to be associated with this queue. * @async: Is this a FW asynchronous message handling queue? * @cbfn: Completion callback. * * This API configures an ingress queue with FW by issuing a FW_IQ_CMD mailbox * with alloc/write bits set.
*/ int
csio_wr_iq_create(struct csio_hw *hw, void *priv, int iq_idx,
uint32_t vec, uint8_t portid, bool async, void (*cbfn) (struct csio_hw *, struct csio_mb *))
{ struct csio_mb *mbp; struct csio_iq_params iqp; int flq_idx;
if (csio_mb_issue(hw, mbp)) {
csio_err(hw, "Issue of EQ OFLD cmd failed!\n");
mempool_free(mbp, hw->mb_mempool); return -EINVAL;
}
if (cbfn != NULL) return 0;
return csio_wr_eq_cfg_rsp(hw, mbp, eq_idx);
}
/* * csio_wr_iq_destroy_rsp - Response handler for IQ removal. * @hw: The HW module. * @mbp: Mailbox. * @iq_idx: Ingress queue that was freed. * * Handle FW_IQ_CMD (free) mailbox completion.
*/ staticint
csio_wr_iq_destroy_rsp(struct csio_hw *hw, struct csio_mb *mbp, int iq_idx)
{ enum fw_retval retval = csio_mb_fw_retval(mbp); int rv = 0;
if (retval != FW_SUCCESS)
rv = -EINVAL;
mempool_free(mbp, hw->mb_mempool);
return rv;
}
/* * csio_wr_iq_destroy - Free an ingress queue. * @hw: The HW module. * @priv: Private data object. * @iq_idx: Ingress queue index to destroy * @cbfn: Completion callback. * * This API frees an ingress queue by issuing the FW_IQ_CMD * with the free bit set.
*/ staticint
csio_wr_iq_destroy(struct csio_hw *hw, void *priv, int iq_idx, void (*cbfn)(struct csio_hw *, struct csio_mb *))
{ int rv = 0; struct csio_mb *mbp; struct csio_iq_params iqp; int flq_idx;
memset(&iqp, 0, sizeof(struct csio_iq_params));
mbp = mempool_alloc(hw->mb_mempool, GFP_ATOMIC); if (!mbp) return -ENOMEM;
/* * csio_wr_eq_destroy_rsp - Response handler for OFLD EQ creation. * @hw: The HW module. * @mbp: Mailbox. * @eq_idx: Egress queue that was freed. * * Handle FW_OFLD_EQ_CMD (free) mailbox completion.
*/ staticint
csio_wr_eq_destroy_rsp(struct csio_hw *hw, struct csio_mb *mbp, int eq_idx)
{ enum fw_retval retval = csio_mb_fw_retval(mbp); int rv = 0;
if (retval != FW_SUCCESS)
rv = -EINVAL;
mempool_free(mbp, hw->mb_mempool);
return rv;
}
/* * csio_wr_eq_destroy - Free an Egress queue. * @hw: The HW module. * @priv: Private data object. * @eq_idx: Egress queue index to destroy * @cbfn: Completion callback. * * This API frees an Egress queue by issuing the FW_EQ_OFLD_CMD * with the free bit set.
*/ staticint
csio_wr_eq_destroy(struct csio_hw *hw, void *priv, int eq_idx, void (*cbfn) (struct csio_hw *, struct csio_mb *))
{ int rv = 0; struct csio_mb *mbp; struct csio_eq_params eqp;
memset(&eqp, 0, sizeof(struct csio_eq_params));
mbp = mempool_alloc(hw->mb_mempool, GFP_ATOMIC); if (!mbp) return -ENOMEM;
/* * csio_wr_cleanup_eq_stpg - Cleanup Egress queue status page * @hw: HW module * @qidx: Egress queue index * * Cleanup the Egress queue status page.
*/ staticvoid
csio_wr_cleanup_eq_stpg(struct csio_hw *hw, int qidx)
{ struct csio_q *q = csio_hw_to_wrm(hw)->q_arr[qidx]; struct csio_qstatus_page *stp = (struct csio_qstatus_page *)q->vwrap;
memset(stp, 0, sizeof(*stp));
}
/* * csio_wr_cleanup_iq_ftr - Cleanup Footer entries in IQ * @hw: HW module * @qidx: Ingress queue index * * Cleanup the footer entries in the given ingress queue, * set to 1 the internal copy of genbit.
*/ staticvoid
csio_wr_cleanup_iq_ftr(struct csio_hw *hw, int qidx)
{ struct csio_wrm *wrm = csio_hw_to_wrm(hw); struct csio_q *q = wrm->q_arr[qidx]; void *wr; struct csio_iqwr_footer *ftr;
uint32_t i = 0;
/* set to 1 since we are just about zero out genbit */
q->un.iq.genbit = 1;
for (i = 0; i < q->credits; i++) { /* Get the WR */
wr = (void *)((uintptr_t)q->vstart +
(i * q->wr_sz)); /* Get the footer */
ftr = (struct csio_iqwr_footer *)((uintptr_t)wr +
(q->wr_sz - sizeof(*ftr))); /* Zero out footer */
memset(ftr, 0, sizeof(*ftr));
}
}
int
csio_wr_destroy_queues(struct csio_hw *hw, bool cmd)
{ int i, flq_idx; struct csio_q *q; struct csio_wrm *wrm = csio_hw_to_wrm(hw); int rv;
for (i = 0; i < wrm->free_qidx; i++) {
q = wrm->q_arr[i];
switch (q->type) { case CSIO_EGRESS: if (csio_q_eqid(hw, i) != CSIO_MAX_QID) {
csio_wr_cleanup_eq_stpg(hw, i); if (!cmd) {
csio_q_eqid(hw, i) = CSIO_MAX_QID; continue;
}
rv = csio_wr_eq_destroy(hw, NULL, i, NULL); if ((rv == -EBUSY) || (rv == -ETIMEDOUT))
cmd = false;
csio_q_eqid(hw, i) = CSIO_MAX_QID;
}
fallthrough; case CSIO_INGRESS: if (csio_q_iqid(hw, i) != CSIO_MAX_QID) {
csio_wr_cleanup_iq_ftr(hw, i); if (!cmd) {
csio_q_iqid(hw, i) = CSIO_MAX_QID;
flq_idx = csio_q_iq_flq_idx(hw, i); if (flq_idx != -1)
csio_q_flid(hw, flq_idx) =
CSIO_MAX_QID; continue;
}
rv = csio_wr_iq_destroy(hw, NULL, i, NULL); if ((rv == -EBUSY) || (rv == -ETIMEDOUT))
cmd = false;
/* * csio_wr_get - Get requested size of WR entry/entries from queue. * @hw: HW module. * @qidx: Index of queue. * @size: Cumulative size of Work request(s). * @wrp: Work request pair. * * If requested credits are available, return the start address of the * work request in the work request pair. Set pidx accordingly and * return. * * NOTE about WR pair: * ================== * A WR can start towards the end of a queue, and then continue at the * beginning, since the queue is considered to be circular. This will * require a pair of address/size to be passed back to the caller - * hence Work request pair format.
*/ int
csio_wr_get(struct csio_hw *hw, int qidx, uint32_t size, struct csio_wr_pair *wrp)
{ struct csio_wrm *wrm = csio_hw_to_wrm(hw); struct csio_q *q = wrm->q_arr[qidx]; void *cwr = (void *)((uintptr_t)(q->vstart) +
(q->pidx * CSIO_QCREDIT_SZ)); struct csio_qstatus_page *stp = (struct csio_qstatus_page *)q->vwrap;
uint16_t cidx = q->cidx = ntohs(stp->cidx);
uint16_t pidx = q->pidx;
uint32_t req_sz = ALIGN(size, CSIO_QCREDIT_SZ); int req_credits = req_sz / CSIO_QCREDIT_SZ; int credits;
/* * Check if we have enough credits. * credits = 1 implies queue is full.
*/ if (!credits || (req_credits > credits)) {
CSIO_INC_STATS(q, n_qfull); return -EBUSY;
}
/* * If we are here, we have enough credits to satisfy the * request. Check if we are near the end of q, and if WR spills over. * If it does, use the first addr/size to cover the queue until * the end. Fit the remainder portion of the request at the top * of queue and return it in the second addr/len. Set pidx * accordingly.
*/ if (unlikely(((uintptr_t)cwr + req_sz) > (uintptr_t)(q->vwrap))) {
wrp->addr1 = cwr;
wrp->size1 = (uint32_t)((uintptr_t)q->vwrap - (uintptr_t)cwr);
wrp->addr2 = q->vstart;
wrp->size2 = req_sz - wrp->size1;
q->pidx = (uint16_t)(ALIGN(wrp->size2, CSIO_QCREDIT_SZ) /
CSIO_QCREDIT_SZ);
CSIO_INC_STATS(q, n_qwrap);
CSIO_INC_STATS(q, n_eq_wr_split);
} else {
wrp->addr1 = cwr;
wrp->size1 = req_sz;
wrp->addr2 = NULL;
wrp->size2 = 0;
q->pidx += (uint16_t)req_credits;
/* We are the end of queue, roll back pidx to top of queue */ if (unlikely(q->pidx == q->credits)) {
q->pidx = 0;
CSIO_INC_STATS(q, n_qwrap);
}
}
q->inc_idx = (uint16_t)req_credits;
CSIO_INC_STATS(q, n_tot_reqs);
return 0;
}
/* * csio_wr_copy_to_wrp - Copies given data into WR. * @data_buf - Data buffer * @wrp - Work request pair. * @wr_off - Work request offset. * @data_len - Data length. * * Copies the given data in Work Request. Work request pair(wrp) specifies * address information of Work request. * Returns: none
*/ void
csio_wr_copy_to_wrp(void *data_buf, struct csio_wr_pair *wrp,
uint32_t wr_off, uint32_t data_len)
{
uint32_t nbytes;
/* Number of space available in buffer addr1 of WRP */
nbytes = ((wrp->size1 - wr_off) >= data_len) ?
data_len : (wrp->size1 - wr_off);
/* Write the remaining data from the begining of circular buffer */ if (data_len) {
CSIO_DB_ASSERT(data_len <= wrp->size2);
CSIO_DB_ASSERT(wrp->addr2 != NULL);
memcpy(wrp->addr2, (uint8_t *) data_buf + nbytes, data_len);
}
}
/* * csio_wr_issue - Notify chip of Work request. * @hw: HW module. * @qidx: Index of queue. * @prio: 0: Low priority, 1: High priority * * Rings the SGE Doorbell by writing the current producer index of the passed * in queue into the register. *
*/ int
csio_wr_issue(struct csio_hw *hw, int qidx, bool prio)
{ struct csio_wrm *wrm = csio_hw_to_wrm(hw); struct csio_q *q = wrm->q_arr[qidx];
/* * csio_wr_inval_flq_buf - Invalidate a free list buffer entry. * @hw: HW module. * @flq: The freelist queue. * * Invalidate the driver's version of a freelist buffer entry, * without freeing the associated the DMA memory. The entry * to be invalidated is picked up from the current Free list * queue cidx. *
*/ staticinlinevoid
csio_wr_inval_flq_buf(struct csio_hw *hw, struct csio_q *flq)
{
flq->cidx++; if (flq->cidx == flq->credits) {
flq->cidx = 0;
CSIO_INC_STATS(flq, n_qwrap);
}
}
/* * csio_wr_process_fl - Process a freelist completion. * @hw: HW module. * @q: The ingress queue attached to the Freelist. * @wr: The freelist completion WR in the ingress queue. * @len_to_qid: The lower 32-bits of the first flit of the RSP footer * @iq_handler: Caller's handler for this completion. * @priv: Private pointer of caller *
*/ staticinlinevoid
csio_wr_process_fl(struct csio_hw *hw, struct csio_q *q, void *wr, uint32_t len_to_qid, void (*iq_handler)(struct csio_hw *, void *,
uint32_t, struct csio_fl_dma_buf *, void *), void *priv)
{ struct csio_wrm *wrm = csio_hw_to_wrm(hw); struct csio_sge *sge = &wrm->sge; struct csio_fl_dma_buf flb; struct csio_dma_buf *buf, *fbuf;
uint32_t bufsz, len, lastlen = 0; struct csio_q *flq = hw->wrm.q_arr[q->un.iq.flq_idx];
CSIO_DB_ASSERT(flq != NULL);
len = len_to_qid;
if (len & IQWRF_NEWBUF) { if (flq->un.fl.offset > 0) {
csio_wr_inval_flq_buf(hw, flq);
flq->un.fl.offset = 0;
}
len = IQWRF_LEN_GET(len);
}
CSIO_DB_ASSERT(len != 0);
flb.totlen = len;
/* Consume all freelist buffers used for len bytes */ for (fbuf = flb.flbufs; ; fbuf++) {
buf = &flq->un.fl.bufs[flq->cidx];
bufsz = csio_wr_fl_bufsz(sge, buf);
if (flq->un.fl.packen)
flq->un.fl.offset += ALIGN(lastlen, sge->csio_fl_align); else
csio_wr_inval_flq_buf(hw, flq);
}
/* * csio_is_new_iqwr - Is this a new Ingress queue entry ? * @q: Ingress quueue. * @ftr: Ingress queue WR SGE footer. * * The entry is new if our generation bit matches the corresponding * bit in the footer of the current WR.
*/ staticinlinebool
csio_is_new_iqwr(struct csio_q *q, struct csio_iqwr_footer *ftr)
{ return (q->un.iq.genbit == (ftr->u.type_gen >> IQWRF_GEN_SHIFT));
}
/* * csio_wr_process_iq - Process elements in Ingress queue. * @hw: HW pointer * @qidx: Index of queue * @iq_handler: Handler for this queue * @priv: Caller's private pointer * * This routine walks through every entry of the ingress queue, calling * the provided iq_handler with the entry, until the generation bit * flips.
*/ int
csio_wr_process_iq(struct csio_hw *hw, struct csio_q *q, void (*iq_handler)(struct csio_hw *, void *,
uint32_t, struct csio_fl_dma_buf *, void *), void *priv)
{ struct csio_wrm *wrm = csio_hw_to_wrm(hw); void *wr = (void *)((uintptr_t)q->vstart + (q->cidx * q->wr_sz)); struct csio_iqwr_footer *ftr;
uint32_t wr_type, fw_qid, qid; struct csio_q *q_completed; struct csio_q *flq = csio_iq_has_fl(q) ?
wrm->q_arr[q->un.iq.flq_idx] : NULL; int rv = 0;
/* Get the footer */
ftr = (struct csio_iqwr_footer *)((uintptr_t)wr +
(q->wr_sz - sizeof(*ftr)));
/* * When q wrapped around last time, driver should have inverted * ic.genbit as well.
*/ while (csio_is_new_iqwr(q, ftr)) {
/* * Ingress *always* has fixed size WR entries. Therefore, * there should always be complete WRs towards the end of * queue.
*/ if (((uintptr_t)wr + q->wr_sz) == (uintptr_t)q->vwrap) {
/* Roll over to start of queue */
q->cidx = 0;
wr = q->vstart;
/* * We need to re-arm SGE interrupts in case we got a stray interrupt, * especially in msix mode. With INTx, this may be a common occurence.
*/ if (unlikely(!q->inc_idx)) {
CSIO_INC_STATS(q, n_stray_comp);
rv = -EINVAL; goto restart;
}
/* Replenish free list buffers if pending falls below low water mark */ if (flq) {
uint32_t avail = csio_wr_avail_qcredits(flq); if (avail <= 16) { /* Make sure in FLQ, atleast 1 credit (8 FL buffers) * remains unpopulated otherwise HW thinks * FLQ is empty.
*/
csio_wr_update_fl(hw, flq, (flq->credits - 8) - avail);
csio_wr_ring_fldb(hw, flq);
}
}
restart: /* Now inform SGE about our incremental index value */
csio_wr_reg32(hw, CIDXINC_V(q->inc_idx) |
INGRESSQID_V(q->un.iq.physiqid) |
TIMERREG_V(csio_sge_timer_reg),
MYPF_REG(SGE_PF_GTS_A));
q->stats.n_tot_rsps += q->inc_idx;
/* T5 introduced the separation of the Free List Padding and * Packing Boundaries. Thus, we can select a smaller Padding * Boundary to avoid uselessly chewing up PCIe Link and Memory * Bandwidth, and use a Packing Boundary which is large enough * to avoid false sharing between CPUs, etc. * * For the PCI Link, the smaller the Padding Boundary the * better. For the Memory Controller, a smaller Padding * Boundary is better until we cross under the Memory Line * Size (the minimum unit of transfer to/from Memory). If we * have a Padding Boundary which is smaller than the Memory * Line Size, that'll involve a Read-Modify-Write cycle on the * Memory Controller which is never good.
*/
/* We want the Packing Boundary to be based on the Cache Line * Size in order to help avoid False Sharing performance * issues between CPUs, etc. We also want the Packing * Boundary to incorporate the PCI-E Maximum Payload Size. We * get best performance when the Packing Boundary is a * multiple of the Maximum Payload Size.
*/
pack_align = fl_align; if (pci_is_pcie(hw->pdev)) {
u32 mps, mps_log;
u16 devctl;
/* The PCIe Device Control Maximum Payload Size field * [bits 7:5] encodes sizes as powers of 2 starting at * 128 bytes.
*/
pcie_capability_read_word(hw->pdev, PCI_EXP_DEVCTL, &devctl);
mps_log = ((devctl & PCI_EXP_DEVCTL_PAYLOAD) >> 5) + 7;
mps = 1 << mps_log; if (mps > pack_align)
pack_align = mps;
}
/* T5/T6 have a special interpretation of the "0" * value for the Packing Boundary. This corresponds to 16 * bytes instead of the expected 32 bytes.
*/ if (pack_align <= 16) {
ingpack = INGPACKBOUNDARY_16B_X;
fl_align = 16;
} elseif (pack_align == 32) {
ingpack = INGPACKBOUNDARY_64B_X;
fl_align = 64;
} else {
u32 pack_align_log = fls(pack_align) - 1;
/* Use the smallest Ingress Padding which isn't smaller than * the Memory Controller Read/Write Size. We'll take that as * being 8 bytes since we don't know of any system with a * wider Memory Controller Bus Width.
*/ if (csio_is_t5(hw->pdev->device & CSIO_HW_CHIP_MASK))
ingpad = INGPADBOUNDARY_32B_X; else
ingpad = T6_INGPADBOUNDARY_8B_X;
/* FL BUFFER SIZE#0 is Page size i,e already aligned to cache line */
csio_wr_reg32(hw, PAGE_SIZE, SGE_FL_BUFFER_SIZE0_A);
/* * If using hard params, the following will get set correctly * in csio_wr_set_sge().
*/ if (hw->flags & CSIO_HWF_USING_SOFT_PARAMS) {
csio_wr_reg32(hw,
(csio_rd_reg32(hw, SGE_FL_BUFFER_SIZE2_A) +
fl_align - 1) & ~(fl_align - 1),
SGE_FL_BUFFER_SIZE2_A);
csio_wr_reg32(hw,
(csio_rd_reg32(hw, SGE_FL_BUFFER_SIZE3_A) +
fl_align - 1) & ~(fl_align - 1),
SGE_FL_BUFFER_SIZE3_A);
}
/* default value of rx_dma_offset of the NIC driver */
csio_set_reg_field(hw, SGE_CONTROL_A,
PKTSHIFT_V(PKTSHIFT_M),
PKTSHIFT_V(CSIO_SGE_RX_DMA_OFFSET));
/* * csio_wr_set_sge - Initialize SGE registers * @hw: HW module. * * Used by Master function to initialize SGE registers in the absence * of a config file.
*/ staticvoid
csio_wr_set_sge(struct csio_hw *hw)
{ struct csio_wrm *wrm = csio_hw_to_wrm(hw); struct csio_sge *sge = &wrm->sge; int i;
/* * Set up our basic SGE mode to deliver CPL messages to our Ingress * Queue and Packet Date to the Free List.
*/
csio_set_reg_field(hw, SGE_CONTROL_A, RXPKTCPLMODE_F, RXPKTCPLMODE_F);
/* sge->csio_fl_align is set up by csio_wr_fixup_host_params(). */
/* * Set up to drop DOORBELL writes when the DOORBELL FIFO overflows * and generate an interrupt when this occurs so we can recover.
*/
csio_set_reg_field(hw, SGE_DBFIFO_STATUS_A,
LP_INT_THRESH_T5_V(LP_INT_THRESH_T5_M),
LP_INT_THRESH_T5_V(CSIO_SGE_DBFIFO_INT_THRESH));
csio_set_reg_field(hw, SGE_DBFIFO_STATUS2_A,
HP_INT_THRESH_T5_V(LP_INT_THRESH_T5_M),
HP_INT_THRESH_T5_V(CSIO_SGE_DBFIFO_INT_THRESH));
void
csio_wr_sge_init(struct csio_hw *hw)
{ /* * If we are master and chip is not initialized: * - If we plan to use the config file, we need to fixup some * host specific registers, and read the rest of the SGE * configuration. * - If we dont plan to use the config file, we need to initialize * SGE entirely, including fixing the host specific registers. * If we are master and chip is initialized, just read and work off of * the already initialized SGE values. * If we arent the master, we are only allowed to read and work off of * the already initialized SGE values. * * Therefore, before calling this function, we assume that the master- * ship of the card, state and whether to use config file or not, have * already been decided.
*/ if (csio_is_hw_master(hw)) { if (hw->fw_state != CSIO_DEV_STATE_INIT)
csio_wr_fixup_host_params(hw);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.