Path: blob/master/drivers/infiniband/hw/cxgb3/cxio_hal.h
15112 views
/*1* Copyright (c) 2006 Chelsio, Inc. All rights reserved.2*3* This software is available to you under a choice of one of two4* licenses. You may choose to be licensed under the terms of the GNU5* General Public License (GPL) Version 2, available from the file6* COPYING in the main directory of this source tree, or the7* OpenIB.org BSD license below:8*9* Redistribution and use in source and binary forms, with or10* without modification, are permitted provided that the following11* conditions are met:12*13* - Redistributions of source code must retain the above14* copyright notice, this list of conditions and the following15* disclaimer.16*17* - Redistributions in binary form must reproduce the above18* copyright notice, this list of conditions and the following19* disclaimer in the documentation and/or other materials20* provided with the distribution.21*22* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,23* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF24* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND25* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS26* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN27* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN28* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE29* SOFTWARE.30*/31#ifndef __CXIO_HAL_H__32#define __CXIO_HAL_H__3334#include <linux/list.h>35#include <linux/mutex.h>36#include <linux/kfifo.h>3738#include "t3_cpl.h"39#include "t3cdev.h"40#include "cxgb3_ctl_defs.h"41#include "cxio_wr.h"4243#define T3_CTRL_QP_ID FW_RI_SGEEC_START44#define T3_CTL_QP_TID FW_RI_TID_START45#define T3_CTRL_QP_SIZE_LOG2 846#define T3_CTRL_CQ_ID 04748#define T3_MAX_NUM_RI (1<<15)49#define T3_MAX_NUM_QP (1<<15)50#define T3_MAX_NUM_CQ (1<<15)51#define T3_MAX_NUM_PD (1<<15)52#define T3_MAX_PBL_SIZE 25653#define T3_MAX_RQ_SIZE 102454#define T3_MAX_QP_DEPTH (T3_MAX_RQ_SIZE-1)55#define T3_MAX_CQ_DEPTH 6553656#define T3_MAX_NUM_STAG (1<<15)57#define T3_MAX_MR_SIZE 0x100000000ULL58#define T3_PAGESIZE_MASK 0xffff000 /* 4KB-128MB */5960#define T3_STAG_UNSET 0xffffffff6162#define T3_MAX_DEV_NAME_LEN 326364#define CXIO_FW_MAJ 76566struct cxio_hal_ctrl_qp {67u32 wptr;68u32 rptr;69struct mutex lock; /* for the wtpr, can sleep */70wait_queue_head_t waitq;/* wait for RspQ/CQE msg */71union t3_wr *workq; /* the work request queue */72dma_addr_t dma_addr; /* pci bus address of the workq */73DEFINE_DMA_UNMAP_ADDR(mapping);74void __iomem *doorbell;75};7677struct cxio_hal_resource {78struct kfifo tpt_fifo;79spinlock_t tpt_fifo_lock;80struct kfifo qpid_fifo;81spinlock_t qpid_fifo_lock;82struct kfifo cqid_fifo;83spinlock_t cqid_fifo_lock;84struct kfifo pdid_fifo;85spinlock_t pdid_fifo_lock;86};8788struct cxio_qpid_list {89struct list_head entry;90u32 qpid;91};9293struct cxio_ucontext {94struct list_head qpids;95struct mutex lock;96};9798struct cxio_rdev {99char dev_name[T3_MAX_DEV_NAME_LEN];100struct t3cdev *t3cdev_p;101struct rdma_info rnic_info;102struct adap_ports port_info;103struct cxio_hal_resource *rscp;104struct cxio_hal_ctrl_qp ctrl_qp;105void *ulp;106unsigned long qpshift;107u32 qpnr;108u32 qpmask;109struct cxio_ucontext uctx;110struct gen_pool *pbl_pool;111struct gen_pool *rqt_pool;112struct list_head entry;113struct ch_embedded_info fw_info;114u32 flags;115#define CXIO_ERROR_FATAL 1116};117118static inline int cxio_fatal_error(struct cxio_rdev *rdev_p)119{120return rdev_p->flags & CXIO_ERROR_FATAL;121}122123static inline int cxio_num_stags(struct cxio_rdev *rdev_p)124{125return min((int)T3_MAX_NUM_STAG, (int)((rdev_p->rnic_info.tpt_top - rdev_p->rnic_info.tpt_base) >> 5));126}127128typedef void (*cxio_hal_ev_callback_func_t) (struct cxio_rdev * rdev_p,129struct sk_buff * skb);130131#define RSPQ_CQID(rsp) (be32_to_cpu(rsp->cq_ptrid) & 0xffff)132#define RSPQ_CQPTR(rsp) ((be32_to_cpu(rsp->cq_ptrid) >> 16) & 0xffff)133#define RSPQ_GENBIT(rsp) ((be32_to_cpu(rsp->flags) >> 16) & 1)134#define RSPQ_OVERFLOW(rsp) ((be32_to_cpu(rsp->flags) >> 17) & 1)135#define RSPQ_AN(rsp) ((be32_to_cpu(rsp->flags) >> 18) & 1)136#define RSPQ_SE(rsp) ((be32_to_cpu(rsp->flags) >> 19) & 1)137#define RSPQ_NOTIFY(rsp) ((be32_to_cpu(rsp->flags) >> 20) & 1)138#define RSPQ_CQBRANCH(rsp) ((be32_to_cpu(rsp->flags) >> 21) & 1)139#define RSPQ_CREDIT_THRESH(rsp) ((be32_to_cpu(rsp->flags) >> 22) & 1)140141struct respQ_msg_t {142__be32 flags; /* flit 0 */143__be32 cq_ptrid;144__be64 rsvd; /* flit 1 */145struct t3_cqe cqe; /* flits 2-3 */146};147148enum t3_cq_opcode {149CQ_ARM_AN = 0x2,150CQ_ARM_SE = 0x6,151CQ_FORCE_AN = 0x3,152CQ_CREDIT_UPDATE = 0x7153};154155int cxio_rdev_open(struct cxio_rdev *rdev);156void cxio_rdev_close(struct cxio_rdev *rdev);157int cxio_hal_cq_op(struct cxio_rdev *rdev, struct t3_cq *cq,158enum t3_cq_opcode op, u32 credit);159int cxio_create_cq(struct cxio_rdev *rdev, struct t3_cq *cq, int kernel);160int cxio_destroy_cq(struct cxio_rdev *rdev, struct t3_cq *cq);161int cxio_resize_cq(struct cxio_rdev *rdev, struct t3_cq *cq);162void cxio_release_ucontext(struct cxio_rdev *rdev, struct cxio_ucontext *uctx);163void cxio_init_ucontext(struct cxio_rdev *rdev, struct cxio_ucontext *uctx);164int cxio_create_qp(struct cxio_rdev *rdev, u32 kernel_domain, struct t3_wq *wq,165struct cxio_ucontext *uctx);166int cxio_destroy_qp(struct cxio_rdev *rdev, struct t3_wq *wq,167struct cxio_ucontext *uctx);168int cxio_peek_cq(struct t3_wq *wr, struct t3_cq *cq, int opcode);169int cxio_write_pbl(struct cxio_rdev *rdev_p, __be64 *pbl,170u32 pbl_addr, u32 pbl_size);171int cxio_register_phys_mem(struct cxio_rdev *rdev, u32 * stag, u32 pdid,172enum tpt_mem_perm perm, u32 zbva, u64 to, u32 len,173u8 page_size, u32 pbl_size, u32 pbl_addr);174int cxio_reregister_phys_mem(struct cxio_rdev *rdev, u32 * stag, u32 pdid,175enum tpt_mem_perm perm, u32 zbva, u64 to, u32 len,176u8 page_size, u32 pbl_size, u32 pbl_addr);177int cxio_dereg_mem(struct cxio_rdev *rdev, u32 stag, u32 pbl_size,178u32 pbl_addr);179int cxio_allocate_window(struct cxio_rdev *rdev, u32 * stag, u32 pdid);180int cxio_allocate_stag(struct cxio_rdev *rdev, u32 *stag, u32 pdid, u32 pbl_size, u32 pbl_addr);181int cxio_deallocate_window(struct cxio_rdev *rdev, u32 stag);182int cxio_rdma_init(struct cxio_rdev *rdev, struct t3_rdma_init_attr *attr);183void cxio_register_ev_cb(cxio_hal_ev_callback_func_t ev_cb);184void cxio_unregister_ev_cb(cxio_hal_ev_callback_func_t ev_cb);185u32 cxio_hal_get_pdid(struct cxio_hal_resource *rscp);186void cxio_hal_put_pdid(struct cxio_hal_resource *rscp, u32 pdid);187int __init cxio_hal_init(void);188void __exit cxio_hal_exit(void);189int cxio_flush_rq(struct t3_wq *wq, struct t3_cq *cq, int count);190int cxio_flush_sq(struct t3_wq *wq, struct t3_cq *cq, int count);191void cxio_count_rcqes(struct t3_cq *cq, struct t3_wq *wq, int *count);192void cxio_count_scqes(struct t3_cq *cq, struct t3_wq *wq, int *count);193void cxio_flush_hw_cq(struct t3_cq *cq);194int cxio_poll_cq(struct t3_wq *wq, struct t3_cq *cq, struct t3_cqe *cqe,195u8 *cqe_flushed, u64 *cookie, u32 *credit);196int iwch_cxgb3_ofld_send(struct t3cdev *tdev, struct sk_buff *skb);197198#define MOD "iw_cxgb3: "199#define PDBG(fmt, args...) pr_debug(MOD fmt, ## args)200201#ifdef DEBUG202void cxio_dump_tpt(struct cxio_rdev *rev, u32 stag);203void cxio_dump_pbl(struct cxio_rdev *rev, u32 pbl_addr, uint len, u8 shift);204void cxio_dump_wqe(union t3_wr *wqe);205void cxio_dump_wce(struct t3_cqe *wce);206void cxio_dump_rqt(struct cxio_rdev *rdev, u32 hwtid, int nents);207void cxio_dump_tcb(struct cxio_rdev *rdev, u32 hwtid);208#endif209210#endif211212213