The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/irdma/irdma_cm.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * SPDX-License-Identifier: GPL-2.0 or Linux-OpenIB
    3  *
    4  * Copyright (c) 2015 - 2022 Intel Corporation
    5  *
    6  * This software is available to you under a choice of one of two
    7  * licenses.  You may choose to be licensed under the terms of the GNU
    8  * General Public License (GPL) Version 2, available from the file
    9  * COPYING in the main directory of this source tree, or the
   10  * OpenFabrics.org BSD license below:
   11  *
   12  *   Redistribution and use in source and binary forms, with or
   13  *   without modification, are permitted provided that the following
   14  *   conditions are met:
   15  *
   16  *    - Redistributions of source code must retain the above
   17  *      copyright notice, this list of conditions and the following
   18  *      disclaimer.
   19  *
   20  *    - Redistributions in binary form must reproduce the above
   21  *      copyright notice, this list of conditions and the following
   22  *      disclaimer in the documentation and/or other materials
   23  *      provided with the distribution.
   24  *
   25  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
   26  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
   27  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
   28  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
   29  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
   30  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
   31  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
   32  * SOFTWARE.
   33  */
   34 /*$FreeBSD$*/
   35 
   36 #ifndef IRDMA_CM_H
   37 #define IRDMA_CM_H
   38 
   39 #define IRDMA_MPA_REQUEST_ACCEPT        1
   40 #define IRDMA_MPA_REQUEST_REJECT        2
   41 
   42 /* IETF MPA -- defines */
   43 #define IEFT_MPA_KEY_REQ        "MPA ID Req Frame"
   44 #define IEFT_MPA_KEY_REP        "MPA ID Rep Frame"
   45 #define IETF_MPA_KEY_SIZE       16
   46 #define IETF_MPA_VER            1
   47 #define IETF_MAX_PRIV_DATA_LEN  512
   48 #define IETF_MPA_FRAME_SIZE     20
   49 #define IETF_RTR_MSG_SIZE       4
   50 #define IETF_MPA_V2_FLAG        0x10
   51 #define SNDMARKER_SEQNMASK      0x000001ff
   52 #define IRDMA_MAX_IETF_SIZE     32
   53 
   54 /* IETF RTR MSG Fields */
   55 #define IETF_PEER_TO_PEER       0x8000
   56 #define IETF_FLPDU_ZERO_LEN     0x4000
   57 #define IETF_RDMA0_WRITE        0x8000
   58 #define IETF_RDMA0_READ         0x4000
   59 #define IETF_NO_IRD_ORD         0x3fff
   60 
   61 #define MAX_PORTS       65536
   62 
   63 #define IRDMA_PASSIVE_STATE_INDICATED   0
   64 #define IRDMA_DO_NOT_SEND_RESET_EVENT   1
   65 #define IRDMA_SEND_RESET_EVENT          2
   66 
   67 #define MAX_IRDMA_IFS   4
   68 
   69 #define SET_ACK         1
   70 #define SET_SYN         2
   71 #define SET_FIN         4
   72 #define SET_RST         8
   73 
   74 #define TCP_OPTIONS_PADDING     3
   75 
   76 #define IRDMA_DEFAULT_RETRYS    64
   77 #define IRDMA_DEFAULT_RETRANS   32
   78 #define IRDMA_DEFAULT_TTL               0x40
   79 #define IRDMA_DEFAULT_RTT_VAR           6
   80 #define IRDMA_DEFAULT_SS_THRESH         0x3fffffff
   81 #define IRDMA_DEFAULT_REXMIT_THRESH     8
   82 
   83 #define IRDMA_RETRY_TIMEOUT     HZ
   84 #define IRDMA_SHORT_TIME        10
   85 #define IRDMA_LONG_TIME         (2 * HZ)
   86 #define IRDMA_MAX_TIMEOUT       ((unsigned long)(12 * HZ))
   87 
   88 #define IRDMA_CM_HASHTABLE_SIZE         1024
   89 #define IRDMA_CM_TCP_TIMER_INTERVAL     3000
   90 #define IRDMA_CM_DEFAULT_MTU            1540
   91 #define IRDMA_CM_DEFAULT_FRAME_CNT      10
   92 #define IRDMA_CM_THREAD_STACK_SIZE      256
   93 #define IRDMA_CM_DEFAULT_RCV_WND        64240
   94 #define IRDMA_CM_DEFAULT_RCV_WND_SCALED 0x3FFFC
   95 #define IRDMA_CM_DEFAULT_RCV_WND_SCALE  2
   96 #define IRDMA_CM_DEFAULT_FREE_PKTS      10
   97 #define IRDMA_CM_FREE_PKT_LO_WATERMARK  2
   98 #define IRDMA_CM_DEFAULT_MSS            536
   99 #define IRDMA_CM_DEFAULT_MPA_VER        2
  100 #define IRDMA_CM_DEFAULT_SEQ            0x159bf75f
  101 #define IRDMA_CM_DEFAULT_LOCAL_ID       0x3b47
  102 #define IRDMA_CM_DEFAULT_SEQ2           0x18ed5740
  103 #define IRDMA_CM_DEFAULT_LOCAL_ID2      0xb807
  104 #define IRDMA_MAX_CM_BUF                (IRDMA_MAX_IETF_SIZE + IETF_MAX_PRIV_DATA_LEN)
  105 
  106 enum ietf_mpa_flags {
  107         IETF_MPA_FLAGS_REJECT  = 0x20,
  108         IETF_MPA_FLAGS_CRC     = 0x40,
  109         IETF_MPA_FLAGS_MARKERS = 0x80,
  110 };
  111 
  112 enum irdma_timer_type {
  113         IRDMA_TIMER_TYPE_SEND,
  114         IRDMA_TIMER_TYPE_CLOSE,
  115 };
  116 
  117 enum option_nums {
  118         OPTION_NUM_EOL,
  119         OPTION_NUM_NONE,
  120         OPTION_NUM_MSS,
  121         OPTION_NUM_WINDOW_SCALE,
  122         OPTION_NUM_SACK_PERM,
  123         OPTION_NUM_SACK,
  124         OPTION_NUM_WRITE0 = 0xbc,
  125 };
  126 
  127 /* cm node transition states */
  128 enum irdma_cm_node_state {
  129         IRDMA_CM_STATE_UNKNOWN,
  130         IRDMA_CM_STATE_INITED,
  131         IRDMA_CM_STATE_LISTENING,
  132         IRDMA_CM_STATE_SYN_RCVD,
  133         IRDMA_CM_STATE_SYN_SENT,
  134         IRDMA_CM_STATE_ONE_SIDE_ESTABLISHED,
  135         IRDMA_CM_STATE_ESTABLISHED,
  136         IRDMA_CM_STATE_ACCEPTING,
  137         IRDMA_CM_STATE_MPAREQ_SENT,
  138         IRDMA_CM_STATE_MPAREQ_RCVD,
  139         IRDMA_CM_STATE_MPAREJ_RCVD,
  140         IRDMA_CM_STATE_OFFLOADED,
  141         IRDMA_CM_STATE_FIN_WAIT1,
  142         IRDMA_CM_STATE_FIN_WAIT2,
  143         IRDMA_CM_STATE_CLOSE_WAIT,
  144         IRDMA_CM_STATE_TIME_WAIT,
  145         IRDMA_CM_STATE_LAST_ACK,
  146         IRDMA_CM_STATE_CLOSING,
  147         IRDMA_CM_STATE_LISTENER_DESTROYED,
  148         IRDMA_CM_STATE_CLOSED,
  149 };
  150 
  151 enum mpa_frame_ver {
  152         IETF_MPA_V1 = 1,
  153         IETF_MPA_V2 = 2,
  154 };
  155 
  156 enum mpa_frame_key {
  157         MPA_KEY_REQUEST,
  158         MPA_KEY_REPLY,
  159 };
  160 
  161 enum send_rdma0 {
  162         SEND_RDMA_READ_ZERO  = 1,
  163         SEND_RDMA_WRITE_ZERO = 2,
  164 };
  165 
  166 enum irdma_tcpip_pkt_type {
  167         IRDMA_PKT_TYPE_UNKNOWN,
  168         IRDMA_PKT_TYPE_SYN,
  169         IRDMA_PKT_TYPE_SYNACK,
  170         IRDMA_PKT_TYPE_ACK,
  171         IRDMA_PKT_TYPE_FIN,
  172         IRDMA_PKT_TYPE_RST,
  173 };
  174 
  175 enum irdma_cm_listener_state {
  176         IRDMA_CM_LISTENER_PASSIVE_STATE = 1,
  177         IRDMA_CM_LISTENER_ACTIVE_STATE  = 2,
  178         IRDMA_CM_LISTENER_EITHER_STATE  = 3,
  179 };
  180 
  181 /* CM event codes */
  182 enum irdma_cm_event_type {
  183         IRDMA_CM_EVENT_UNKNOWN,
  184         IRDMA_CM_EVENT_ESTABLISHED,
  185         IRDMA_CM_EVENT_MPA_REQ,
  186         IRDMA_CM_EVENT_MPA_CONNECT,
  187         IRDMA_CM_EVENT_MPA_ACCEPT,
  188         IRDMA_CM_EVENT_MPA_REJECT,
  189         IRDMA_CM_EVENT_MPA_ESTABLISHED,
  190         IRDMA_CM_EVENT_CONNECTED,
  191         IRDMA_CM_EVENT_RESET,
  192         IRDMA_CM_EVENT_ABORTED,
  193 };
  194 
  195 struct ietf_mpa_v1 {
  196         u8 key[IETF_MPA_KEY_SIZE];
  197         u8 flags;
  198         u8 rev;
  199         __be16 priv_data_len;
  200         u8 priv_data[];
  201 };
  202 
  203 struct ietf_rtr_msg {
  204         __be16 ctrl_ird;
  205         __be16 ctrl_ord;
  206 };
  207 
  208 struct ietf_mpa_v2 {
  209         u8 key[IETF_MPA_KEY_SIZE];
  210         u8 flags;
  211         u8 rev;
  212         __be16 priv_data_len;
  213         struct ietf_rtr_msg rtr_msg;
  214         u8 priv_data[];
  215 };
  216 
  217 struct option_base {
  218         u8 optionnum;
  219         u8 len;
  220 };
  221 
  222 struct option_mss {
  223         u8 optionnum;
  224         u8 len;
  225         __be16 mss;
  226 };
  227 
  228 struct option_windowscale {
  229         u8 optionnum;
  230         u8 len;
  231         u8 shiftcount;
  232 };
  233 
  234 union all_known_options {
  235         char eol;
  236         struct option_base base;
  237         struct option_mss mss;
  238         struct option_windowscale windowscale;
  239 };
  240 
  241 struct irdma_timer_entry {
  242         struct list_head list;
  243         unsigned long timetosend; /* jiffies */
  244         struct irdma_puda_buf *sqbuf;
  245         u32 type;
  246         u32 retrycount;
  247         u32 retranscount;
  248         u32 context;
  249         u32 send_retrans;
  250         int close_when_complete;
  251 };
  252 
  253 /* CM context params */
  254 struct irdma_cm_tcp_context {
  255         u8 client;
  256         u32 loc_seq_num;
  257         u32 loc_ack_num;
  258         u32 rem_ack_num;
  259         u32 rcv_nxt;
  260         u32 loc_id;
  261         u32 rem_id;
  262         u32 snd_wnd;
  263         u32 max_snd_wnd;
  264         u32 rcv_wnd;
  265         u32 mss;
  266         u8 snd_wscale;
  267         u8 rcv_wscale;
  268 };
  269 
  270 struct irdma_apbvt_entry {
  271         struct hlist_node hlist;
  272         u32 use_cnt;
  273         u16 port;
  274 };
  275 
  276 struct irdma_cm_listener {
  277         struct list_head list;
  278         struct iw_cm_id *cm_id;
  279         struct irdma_cm_core *cm_core;
  280         struct irdma_device *iwdev;
  281         struct list_head child_listen_list;
  282         struct irdma_apbvt_entry *apbvt_entry;
  283         enum irdma_cm_listener_state listener_state;
  284         atomic_t refcnt;
  285         atomic_t pend_accepts_cnt;
  286         u32 loc_addr[4];
  287         u32 reused_node;
  288         int backlog;
  289         u16 loc_port;
  290         u16 vlan_id;
  291         u8 loc_mac[ETH_ALEN];
  292         u8 user_pri;
  293         u8 tos;
  294         bool qhash_set:1;
  295         bool ipv4:1;
  296 };
  297 
  298 struct irdma_kmem_info {
  299         void *addr;
  300         u32 size;
  301 };
  302 
  303 struct irdma_mpa_priv_info {
  304         const void *addr;
  305         u32 size;
  306 };
  307 
  308 struct irdma_cm_node {
  309         struct irdma_qp *iwqp;
  310         struct irdma_device *iwdev;
  311         struct irdma_sc_dev *dev;
  312         struct irdma_cm_tcp_context tcp_cntxt;
  313         struct irdma_cm_core *cm_core;
  314         struct irdma_timer_entry *send_entry;
  315         struct irdma_timer_entry *close_entry;
  316         struct irdma_cm_listener *listener;
  317         struct list_head timer_entry;
  318         struct list_head reset_entry;
  319         struct list_head teardown_entry;
  320         struct irdma_apbvt_entry *apbvt_entry;
  321         struct rcu_head rcu_head;
  322         struct irdma_mpa_priv_info pdata;
  323         struct irdma_sc_ah *ah;
  324         struct irdma_kmem_info mpa_hdr;
  325         struct iw_cm_id *cm_id;
  326         struct hlist_node list;
  327         struct completion establish_comp;
  328         spinlock_t retrans_list_lock; /* protect CM node rexmit updates*/
  329         atomic_t passive_state;
  330         atomic_t refcnt;
  331         enum irdma_cm_node_state state;
  332         enum send_rdma0 send_rdma0_op;
  333         enum mpa_frame_ver mpa_frame_rev;
  334         u32 loc_addr[4], rem_addr[4];
  335         u16 loc_port, rem_port;
  336         int apbvt_set;
  337         int accept_pend;
  338         u16 vlan_id;
  339         u16 ird_size;
  340         u16 ord_size;
  341         u16 mpav2_ird_ord;
  342         u16 lsmm_size;
  343         u8 pdata_buf[IETF_MAX_PRIV_DATA_LEN];
  344         u8 loc_mac[ETH_ALEN];
  345         u8 rem_mac[ETH_ALEN];
  346         u8 user_pri;
  347         u8 tos;
  348         bool ack_rcvd:1;
  349         bool qhash_set:1;
  350         bool ipv4:1;
  351         bool snd_mark_en:1;
  352         bool rcv_mark_en:1;
  353         bool do_lpb:1;
  354         bool accelerated:1;
  355         struct ietf_mpa_v2 mpa_v2_frame;
  356 };
  357 
  358 /* Used by internal CM APIs to pass CM information*/
  359 struct irdma_cm_info {
  360         struct iw_cm_id *cm_id;
  361         u16 loc_port;
  362         u16 rem_port;
  363         u32 loc_addr[4];
  364         u32 rem_addr[4];
  365         u32 qh_qpid;
  366         u16 vlan_id;
  367         int backlog;
  368         u8 user_pri;
  369         u8 tos;
  370         bool ipv4;
  371 };
  372 
  373 struct irdma_cm_event {
  374         enum irdma_cm_event_type type;
  375         struct irdma_cm_info cm_info;
  376         struct work_struct event_work;
  377         struct irdma_cm_node *cm_node;
  378 };
  379 
  380 struct irdma_cm_core {
  381         struct irdma_device *iwdev;
  382         struct irdma_sc_dev *dev;
  383         struct list_head listen_list;
  384         DECLARE_HASHTABLE(cm_hash_tbl, 8);
  385         DECLARE_HASHTABLE(apbvt_hash_tbl, 8);
  386         struct timer_list tcp_timer;
  387         struct workqueue_struct *event_wq;
  388         spinlock_t ht_lock; /* protect CM node (active side) list */
  389         spinlock_t listen_list_lock; /* protect listener list */
  390         spinlock_t apbvt_lock; /*serialize apbvt add/del entries*/
  391         u64 stats_nodes_created;
  392         u64 stats_nodes_destroyed;
  393         u64 stats_listen_created;
  394         u64 stats_listen_destroyed;
  395         u64 stats_listen_nodes_created;
  396         u64 stats_listen_nodes_destroyed;
  397         u64 stats_lpbs;
  398         u64 stats_accepts;
  399         u64 stats_rejects;
  400         u64 stats_connect_errs;
  401         u64 stats_passive_errs;
  402         u64 stats_pkt_retrans;
  403         u64 stats_backlog_drops;
  404         struct irdma_puda_buf *(*form_cm_frame)(struct irdma_cm_node *cm_node,
  405                                                 struct irdma_kmem_info *options,
  406                                                 struct irdma_kmem_info *hdr,
  407                                                 struct irdma_mpa_priv_info *pdata,
  408                                                 u8 flags);
  409         int (*cm_create_ah)(struct irdma_cm_node *cm_node, bool wait);
  410         void (*cm_free_ah)(struct irdma_cm_node *cm_node);
  411 };
  412 
  413 int irdma_schedule_cm_timer(struct irdma_cm_node *cm_node,
  414                             struct irdma_puda_buf *sqbuf,
  415                             enum irdma_timer_type type, int send_retrans,
  416                             int close_when_complete);
  417 
  418 static inline u8 irdma_tos2dscp(u8 tos)
  419 {
  420 #define IRDMA_DSCP_S 2
  421 #define IRDMA_DSCP GENMASK(7, 2)
  422         return FIELD_GET(IRDMA_DSCP, tos);
  423 }
  424 
  425 int irdma_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param);
  426 int irdma_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len);
  427 int irdma_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param);
  428 int irdma_create_listen(struct iw_cm_id *cm_id, int backlog);
  429 int irdma_destroy_listen(struct iw_cm_id *cm_id);
  430 int irdma_add_arp(struct irdma_pci_f *rf, u32 *ip, const u8 *mac);
  431 void irdma_cm_teardown_connections(struct irdma_device *iwdev, u32 *ipaddr,
  432                                    struct irdma_cm_info *nfo,
  433                                    bool disconnect_all);
  434 int irdma_cm_start(struct irdma_device *dev);
  435 int irdma_cm_stop(struct irdma_device *dev);
  436 bool irdma_ipv4_is_lpb(u32 loc_addr, u32 rem_addr);
  437 bool irdma_ipv6_is_lpb(u32 *loc_addr, u32 *rem_addr);
  438 int irdma_arp_table(struct irdma_pci_f *rf, u32 *ip_addr,
  439                     const u8 *mac_addr, u32 action);
  440 bool irdma_port_in_use(struct irdma_cm_core *cm_core, u16 port);
  441 void irdma_send_ack(struct irdma_cm_node *cm_node);
  442 void irdma_lpb_nop(struct irdma_sc_qp *qp);
  443 void irdma_rem_ref_cm_node(struct irdma_cm_node *cm_node);
  444 void irdma_add_conn_est_qh(struct irdma_cm_node *cm_node);
  445 #endif /* IRDMA_CM_H */

Cache object: 9545f1b23ec22b31ba1a4ddda26c7290


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.