16e76cdd6e3cfaac7d91c3b0644ee1bc6cf52347agiri * This file contains definitions imported from the OFED rds header ib.h.
16e76cdd6e3cfaac7d91c3b0644ee1bc6cf52347agiri * Oracle elects to have and use the contents of ib.h under and
16e76cdd6e3cfaac7d91c3b0644ee1bc6cf52347agiri * governed by the OpenIB.org BSD license.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota/* minor versions supported */
5e12ddada2833f3aa285210603ce9aaeb8be35ccEiji Ota#define RDSV3_IB_MAX_RECV_ALLOC ((512 * 1024 * 1024) / RDSV3_FRAG_SIZE)
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * IB posts RDSV3_FRAG_SIZE fragments of pages to the receive queues to
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * try and minimize the amount of memory tied up both the device and
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * socket receive queues.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota/* page offset of the final full frag that fits in the page */
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota (((PAGE_SIZE / RDSV3_FRAG_SIZE) - 1) * RDSV3_FRAG_SIZE)
5d5562f583b2b6affe19bdce0b3c8b1840d667a4Eiji Ota list_node_t ii_obj; /* list obj of rdsv3_inc_pool list */
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota /* Add new fields at the end, and don't permute existing fields. */
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota uint32_be_t dp_credit; /* non-zero enables flow ctl */
5d5562f583b2b6affe19bdce0b3c8b1840d667a4Eiji Ota * Rings are posted with all the allocations they'll need to queue the
5d5562f583b2b6affe19bdce0b3c8b1840d667a4Eiji Ota * incoming message to the receiving socket so this can't fail.
5d5562f583b2b6affe19bdce0b3c8b1840d667a4Eiji Ota * All fragments start with a header, so we can make sure we're not receiving
5d5562f583b2b6affe19bdce0b3c8b1840d667a4Eiji Ota * garbage, and we can tell a small 8 byte fragment from an ACK frame.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota /* alphabet soup, IBTA style */
5d5562f583b2b6affe19bdce0b3c8b1840d667a4Eiji Ota /* soft CQ */
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota /* sending acks */
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * Flow control related information
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * Our algorithm uses a pair variables that we need to access
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * atomically - one for the send credits, and one posted
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * recv credits we need to transfer to remote.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * Rather than protect them using a slow spinlock, we put both into
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * a single atomic_t and update it using cmpxchg
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota /* Protocol version specific information */
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota unsigned int i_flowctl:1; /* enable/disable flow ctl */
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota /* Batched completions */
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota/* This assumes that atomic_t is at least 32 bits */
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota/* bits for i_ack_flags */
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota/* Magic WR_ID for ACKs */
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otaextern void rdsv3_ib_remove_one(ib_device_t *device);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otaextern unsigned int fmr_pool_size;
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otaextern unsigned int fmr_message_size;
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otaextern unsigned int rdsv3_ib_retry_count;
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otaint rdsv3_ib_conn_alloc(struct rdsv3_connection *conn, int gfp);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otaint rdsv3_ib_conn_connect(struct rdsv3_connection *conn);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otavoid rdsv3_ib_conn_shutdown(struct rdsv3_connection *conn);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otavoid rdsv3_conn_drop(struct rdsv3_connection *conn);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otaint rdsv3_ib_cm_handle_connect(struct rdma_cm_id *cm_id,
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otaint rdsv3_ib_cm_initiate_connect(struct rdma_cm_id *cm_id);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otavoid rdsv3_ib_cm_connect_complete(struct rdsv3_connection *conn,
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otaint rdsv3_ib_update_ipaddr(struct rdsv3_ib_device *rds_ibdev,
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otavoid rdsv3_ib_add_conn(struct rdsv3_ib_device *rds_ibdev,
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otavoid rdsv3_ib_remove_conn(struct rdsv3_ib_device *rds_ibdev,
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otavoid __rdsv3_ib_destroy_conns(struct list *list, kmutex_t *list_lock);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otastatic inline void rdsv3_ib_destroy_nodev_conns(void)
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota __rdsv3_ib_destroy_conns(&ib_nodev_conns, &ib_nodev_conns_lock);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otastatic inline void rdsv3_ib_destroy_conns(struct rdsv3_ib_device *rds_ibdev)
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota __rdsv3_ib_destroy_conns(&rds_ibdev->conn_list, &rds_ibdev->spinlock);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otaint rdsv3_ib_create_mr_pool(struct rdsv3_ib_device *);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otavoid rdsv3_ib_destroy_mr_pool(struct rdsv3_ib_device *);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otavoid rdsv3_ib_get_mr_info(struct rdsv3_ib_device *rds_ibdev,
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Otavoid *rdsv3_ib_get_mr(struct rds_iovec *args, unsigned long nents,
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otavoid rdsv3_ib_sync_mr(void *trans_private, int dir);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otavoid rdsv3_ib_free_mr(void *trans_private, int invalidate);
5d5562f583b2b6affe19bdce0b3c8b1840d667a4Eiji Otaint rdsv3_ib_recv_refill(struct rdsv3_connection *conn, int prefill);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otaint rdsv3_ib_inc_copy_to_user(struct rdsv3_incoming *inc, uio_t *uiop,
5d5562f583b2b6affe19bdce0b3c8b1840d667a4Eiji Otavoid rdsv3_ib_recv_cqe_handler(struct rdsv3_ib_connection *ic, ibt_wc_t *wc,
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otavoid rdsv3_ib_recv_init_ring(struct rdsv3_ib_connection *ic);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otavoid rdsv3_ib_recv_clear_ring(struct rdsv3_ib_connection *ic);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otavoid rdsv3_ib_recv_init_ack(struct rdsv3_ib_connection *ic);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otavoid rdsv3_ib_attempt_ack(struct rdsv3_ib_connection *ic);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otavoid rdsv3_ib_ack_send_complete(struct rdsv3_ib_connection *ic);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otauint64_t rdsv3_ib_piggyb_ack(struct rdsv3_ib_connection *ic);
5d5562f583b2b6affe19bdce0b3c8b1840d667a4Eiji Otavoid rdsv3_ib_set_ack(struct rdsv3_ib_connection *ic, uint64_t seq,
5d5562f583b2b6affe19bdce0b3c8b1840d667a4Eiji Otaint rdsv3_ib_create_inc_pool(struct rdsv3_ib_device *);
5d5562f583b2b6affe19bdce0b3c8b1840d667a4Eiji Otavoid rdsv3_ib_destroy_inc_pool(struct rdsv3_ib_device *);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otavoid rdsv3_ib_ring_init(struct rdsv3_ib_work_ring *ring, uint32_t nr);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otavoid rdsv3_ib_ring_resize(struct rdsv3_ib_work_ring *ring, uint32_t nr);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otauint32_t rdsv3_ib_ring_alloc(struct rdsv3_ib_work_ring *ring, uint32_t val,
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otavoid rdsv3_ib_ring_free(struct rdsv3_ib_work_ring *ring, uint32_t val);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otavoid rdsv3_ib_ring_unalloc(struct rdsv3_ib_work_ring *ring, uint32_t val);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otaint rdsv3_ib_ring_empty(struct rdsv3_ib_work_ring *ring);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otaint rdsv3_ib_ring_low(struct rdsv3_ib_work_ring *ring);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otauint32_t rdsv3_ib_ring_oldest(struct rdsv3_ib_work_ring *ring);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otauint32_t rdsv3_ib_ring_completed(struct rdsv3_ib_work_ring *ring,
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otavoid rdsv3_ib_xmit_complete(struct rdsv3_connection *conn);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otaint rdsv3_ib_xmit(struct rdsv3_connection *conn, struct rdsv3_message *rm,
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota unsigned int hdr_off, unsigned int sg, unsigned int off);
5d5562f583b2b6affe19bdce0b3c8b1840d667a4Eiji Otavoid rdsv3_ib_send_cqe_handler(struct rdsv3_ib_connection *ic, ibt_wc_t *wc);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otavoid rdsv3_ib_send_init_ring(struct rdsv3_ib_connection *ic);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otavoid rdsv3_ib_send_clear_ring(struct rdsv3_ib_connection *ic);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otaint rdsv3_ib_xmit_rdma(struct rdsv3_connection *conn, struct rdsv3_rdma_op *op);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otavoid rdsv3_ib_send_add_credits(struct rdsv3_connection *conn,
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota unsigned int credits);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otavoid rdsv3_ib_advertise_credits(struct rdsv3_connection *conn,
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota unsigned int posted);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otaint rdsv3_ib_send_grab_credits(struct rdsv3_ib_connection *ic, uint32_t wanted,
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otaunsigned int rdsv3_ib_stats_info_copy(struct rdsv3_info_iterator *iter,
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota unsigned int avail);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otaextern unsigned long rdsv3_ib_sysctl_max_send_wr;
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otaextern unsigned long rdsv3_ib_sysctl_max_recv_wr;
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otaextern unsigned long rdsv3_ib_sysctl_max_unsig_wrs;
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otaextern unsigned long rdsv3_ib_sysctl_max_unsig_bytes;
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otaextern unsigned long rdsv3_ib_sysctl_max_recv_allocation;
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otaextern unsigned int rdsv3_ib_sysctl_flow_control;
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#endif /* _RDSV3_IB_H */