| 1 |
/* |
| 2 |
* Copyright (c) 2013. Intel Corporation. All rights reserved. |
| 3 |
* Copyright (c) 2006-2012. QLogic Corporation. All rights reserved. |
| 4 |
* Copyright (c) 2003-2006, PathScale, Inc. All rights reserved. |
| 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 |
* OpenIB.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 |
|
| 35 |
#ifndef _IPS_PROTO_H |
| 36 |
#define _IPS_PROTO_H |
| 37 |
|
| 38 |
#include "psm_user.h" |
| 39 |
|
| 40 |
#include "ips_recvhdrq.h" |
| 41 |
#include "ips_tid.h" |
| 42 |
#include "ips_scb.h" |
| 43 |
#include "ips_epstate.h" |
| 44 |
#include "ips_spio.h" |
| 45 |
#include "ips_stats.h" |
| 46 |
#include "ips_proto_am.h" |
| 47 |
#include "ips_tidflow.h" |
| 48 |
#include "ips_path_rec.h" |
| 49 |
|
| 50 |
typedef enum ips_path_type { |
| 51 |
IPS_PATH_LOW_PRIORITY, |
| 52 |
IPS_PATH_NORMAL_PRIORITY, |
| 53 |
IPS_PATH_HIGH_PRIORITY, |
| 54 |
IPS_PATH_MAX_PRIORITY |
| 55 |
} ips_path_type_t; |
| 56 |
|
| 57 |
/* |
| 58 |
* Local Endpoint info. |
| 59 |
* |
| 60 |
* Contains information necessary for composing packets for the local endpoint |
| 61 |
*/ |
| 62 |
struct ips_epinfo { |
| 63 |
uint32_t ep_baseqp; |
| 64 |
uint16_t ep_base_lid; |
| 65 |
uint8_t ep_lmc; |
| 66 |
uint8_t ep_pad; |
| 67 |
ibta_rate ep_link_rate; |
| 68 |
uint16_t ep_context; |
| 69 |
uint16_t ep_subcontext; |
| 70 |
uint16_t ep_hca_type; |
| 71 |
uint16_t ep_sl; /* IPATH_SL only when path record not used */ |
| 72 |
uint16_t ep_unit; |
| 73 |
uint16_t ep_mtu; |
| 74 |
uint16_t ep_piosize; |
| 75 |
uint16_t ep_hdrq_msg_size; |
| 76 |
uint16_t ep_pkey; /* PSM_PKEY only when path record not used */ |
| 77 |
uint64_t ep_timeout_ack; /* PSM_ERRCHK_TIMEOUT if no path record */ |
| 78 |
uint64_t ep_timeout_ack_max; |
| 79 |
uint32_t ep_timeout_ack_factor; |
| 80 |
}; |
| 81 |
|
| 82 |
/* |
| 83 |
* Remote Endpoint info. |
| 84 |
* |
| 85 |
* Contains information necessary for composing packets for a remote endpoint |
| 86 |
*/ |
| 87 |
#define IPS_MAX_PATH_LMC 3 |
| 88 |
struct ips_epinfo_remote { |
| 89 |
uint32_t epr_qp; /* qp+context encoding */ |
| 90 |
uint32_t epr_commidx_to; |
| 91 |
uint32_t epr_commidx_from; |
| 92 |
uint16_t epr_piosize; |
| 93 |
uint16_t epr_context; /* Real context value */ |
| 94 |
uint16_t epr_subcontext; |
| 95 |
uint8_t epr_hca_type; |
| 96 |
uint8_t epr_hpp_index; |
| 97 |
|
| 98 |
/* For LMC/Torus keep list of base and max dlid. Used for pkt verification */ |
| 99 |
uint16_t epr_base_lid; |
| 100 |
uint16_t epr_pkt_context; /* Context encoding in packet header */ |
| 101 |
uint16_t epr_max_lid; |
| 102 |
uint8_t epr_num_paths[IPS_PATH_MAX_PRIORITY]; |
| 103 |
uint8_t epr_next_path[IPS_PATH_MAX_PRIORITY]; |
| 104 |
ips_path_rec_t *epr_path[IPS_PATH_MAX_PRIORITY][1 << IPS_MAX_PATH_LMC]; |
| 105 |
}; |
| 106 |
|
| 107 |
/* |
| 108 |
* Control messages. |
| 109 |
* |
| 110 |
* ips low-level control messages to ensure reliability of eager packets. |
| 111 |
* |
| 112 |
*/ |
| 113 |
struct ips_proto; |
| 114 |
psm_error_t |
| 115 |
ips_proto_init(const psmi_context_t *context, |
| 116 |
const struct ptl *ptl, |
| 117 |
int num_of_send_bufs, int num_of_send_desc, uint32_t imm_size, |
| 118 |
const struct psmi_timer_ctrl *timerq, /* PTL's timerq */ |
| 119 |
const struct ips_epstate *epstate, /* PTL's epstate */ |
| 120 |
const struct ips_spio *spioc, /* PTL's spio control */ |
| 121 |
struct ips_proto *proto); /* output protocol */ |
| 122 |
|
| 123 |
psm_error_t ips_proto_fini(struct ips_proto *proto, int force, |
| 124 |
uint64_t timeout); |
| 125 |
|
| 126 |
/* |
| 127 |
* For writev support, we need to pass the pbc along with the message header |
| 128 |
*/ |
| 129 |
struct ips_pbc_header { |
| 130 |
union ipath_pbc pbc; |
| 131 |
struct ips_message_header hdr; |
| 132 |
} PSMI_CACHEALIGN; |
| 133 |
|
| 134 |
/* |
| 135 |
* Control message structures |
| 136 |
*/ |
| 137 |
#define CTRL_MSG_QEUEUE_SIZE 32 /* power of two */ |
| 138 |
|
| 139 |
struct ips_proto_ctrl_message { |
| 140 |
struct ips_pbc_header pbc_hdr; |
| 141 |
uint8_t _hdr_uwords[IPS_HEADER_QUEUE_UWORDS_MAX<<2]; |
| 142 |
} PSMI_CACHEALIGN; |
| 143 |
|
| 144 |
/* Control messages saved in the control queue. Even though we only |
| 145 |
* always send 2 ptl_args on the wire, some message types will save |
| 146 |
* more than 16 bytes in arguments. |
| 147 |
*/ |
| 148 |
struct ips_flow; |
| 149 |
struct ips_tid_recv_desc; |
| 150 |
|
| 151 |
struct ips_ctrlq_elem { |
| 152 |
struct ptl_epaddr *ipsaddr; |
| 153 |
uint8_t message_type; |
| 154 |
uint8_t flowid; |
| 155 |
uint16_t pad; |
| 156 |
uint32_t *msg_queue_mask; |
| 157 |
struct ips_flow *flow; |
| 158 |
ptl_arg_t args[3]; |
| 159 |
}; |
| 160 |
|
| 161 |
struct ips_ctrlq { |
| 162 |
/* Queued control messages, queued when pio is busy */ |
| 163 |
struct ips_proto *ctrlq_proto; |
| 164 |
|
| 165 |
int ctrlq_flowid; |
| 166 |
uint32_t ctrlq_head; |
| 167 |
uint32_t ctrlq_tail; |
| 168 |
uint32_t ctrlq_overflow; |
| 169 |
uint32_t ctrlq_never_enqueue; |
| 170 |
|
| 171 |
struct ips_ctrlq_elem ctrlq_cqe[CTRL_MSG_QEUEUE_SIZE] PSMI_CACHEALIGN; |
| 172 |
struct psmi_timer ctrlq_timer; /* when in timerq */ |
| 173 |
}; |
| 174 |
|
| 175 |
/* |
| 176 |
* Connect/disconnect, as implemented by ips |
| 177 |
*/ |
| 178 |
psm_error_t ips_proto_connect(struct ips_proto *proto, int numep, |
| 179 |
const psm_epid_t *array_of_epid, |
| 180 |
const int *array_of_epid_mask, |
| 181 |
psm_error_t *array_of_errors, |
| 182 |
psm_epaddr_t *array_of_epaddr, |
| 183 |
uint64_t timeout_in); |
| 184 |
|
| 185 |
psm_error_t ips_proto_disconnect(struct ips_proto *proto, int force, int numep, |
| 186 |
const psm_epaddr_t array_of_epaddr[], |
| 187 |
const int array_of_epaddr_mask[], |
| 188 |
psm_error_t array_of_errors[], |
| 189 |
uint64_t timeout_in); |
| 190 |
|
| 191 |
int ips_proto_isconnected(struct ptl_epaddr *ipsaddr); |
| 192 |
|
| 193 |
/* |
| 194 |
* Pending operation structures |
| 195 |
*/ |
| 196 |
struct ips_pend_sreq { |
| 197 |
STAILQ_ENTRY(ips_pend_sreq) next; |
| 198 |
psm_mq_req_t req; |
| 199 |
uint32_t type; |
| 200 |
}; |
| 201 |
|
| 202 |
#define IPS_PENDSEND_EAGER_DATA 1 |
| 203 |
#define IPS_PENDSEND_EAGER_REQ 2 |
| 204 |
#define IPS_PENDSEND_EXP_TIDS 3 |
| 205 |
#define IPS_PENDSEND_EXP_SENDS 4 |
| 206 |
|
| 207 |
STAILQ_HEAD(ips_pendsendq, ips_pend_sreq); |
| 208 |
|
| 209 |
struct ips_pend_sends { |
| 210 |
struct ips_proto *proto; /* back ptr */ |
| 211 |
struct psmi_timer timer; |
| 212 |
struct ips_pendsendq pendq; |
| 213 |
}; |
| 214 |
|
| 215 |
/* |
| 216 |
* One instance of the protocol |
| 217 |
*/ |
| 218 |
|
| 219 |
struct ips_protoexp; |
| 220 |
|
| 221 |
struct ips_proto_stats { |
| 222 |
uint64_t pio_busy_cnt; |
| 223 |
uint64_t writev_busy_cnt; |
| 224 |
uint64_t writev_compl_eagain; |
| 225 |
uint64_t writev_compl_delay; |
| 226 |
uint64_t scb_egr_unavail_cnt; |
| 227 |
uint64_t scb_exp_unavail_cnt; |
| 228 |
uint64_t hdr_overflow; |
| 229 |
uint64_t egr_overflow; |
| 230 |
uint64_t lid_zero_errs; |
| 231 |
uint64_t unknown_packets; |
| 232 |
uint64_t stray_packets; |
| 233 |
uint64_t send_dma_misaligns; |
| 234 |
}; |
| 235 |
|
| 236 |
struct ips_proto_error_stats { |
| 237 |
uint64_t num_icrc_err; |
| 238 |
uint64_t num_vcrc_err; |
| 239 |
uint64_t num_ecc_err; |
| 240 |
uint64_t num_len_err; |
| 241 |
uint64_t num_mtu_err; |
| 242 |
uint64_t num_khdr_err; |
| 243 |
uint64_t num_tid_err; |
| 244 |
uint64_t num_mk_err; |
| 245 |
uint64_t num_ib_err; |
| 246 |
}; |
| 247 |
|
| 248 |
// OPP support structure. |
| 249 |
struct opp_api { |
| 250 |
void* (*op_path_find_hca)(const char*name, void **device); |
| 251 |
void* (*op_path_open)(void *device, int port_num); |
| 252 |
void (*op_path_close)(void *context); |
| 253 |
int (*op_path_get_path_by_rec)(void *context, ibta_path_rec_t *query, ibta_path_rec_t *response); |
| 254 |
/* TODO: Need symbol to ibv_close_device. */ |
| 255 |
}; |
| 256 |
|
| 257 |
struct ips_ibta_compliance_fn { |
| 258 |
psm_error_t (*get_path_rec)(struct ips_proto *proto, uint16_t slid, |
| 259 |
uint16_t dlid, uint16_t desthca_type, |
| 260 |
unsigned long timeout, |
| 261 |
ips_epaddr_t *ipsaddr); |
| 262 |
psm_error_t (*fini)(struct ips_proto *proto); |
| 263 |
}; |
| 264 |
|
| 265 |
typedef enum ptl_epaddr_flow { |
| 266 |
EP_FLOW_GO_BACK_N_PIO, |
| 267 |
EP_FLOW_GO_BACK_N_DMA, |
| 268 |
EP_FLOW_GO_BACK_N_AM_REQ, |
| 269 |
EP_FLOW_GO_BACK_N_AM_RSP, |
| 270 |
EP_FLOW_LAST /* Keep this the last endpoint flow */ |
| 271 |
} ptl_epaddr_flow_t; |
| 272 |
|
| 273 |
struct ips_proto { |
| 274 |
struct ptl *ptl; /* cached */ |
| 275 |
psm_ep_t ep; /* cached, for errors */ |
| 276 |
psm_mq_t mq; /* cached, for mq handling */ |
| 277 |
int fd; /* cached, for writev ops */ |
| 278 |
|
| 279 |
/* Pending sends */ |
| 280 |
struct ips_pend_sends pend_sends; |
| 281 |
struct ips_epstate *epstate; |
| 282 |
struct psmi_timer_ctrl *timerq; |
| 283 |
|
| 284 |
struct ips_protoexp *protoexp; |
| 285 |
struct ips_scbctrl *scbc_rv; |
| 286 |
struct ips_spio *spioc; |
| 287 |
struct ips_scbctrl scbc_egr; |
| 288 |
struct ips_epinfo epinfo; |
| 289 |
uint64_t timeout_send; |
| 290 |
uint32_t flags; |
| 291 |
uint32_t iovec_cntr_next_inflight; |
| 292 |
uint32_t iovec_cntr_last_completed; |
| 293 |
uint32_t iovec_thresh_eager; |
| 294 |
uint32_t iovec_thresh_eager_blocking; |
| 295 |
uint32_t scb_max_sdma; |
| 296 |
uint32_t scb_bufsize; |
| 297 |
uint16_t scb_max_inflight; |
| 298 |
uint16_t flow_credits; |
| 299 |
mpool_t pend_sends_pool; |
| 300 |
struct ips_ibta_compliance_fn ibta; |
| 301 |
struct ips_proto_stats stats; |
| 302 |
struct ips_proto_error_stats error_stats; |
| 303 |
|
| 304 |
struct ips_proto_am proto_am; |
| 305 |
|
| 306 |
struct ips_ctrlq ctrlq[EP_FLOW_LAST]; |
| 307 |
|
| 308 |
/* Handling tid errors */ |
| 309 |
uint32_t tiderr_cnt; |
| 310 |
uint32_t tiderr_max; |
| 311 |
uint64_t tiderr_tnext; |
| 312 |
uint64_t tiderr_warn_interval; |
| 313 |
uint32_t tiderr_context_tid_off; |
| 314 |
psm_epid_t tiderr_epid; |
| 315 |
|
| 316 |
uint64_t t_init; |
| 317 |
uint64_t t_fini; |
| 318 |
uint32_t runid_key; |
| 319 |
|
| 320 |
int num_connected_to; |
| 321 |
int num_connected_from; |
| 322 |
int num_disconnect_requests; |
| 323 |
|
| 324 |
/* misc state variables. */ |
| 325 |
// Smallest interval in cycles between which we warn about stray messages |
| 326 |
// This is a per-endpoint quantity, overridable with PSM_STRAY_WARN_INTERVAL |
| 327 |
// We use the same interval to send the "die" message. |
| 328 |
uint64_t stray_warn_interval; |
| 329 |
int done_warning; |
| 330 |
int done_once; |
| 331 |
int num_bogus_warnings; |
| 332 |
struct { |
| 333 |
uint32_t interval_secs; |
| 334 |
uint64_t next_warning; |
| 335 |
uint64_t count; |
| 336 |
} psmi_logevent_tid_send_reqs; |
| 337 |
|
| 338 |
/* SL2VL table for protocol */ |
| 339 |
int sl2vl[16]; |
| 340 |
|
| 341 |
/* CCA per port */ |
| 342 |
uint16_t *cct; /* cct table */ |
| 343 |
uint16_t ccti_size; /* ccti table size */ |
| 344 |
uint16_t ccti_limit; /* should be <= size-1 */ |
| 345 |
|
| 346 |
uint16_t ccti_portctrl; /* QP or SL CC */ |
| 347 |
uint16_t ccti_ctrlmap; /* map for valid sl */ |
| 348 |
struct cace { /* CACongestionEntry */ |
| 349 |
uint8_t ccti_increase; /* steps to increase */ |
| 350 |
//uint16_t ccti_timer; /* CCTI Timer in units of 1.024 usec */ |
| 351 |
uint64_t ccti_timer_cycles; /* coverted from us_2_cycles() */ |
| 352 |
uint8_t ccti_threshold; /* threshod to make log */ |
| 353 |
uint8_t ccti_min; /* min value for ccti */ |
| 354 |
} cace[16]; /* 16 service level */ |
| 355 |
|
| 356 |
/* Path record support */ |
| 357 |
uint8_t ips_ipd_delay[IBTA_RATE_120_GBPS + 1]; |
| 358 |
struct hsearch_data ips_path_rec_hash; |
| 359 |
void *opp_lib; |
| 360 |
void *hndl; |
| 361 |
void *device; |
| 362 |
void *opp_ctxt; |
| 363 |
struct opp_api opp_fn; |
| 364 |
|
| 365 |
/* |
| 366 |
* Control message queue for pending messages. |
| 367 |
* |
| 368 |
* Control messages are queued as pending when no PIO is available for sending |
| 369 |
* the message. They are composed on the fly and do not need buffering. |
| 370 |
* |
| 371 |
* Variables here are write once (at init) and read afterwards (except the msg |
| 372 |
* queue overflow counters). |
| 373 |
*/ |
| 374 |
uint32_t ctrl_msg_queue_overflow; |
| 375 |
uint32_t ctrl_msg_queue_never_enqueue; |
| 376 |
uint32_t message_type_to_index[256]; |
| 377 |
#define message_type2index(proto, msg_type) (proto->message_type_to_index[(msg_type)] & ~CTRL_MSG_QUEUE_ALWAYS) |
| 378 |
|
| 379 |
}; |
| 380 |
|
| 381 |
/* |
| 382 |
* Updates to these stats must be reflected in ips_ptl_epaddr_stats_init |
| 383 |
*/ |
| 384 |
struct ptl_epaddr_stats { |
| 385 |
uint64_t err_chk_send; |
| 386 |
uint64_t err_chk_recv; |
| 387 |
uint64_t nak_send; |
| 388 |
uint64_t nak_recv; |
| 389 |
uint64_t connect_req; |
| 390 |
uint64_t disconnect_req; |
| 391 |
uint64_t tids_grant_send; |
| 392 |
uint64_t tids_grant_recv; |
| 393 |
uint64_t send_rexmit; |
| 394 |
uint64_t congestion_pkts; /* IB CCA FECN packets */ |
| 395 |
}; |
| 396 |
|
| 397 |
/* |
| 398 |
* Endpoint address, encapsulates per-endpoint protocol metadata |
| 399 |
* |
| 400 |
* Directly implements the ptl epaddr. |
| 401 |
*/ |
| 402 |
|
| 403 |
/* |
| 404 |
* Flow index (6 bits) encodes the following: |
| 405 |
* |
| 406 |
* Protocol: 3 bits |
| 407 |
* Flow Index: 3 bits |
| 408 |
* |
| 409 |
* Currently only two protocols supported: Go Back N (the "original" flow) |
| 410 |
* and the TIDFLOW. We may look at adding other protocols like |
| 411 |
* Selective ACK and maybe even STCP. |
| 412 |
* |
| 413 |
* The Flow index is protocol specific. For a Go Back N protocol this usually |
| 414 |
* refers to the index of the flow between two endpoints. For TIDFLOWS |
| 415 |
* this is not currently used. |
| 416 |
*/ |
| 417 |
|
| 418 |
#define IPS_MAX_PROTOCOL 8 |
| 419 |
#define IPS_MAX_FLOWINDEX 8 |
| 420 |
|
| 421 |
#define IPS_FLOWID_PACK(protocol,flowindex) \ |
| 422 |
( ((((uint16_t)protocol)&0x7) << 3) | \ |
| 423 |
(((uint16_t)flowindex)&0x7) ) |
| 424 |
|
| 425 |
#define IPS_FLOWID_GET_PROTO(flow) (((flow)>>3)&0x7) |
| 426 |
#define IPS_FLOWID_GET_INDEX(flow) ((flow) % 4) |
| 427 |
|
| 428 |
#define IPS_FLOWID2INDEX(flow) \ |
| 429 |
((flow)&0x7) |
| 430 |
|
| 431 |
typedef void (*ips_flow_enqueue_fn_t)(struct ips_flow *flow, ips_scb_t *scb); |
| 432 |
typedef psm_error_t (*ips_flow_flush_fn_t)(struct ips_flow *, int *nflushed); |
| 433 |
typedef void (*ips_flow_nak_postprocess_fn_t)(struct ips_flow *, struct ips_message_header *p_hdr); |
| 434 |
|
| 435 |
typedef enum psm_transfer_type { |
| 436 |
PSM_TRANSFER_PIO, |
| 437 |
PSM_TRANSFER_DMA, |
| 438 |
PSM_TRANSFER_LAST /* Keep this the last transfer type */ |
| 439 |
} psm_transfer_type_t; |
| 440 |
|
| 441 |
typedef enum psm_protocol_type { |
| 442 |
PSM_PROTOCOL_GO_BACK_N, |
| 443 |
PSM_PROTOCOL_TIDFLOW, |
| 444 |
PSM_PROTOCOL_LAST /* Keep this the last protocol type */ |
| 445 |
} psm_protocol_type_t; |
| 446 |
|
| 447 |
struct ips_transfer_fn { |
| 448 |
/* Functions dealing with enqueuing and flushing scbs to the network */ |
| 449 |
ips_flow_enqueue_fn_t enqueue; |
| 450 |
ips_flow_flush_fn_t flush; |
| 451 |
}; |
| 452 |
|
| 453 |
struct ips_protocol_fn { |
| 454 |
/* FLOW_ADD: Other functions for is_valid etc. */ |
| 455 |
ips_flow_nak_postprocess_fn_t nak_post_process; |
| 456 |
}; |
| 457 |
|
| 458 |
struct ips_flow_fn { |
| 459 |
struct ips_transfer_fn xfer; |
| 460 |
struct ips_protocol_fn protocol; |
| 461 |
}; |
| 462 |
|
| 463 |
#define PIO_TRANSFER_FUNCTIONS { \ |
| 464 |
.enqueue = ips_proto_flow_enqueue, \ |
| 465 |
.flush = ips_proto_flow_flush_pio \ |
| 466 |
} |
| 467 |
|
| 468 |
#define DMA_TRANSFER_FUNCTIONS { \ |
| 469 |
.enqueue = ips_proto_flow_enqueue, \ |
| 470 |
.flush = ips_proto_flow_flush_dma \ |
| 471 |
} |
| 472 |
|
| 473 |
#define GO_BACK_N_PROTOCOL_FUNCTIONS { \ |
| 474 |
.nak_post_process = NULL \ |
| 475 |
} |
| 476 |
|
| 477 |
#define TIDFLOW_PROTOCOL_FUNCTIONS { \ |
| 478 |
.nak_post_process = ips_tidflow_nak_post_process \ |
| 479 |
} |
| 480 |
|
| 481 |
struct ips_flow { |
| 482 |
SLIST_ENTRY(ips_flow) next; /* List of flows with pending acks */ |
| 483 |
struct ips_flow_fn fn; |
| 484 |
|
| 485 |
struct ptl_epaddr *ipsaddr; /* back pointer, remote endpoint */ |
| 486 |
struct ips_epinfo *epinfo; /* back pointer, local epinfo */ |
| 487 |
ips_path_rec_t *path; /* Path to use for flow */ |
| 488 |
psm_transfer_type_t transfer; |
| 489 |
psm_protocol_type_t protocol; |
| 490 |
|
| 491 |
uint32_t flowid; |
| 492 |
uint32_t frag_size; |
| 493 |
uint16_t flags; |
| 494 |
uint16_t sl; |
| 495 |
uint16_t cca_ooo_pkts; |
| 496 |
uint16_t credits; /* Current credits available to send on flow */ |
| 497 |
uint16_t cwin; /* Size of congestion window */ |
| 498 |
uint16_t ack_interval; |
| 499 |
uint16_t msg_ooo_toggle; /* toggle for OOO message */ |
| 500 |
uint16_t msg_ooo_seqnum; /* seqnum for OOO message */ |
| 501 |
|
| 502 |
psmi_seqnum_t xmit_seq_num; |
| 503 |
psmi_seqnum_t xmit_ack_num; |
| 504 |
psmi_seqnum_t recv_seq_num; |
| 505 |
psmi_seqnum_t last_seq_num; |
| 506 |
|
| 507 |
uint32_t scb_num_pending; |
| 508 |
uint32_t scb_num_unacked; |
| 509 |
|
| 510 |
psmi_timer timer_send; /* timer for frames that got a busy PIO */ |
| 511 |
psmi_timer timer_ack; /* timer for unacked frames */ |
| 512 |
|
| 513 |
STAILQ_HEAD(ips_scb_unackedq, ips_scb) scb_unacked; |
| 514 |
SLIST_HEAD(ips_scb_pendlist, ips_scb) scb_pend; |
| 515 |
}; |
| 516 |
|
| 517 |
struct ptl_epaddr { |
| 518 |
struct ptl *ptl; /* cached */ |
| 519 |
psm_epaddr_t epaddr; /* back pointer to psm top-level epaddr */ |
| 520 |
struct ips_proto *proto; /* back pointer to protocol */ |
| 521 |
psm_mq_t mq; /* cached */ |
| 522 |
|
| 523 |
uint16_t flags; /* per-endpoint flags */ |
| 524 |
struct ips_epinfo_remote epr; /* remote endpoint params */ |
| 525 |
struct ips_flow flows[EP_FLOW_LAST] PSMI_CACHEALIGN; |
| 526 |
struct ips_flow tidgr_flow; /* tidflow */ |
| 527 |
|
| 528 |
uint32_t ctrl_msg_queued; /* bitmap of queued control messages to be send */ |
| 529 |
uint32_t delay_in_ms; /* used in close */ |
| 530 |
uint64_t s_timeout; /* used as a time in close */ |
| 531 |
int credit; |
| 532 |
|
| 533 |
pthread_mutex_t sesslock; |
| 534 |
struct ptl_epaddr_stats stats; |
| 535 |
|
| 536 |
uint32_t runid_key; |
| 537 |
uint16_t psm_verno; |
| 538 |
uint16_t connect_verno; /* The lowest connect version we can support */ |
| 539 |
uint16_t cstate_to; |
| 540 |
uint16_t cstate_from; |
| 541 |
psm_error_t cerror_to; |
| 542 |
psm_error_t cerror_from; |
| 543 |
} |
| 544 |
__attribute__((aligned(64))); |
| 545 |
|
| 546 |
|
| 547 |
/* |
| 548 |
* Send support on scbs. |
| 549 |
* |
| 550 |
*/ |
| 551 |
void ips_flow_init(struct ips_flow *flow, ips_path_rec_t *path, |
| 552 |
ips_epaddr_t *ipsaddr, |
| 553 |
psm_transfer_type_t transfer_type, |
| 554 |
psm_protocol_type_t protocol, ips_path_type_t path_type, |
| 555 |
uint32_t flow_index); |
| 556 |
|
| 557 |
void ips_scb_prepare_flow(ips_scb_t *scb, struct ips_epinfo *epinfo, |
| 558 |
struct ips_epinfo_remote *epr, struct ips_flow *flow); |
| 559 |
|
| 560 |
void ips_proto_flow_enqueue(struct ips_flow *flow, ips_scb_t *scb); |
| 561 |
|
| 562 |
psm_error_t ips_proto_flow_flush_pio(struct ips_flow *flow, int *nflushed); |
| 563 |
psm_error_t ips_proto_flow_flush_dma(struct ips_flow *flow, int *nflushed); |
| 564 |
|
| 565 |
/* Wrapper for enqueue + flush */ |
| 566 |
psm_error_t ips_proto_scb_pio_send(struct ips_flow *flow, ips_scb_t *scb); |
| 567 |
|
| 568 |
void ips_proto_scb_dma_enqueue(struct ips_proto *proto, ips_scb_t *scb); |
| 569 |
psm_error_t ips_proto_scb_dma_flush(struct ips_proto *proto, ips_epaddr_t *ipsaddr, |
| 570 |
int *nflushed); |
| 571 |
psm_error_t ips_proto_dma_wait_until(struct ips_proto *proto, uint32_t dma_ctr); |
| 572 |
psm_error_t ips_proto_dma_wait(struct ips_proto *proto, uint32_t dma_ctr, |
| 573 |
uint32_t *dma_ctr_out); |
| 574 |
|
| 575 |
psm_error_t ips_dma_transfer_frame(struct ips_proto *proto, |
| 576 |
struct ips_flow *flow, |
| 577 |
struct ips_pbc_header *pbc_hdr, |
| 578 |
void *payload, uint32_t paylen, |
| 579 |
uint32_t cksum); |
| 580 |
|
| 581 |
/* Special-case for expected sends */ |
| 582 |
void ips_protoexp_scb_inflight(ips_scb_t *scb); |
| 583 |
|
| 584 |
/* |
| 585 |
* Protocol receive processing |
| 586 |
* |
| 587 |
*/ |
| 588 |
/* NAK post processing for tidflows */ |
| 589 |
void ips_tidflow_nak_post_process(struct ips_flow *flow, |
| 590 |
struct ips_message_header *p_hdr); |
| 591 |
/* Actual receive processing is an inline in ips_proto_help.h */ |
| 592 |
int ips_proto_process_packet_inner(struct ips_recvhdrq_event *rcv_ev); |
| 593 |
/* Error handling for unknown packet, packet is unknown when epid doesn't match |
| 594 |
* in epstate table */ |
| 595 |
int ips_proto_process_unknown(const struct ips_recvhdrq_event *rcv_ev); |
| 596 |
/* Exposed for fastpath only */ |
| 597 |
void ips_proto_process_ack(struct ips_recvhdrq_event *rcv_ev); |
| 598 |
/* Handling error cases */ |
| 599 |
int ips_proto_process_packet_error(struct ips_recvhdrq_event *rcv_ev); |
| 600 |
|
| 601 |
/* |
| 602 |
* Protocol exception handling and frame dumps |
| 603 |
*/ |
| 604 |
void ips_proto_get_rhf_errstring(uint32_t err, char *msg, size_t len); |
| 605 |
void ips_proto_dump_err_stats(struct ips_proto *proto); |
| 606 |
void ips_proto_show_rhf_errors(const uint32_t *rhdr); |
| 607 |
void ips_proto_show_header(struct ips_message_header *p_hdr, char *msg); |
| 608 |
void ips_proto_dump_frame(void *frame, int lenght, char *message); |
| 609 |
void ips_proto_dump_data(void *data, int data_length); |
| 610 |
void ips_proto_dump_eager(uint32_t *curr_rcv_hdr); |
| 611 |
|
| 612 |
/* |
| 613 |
* Checksum of ips packets |
| 614 |
*/ |
| 615 |
uint32_t ips_crc_calculate(uint32_t len, uint8_t *data, uint32_t crc); |
| 616 |
|
| 617 |
/* |
| 618 |
* Expected send support |
| 619 |
*/ |
| 620 |
/* |
| 621 |
* The expsend token is currently always a pointer to a MQ request. It is |
| 622 |
* echoed on the wire throughout various phases of the expected send protocol |
| 623 |
* to identify a particular send. |
| 624 |
*/ |
| 625 |
typedef void (*ips_tid_completion_callback_t)(void *); |
| 626 |
|
| 627 |
psm_error_t ips_protoexp_init(const psmi_context_t *context, |
| 628 |
const struct ips_proto *proto, |
| 629 |
uint32_t protoexp_flags, |
| 630 |
int num_of_send_bufs, |
| 631 |
int num_of_send_desc, |
| 632 |
struct ips_protoexp **protoexp_o); |
| 633 |
|
| 634 |
psm_error_t ips_protoexp_fini(struct ips_protoexp *protoexp); |
| 635 |
void ips_protoexp_handle_tiderr(const struct ips_recvhdrq_event *rcv_ev); |
| 636 |
void ips_protoexp_handle_data_err(const struct ips_recvhdrq_event *rcv_ev); |
| 637 |
void ips_protoexp_handle_tf_seqerr(const struct ips_recvhdrq_event *rcv_ev); |
| 638 |
void ips_protoexp_handle_tf_generr(const struct ips_recvhdrq_event *rcv_ev); |
| 639 |
|
| 640 |
void ips_protoexp_recv_unaligned_data(struct ips_recvhdrq_event *rcv_ev); |
| 641 |
void ips_protoexp_data(struct ips_recvhdrq_event *rcv_ev); |
| 642 |
|
| 643 |
void ips_protoexp_tid_grant(const struct ips_recvhdrq_event *rcv_ev); |
| 644 |
void ips_protoexp_tid_grant_ack(const struct ips_recvhdrq_event *rcv_ev); |
| 645 |
int ips_protoexp_tid_release(const struct ips_recvhdrq_event *rcv_ev); |
| 646 |
void ips_protoexp_tid_release_ack(const struct ips_recvhdrq_event *rcv_ev); |
| 647 |
|
| 648 |
int ips_protoexp_build_ctrl_message(struct ips_protoexp *protoexp, |
| 649 |
struct ptl_epaddr *ipsaddr, |
| 650 |
ptl_arg_t *args, |
| 651 |
uint16_t *pkt_flags, |
| 652 |
uint8_t opcode, void *payload); |
| 653 |
psm_error_t ips_protoexp_flow_newgen(struct ips_tid_recv_desc *tidrecvc); |
| 654 |
|
| 655 |
/* |
| 656 |
* Peer is waiting (blocked) for this request |
| 657 |
*/ |
| 658 |
#define IPS_PROTOEXP_TIDGET_WAIT 0x1 |
| 659 |
#define IPS_PROTOEXP_TIDGET_PEERWAIT 0x2 |
| 660 |
psm_error_t ips_protoexp_tid_get_from_token(struct ips_protoexp *protoexp, |
| 661 |
void *buf, uint32_t length, |
| 662 |
psm_epaddr_t epaddr, |
| 663 |
uint32_t remote_tok, uint32_t flags, |
| 664 |
ips_tid_completion_callback_t callback, |
| 665 |
void *context); |
| 666 |
|
| 667 |
/* |
| 668 |
* Matched-Queue processing and sends |
| 669 |
*/ |
| 670 |
psm_error_t ips_proto_mq_push_eager_req(struct ips_proto *proto, |
| 671 |
psm_mq_req_t req); |
| 672 |
psm_error_t ips_proto_mq_push_eager_data(struct ips_proto *proto, |
| 673 |
psm_mq_req_t req); |
| 674 |
|
| 675 |
int ips_proto_mq_handle_cts(struct ips_proto *proto, ptl_arg_t *args); |
| 676 |
|
| 677 |
int ips_proto_mq_handle_rts_envelope(psm_mq_t mq, int mode, psm_epaddr_t epaddr, |
| 678 |
uint64_t tag, uint32_t reqidx_peer, |
| 679 |
uint32_t msglen); |
| 680 |
int ips_proto_mq_handle_rts_envelope_outoforder(psm_mq_t mq, int mode, |
| 681 |
psm_epaddr_t epaddr, uint16_t msg_seqnum, |
| 682 |
uint64_t tag, uint32_t reqidx_peer, |
| 683 |
uint32_t msglen); |
| 684 |
|
| 685 |
psm_error_t ips_proto_mq_send(psm_mq_t mq, psm_epaddr_t epaddr, |
| 686 |
uint32_t flags, uint64_t tag, const void *ubuf, |
| 687 |
uint32_t len); |
| 688 |
|
| 689 |
psm_error_t ips_proto_mq_isend(psm_mq_t mq, psm_epaddr_t epaddr, |
| 690 |
uint32_t flags, uint64_t tag, const void *ubuf, |
| 691 |
uint32_t len, void *context, psm_mq_req_t *req_o); |
| 692 |
|
| 693 |
int ips_proto_am(struct ips_recvhdrq_event *rcv_ev); |
| 694 |
|
| 695 |
/* IBTA feature related functions (path record, sl2vl etc.) */ |
| 696 |
psm_error_t ips_ibta_init_sl2vl_table(struct ips_proto *proto); |
| 697 |
psm_error_t ips_ibta_link_updown_event(struct ips_proto *proto); |
| 698 |
psm_error_t ips_ibta_init(struct ips_proto *proto); |
| 699 |
psm_error_t ips_ibta_fini(struct ips_proto *proto); |
| 700 |
|
| 701 |
#endif /* _IPS_PROTO_H */ |