Path: blob/master/drivers/infiniband/hw/amso1100/c2_provider.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*32*/3334#ifndef C2_PROVIDER_H35#define C2_PROVIDER_H36#include <linux/inetdevice.h>3738#include <rdma/ib_verbs.h>39#include <rdma/ib_pack.h>4041#include "c2_mq.h"42#include <rdma/iw_cm.h>4344#define C2_MPT_FLAG_ATOMIC (1 << 14)45#define C2_MPT_FLAG_REMOTE_WRITE (1 << 13)46#define C2_MPT_FLAG_REMOTE_READ (1 << 12)47#define C2_MPT_FLAG_LOCAL_WRITE (1 << 11)48#define C2_MPT_FLAG_LOCAL_READ (1 << 10)4950struct c2_buf_list {51void *buf;52DEFINE_DMA_UNMAP_ADDR(mapping);53};545556/* The user context keeps track of objects allocated for a57* particular user-mode client. */58struct c2_ucontext {59struct ib_ucontext ibucontext;60};6162struct c2_mtt;6364/* All objects associated with a PD are kept in the65* associated user context if present.66*/67struct c2_pd {68struct ib_pd ibpd;69u32 pd_id;70};7172struct c2_mr {73struct ib_mr ibmr;74struct c2_pd *pd;75struct ib_umem *umem;76};7778struct c2_av;7980enum c2_ah_type {81C2_AH_ON_HCA,82C2_AH_PCI_POOL,83C2_AH_KMALLOC84};8586struct c2_ah {87struct ib_ah ibah;88};8990struct c2_cq {91struct ib_cq ibcq;92spinlock_t lock;93atomic_t refcount;94int cqn;95int is_kernel;96wait_queue_head_t wait;9798u32 adapter_handle;99struct c2_mq mq;100};101102struct c2_wq {103spinlock_t lock;104};105struct iw_cm_id;106struct c2_qp {107struct ib_qp ibqp;108struct iw_cm_id *cm_id;109spinlock_t lock;110atomic_t refcount;111wait_queue_head_t wait;112int qpn;113114u32 adapter_handle;115u32 send_sgl_depth;116u32 recv_sgl_depth;117u32 rdma_write_sgl_depth;118u8 state;119120struct c2_mq sq_mq;121struct c2_mq rq_mq;122};123124struct c2_cr_query_attrs {125u32 local_addr;126u32 remote_addr;127u16 local_port;128u16 remote_port;129};130131static inline struct c2_pd *to_c2pd(struct ib_pd *ibpd)132{133return container_of(ibpd, struct c2_pd, ibpd);134}135136static inline struct c2_ucontext *to_c2ucontext(struct ib_ucontext *ibucontext)137{138return container_of(ibucontext, struct c2_ucontext, ibucontext);139}140141static inline struct c2_mr *to_c2mr(struct ib_mr *ibmr)142{143return container_of(ibmr, struct c2_mr, ibmr);144}145146147static inline struct c2_ah *to_c2ah(struct ib_ah *ibah)148{149return container_of(ibah, struct c2_ah, ibah);150}151152static inline struct c2_cq *to_c2cq(struct ib_cq *ibcq)153{154return container_of(ibcq, struct c2_cq, ibcq);155}156157static inline struct c2_qp *to_c2qp(struct ib_qp *ibqp)158{159return container_of(ibqp, struct c2_qp, ibqp);160}161162static inline int is_rnic_addr(struct net_device *netdev, u32 addr)163{164struct in_device *ind;165int ret = 0;166167ind = in_dev_get(netdev);168if (!ind)169return 0;170171for_ifa(ind) {172if (ifa->ifa_address == addr) {173ret = 1;174break;175}176}177endfor_ifa(ind);178in_dev_put(ind);179return ret;180}181#endif /* C2_PROVIDER_H */182183184