Path: blob/master/drivers/infiniband/hw/amso1100/c2_mq.h
15112 views
/*1* Copyright (c) 2005 Ammasso, Inc. All rights reserved.2* Copyright (c) 2005 Open Grid Computing, Inc. All rights reserved.3*4* This software is available to you under a choice of one of two5* licenses. You may choose to be licensed under the terms of the GNU6* General Public License (GPL) Version 2, available from the file7* COPYING in the main directory of this source tree, or the8* OpenIB.org BSD license below:9*10* Redistribution and use in source and binary forms, with or11* without modification, are permitted provided that the following12* conditions are met:13*14* - Redistributions of source code must retain the above15* copyright notice, this list of conditions and the following16* disclaimer.17*18* - Redistributions in binary form must reproduce the above19* copyright notice, this list of conditions and the following20* disclaimer in the documentation and/or other materials21* provided with the distribution.22*23* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,24* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF25* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND26* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS27* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN28* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN29* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE30* SOFTWARE.31*/3233#ifndef _C2_MQ_H_34#define _C2_MQ_H_35#include <linux/kernel.h>36#include <linux/dma-mapping.h>37#include "c2_wr.h"3839enum c2_shared_regs {4041C2_SHARED_ARMED = 0x10,42C2_SHARED_NOTIFY = 0x18,43C2_SHARED_SHARED = 0x40,44};4546struct c2_mq_shared {47u16 unused1;48u8 armed;49u8 notification_type;50u32 unused2;51u16 shared;52/* Pad to 64 bytes. */53u8 pad[64 - sizeof(u16) - 2 * sizeof(u8) - sizeof(u32) - sizeof(u16)];54};5556enum c2_mq_type {57C2_MQ_HOST_TARGET = 1,58C2_MQ_ADAPTER_TARGET = 2,59};6061/*62* c2_mq_t is for kernel-mode MQs like the VQs Cand the AEQ.63* c2_user_mq_t (which is the same format) is for user-mode MQs...64*/65#define C2_MQ_MAGIC 0x4d512020 /* 'MQ ' */66struct c2_mq {67u32 magic;68union {69u8 *host;70u8 __iomem *adapter;71} msg_pool;72dma_addr_t host_dma;73DEFINE_DMA_UNMAP_ADDR(mapping);74u16 hint_count;75u16 priv;76struct c2_mq_shared __iomem *peer;77__be16 *shared;78dma_addr_t shared_dma;79u32 q_size;80u32 msg_size;81u32 index;82enum c2_mq_type type;83};8485static __inline__ int c2_mq_empty(struct c2_mq *q)86{87return q->priv == be16_to_cpu(*q->shared);88}8990static __inline__ int c2_mq_full(struct c2_mq *q)91{92return q->priv == (be16_to_cpu(*q->shared) + q->q_size - 1) % q->q_size;93}9495extern void c2_mq_lconsume(struct c2_mq *q, u32 wqe_count);96extern void *c2_mq_alloc(struct c2_mq *q);97extern void c2_mq_produce(struct c2_mq *q);98extern void *c2_mq_consume(struct c2_mq *q);99extern void c2_mq_free(struct c2_mq *q);100extern void c2_mq_req_init(struct c2_mq *q, u32 index, u32 q_size, u32 msg_size,101u8 __iomem *pool_start, u16 __iomem *peer, u32 type);102extern void c2_mq_rep_init(struct c2_mq *q, u32 index, u32 q_size, u32 msg_size,103u8 *pool_start, u16 __iomem *peer, u32 type);104105#endif /* _C2_MQ_H_ */106107108