/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */1/*2* Copyright (c) 2005 Network Appliance, Inc. All rights reserved.3* Copyright (c) 2005 Open Grid Computing, Inc. All rights reserved.4*/56#ifndef IW_CM_H7#define IW_CM_H89#include <linux/in.h>10#include <rdma/ib_cm.h>1112struct iw_cm_id;1314enum iw_cm_event_type {15IW_CM_EVENT_CONNECT_REQUEST = 1, /* connect request received */16IW_CM_EVENT_CONNECT_REPLY, /* reply from active connect request */17IW_CM_EVENT_ESTABLISHED, /* passive side accept successful */18IW_CM_EVENT_DISCONNECT, /* orderly shutdown */19IW_CM_EVENT_CLOSE /* close complete */20};2122struct iw_cm_event {23enum iw_cm_event_type event;24int status;25struct sockaddr_storage local_addr;26struct sockaddr_storage remote_addr;27void *private_data;28void *provider_data;29u8 private_data_len;30u8 ord;31u8 ird;32};3334/**35* iw_cm_handler - Function to be called by the IW CM when delivering events36* to the client.37*38* @cm_id: The IW CM identifier associated with the event.39* @event: Pointer to the event structure.40*/41typedef int (*iw_cm_handler)(struct iw_cm_id *cm_id,42struct iw_cm_event *event);4344/**45* iw_event_handler - Function called by the provider when delivering provider46* events to the IW CM. Returns either 0 indicating the event was processed47* or -errno if the event could not be processed.48*49* @cm_id: The IW CM identifier associated with the event.50* @event: Pointer to the event structure.51*/52typedef int (*iw_event_handler)(struct iw_cm_id *cm_id,53struct iw_cm_event *event);5455struct iw_cm_id {56iw_cm_handler cm_handler; /* client callback function */57void *context; /* client cb context */58struct ib_device *device;59struct sockaddr_storage local_addr; /* local addr */60struct sockaddr_storage remote_addr;61struct sockaddr_storage m_local_addr; /* nmapped local addr */62struct sockaddr_storage m_remote_addr; /* nmapped rem addr */63void *provider_data; /* provider private data */64iw_event_handler event_handler; /* cb for provider65events */66/* Used by provider to add and remove refs on IW cm_id */67void (*add_ref)(struct iw_cm_id *);68void (*rem_ref)(struct iw_cm_id *);69u8 tos;70bool tos_set:1;71bool mapped:1;72bool afonly:1;73};7475struct iw_cm_conn_param {76const void *private_data;77u16 private_data_len;78u32 ord;79u32 ird;80u32 qpn;81};8283enum iw_flags {8485/*86* This flag allows the iwcm and iwpmd to still advertise87* mappings but the real and mapped port numbers are the88* same. Further, iwpmd will not bind any user socket to89* reserve the port. This is required for soft iwarp90* to play in the port mapped iwarp space.91*/92IW_F_NO_PORT_MAP = (1 << 0),93};9495/**96* iw_create_cm_id - Create an IW CM identifier.97*98* @device: The IB device on which to create the IW CM identier.99* @event_handler: User callback invoked to report events associated with the100* returned IW CM identifier.101* @context: User specified context associated with the id.102*/103struct iw_cm_id *iw_create_cm_id(struct ib_device *device,104iw_cm_handler cm_handler, void *context);105106/**107* iw_destroy_cm_id - Destroy an IW CM identifier.108*109* @cm_id: The previously created IW CM identifier to destroy.110*111* The client can assume that no events will be delivered for the CM ID after112* this function returns.113*/114void iw_destroy_cm_id(struct iw_cm_id *cm_id);115116/**117* iw_cm_listen - Listen for incoming connection requests on the118* specified IW CM id.119*120* @cm_id: The IW CM identifier.121* @backlog: The maximum number of outstanding un-accepted inbound listen122* requests to queue.123*124* The source address and port number are specified in the IW CM identifier125* structure.126*/127int iw_cm_listen(struct iw_cm_id *cm_id, int backlog);128129/**130* iw_cm_accept - Called to accept an incoming connect request.131*132* @cm_id: The IW CM identifier associated with the connection request.133* @iw_param: Pointer to a structure containing connection establishment134* parameters.135*136* The specified cm_id will have been provided in the event data for a137* CONNECT_REQUEST event. Subsequent events related to this connection will be138* delivered to the specified IW CM identifier prior and may occur prior to139* the return of this function. If this function returns a non-zero value, the140* client can assume that no events will be delivered to the specified IW CM141* identifier.142*/143int iw_cm_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *iw_param);144145/**146* iw_cm_reject - Reject an incoming connection request.147*148* @cm_id: Connection identifier associated with the request.149* @private_daa: Pointer to data to deliver to the remote peer as part of the150* reject message.151* @private_data_len: The number of bytes in the private_data parameter.152*153* The client can assume that no events will be delivered to the specified IW154* CM identifier following the return of this function. The private_data155* buffer is available for reuse when this function returns.156*/157int iw_cm_reject(struct iw_cm_id *cm_id, const void *private_data,158u8 private_data_len);159160/**161* iw_cm_connect - Called to request a connection to a remote peer.162*163* @cm_id: The IW CM identifier for the connection.164* @iw_param: Pointer to a structure containing connection establishment165* parameters.166*167* Events may be delivered to the specified IW CM identifier prior to the168* return of this function. If this function returns a non-zero value, the169* client can assume that no events will be delivered to the specified IW CM170* identifier.171*/172int iw_cm_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *iw_param);173174/**175* iw_cm_disconnect - Close the specified connection.176*177* @cm_id: The IW CM identifier to close.178* @abrupt: If 0, the connection will be closed gracefully, otherwise, the179* connection will be reset.180*181* The IW CM identifier is still active until the IW_CM_EVENT_CLOSE event is182* delivered.183*/184int iw_cm_disconnect(struct iw_cm_id *cm_id, int abrupt);185186/**187* iw_cm_init_qp_attr - Called to initialize the attributes of the QP188* associated with a IW CM identifier.189*190* @cm_id: The IW CM identifier associated with the QP191* @qp_attr: Pointer to the QP attributes structure.192* @qp_attr_mask: Pointer to a bit vector specifying which QP attributes are193* valid.194*/195int iw_cm_init_qp_attr(struct iw_cm_id *cm_id, struct ib_qp_attr *qp_attr,196int *qp_attr_mask);197198/**199* iwcm_reject_msg - return a pointer to a reject message string.200* @reason: Value returned in the REJECT event status field.201*/202const char *__attribute_const__ iwcm_reject_msg(int reason);203204#endif /* IW_CM_H */205206207