| 1 |
/* |
| 2 |
* Copyright (c) 2006-2012. QLogic Corporation. All rights reserved. |
| 3 |
* Copyright (c) 2003-2006, PathScale, Inc. All rights reserved. |
| 4 |
* |
| 5 |
* This software is available to you under a choice of one of two |
| 6 |
* licenses. You may choose to be licensed under the terms of the GNU |
| 7 |
* General Public License (GPL) Version 2, available from the file |
| 8 |
* COPYING in the main directory of this source tree, or the |
| 9 |
* OpenIB.org BSD license below: |
| 10 |
* |
| 11 |
* Redistribution and use in source and binary forms, with or |
| 12 |
* without modification, are permitted provided that the following |
| 13 |
* conditions are met: |
| 14 |
* |
| 15 |
* - Redistributions of source code must retain the above |
| 16 |
* copyright notice, this list of conditions and the following |
| 17 |
* disclaimer. |
| 18 |
* |
| 19 |
* - Redistributions in binary form must reproduce the above |
| 20 |
* copyright notice, this list of conditions and the following |
| 21 |
* disclaimer in the documentation and/or other materials |
| 22 |
* provided with the distribution. |
| 23 |
* |
| 24 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 25 |
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 26 |
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 27 |
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS |
| 28 |
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
| 29 |
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 30 |
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 31 |
* SOFTWARE. |
| 32 |
*/ |
| 33 |
|
| 34 |
#ifndef _IPS_PTL_H |
| 35 |
#define _IPS_PTL_H |
| 36 |
|
| 37 |
#include "psm_user.h" |
| 38 |
#include "psm_mq_internal.h" |
| 39 |
|
| 40 |
#include "ips_proto_params.h" |
| 41 |
#include "ips_proto.h" |
| 42 |
#include "ips_spio.h" |
| 43 |
#include "ips_recvhdrq.h" |
| 44 |
#include "ips_writehdrq.h" |
| 45 |
#include "ips_epstate.h" |
| 46 |
#include "ips_stats.h" |
| 47 |
#include "ips_subcontext.h" |
| 48 |
|
| 49 |
struct ptl_shared; |
| 50 |
|
| 51 |
/* |
| 52 |
* PTL at the ips level (for InfiniPath) |
| 53 |
* |
| 54 |
* This PTL structure glues all the ips components together. |
| 55 |
* |
| 56 |
* * ips timer, shared by various components, allows each component to |
| 57 |
* schedule time-based expiration callbacks on the timerq. |
| 58 |
* * HW receive queue |
| 59 |
* * send control block to handle eager messages |
| 60 |
* * instantiation of the ips protocol |
| 61 |
* * endpoint state, to map endpoint indexes into structures |
| 62 |
* |
| 63 |
* Receive-side |
| 64 |
* |
| 65 |
* ----[ proto ] |
| 66 |
* / ^ ^ |
| 67 |
* | | | |
| 68 |
* | packet packet |
| 69 |
* | known unknown |
| 70 |
* add_endpt \ / |
| 71 |
* | | |
| 72 |
* `----> [epstate] |
| 73 |
* ^ |
| 74 |
* | |
| 75 |
* lookup_endpt |
| 76 |
* | |
| 77 |
* [recvq] |
| 78 |
* | |
| 79 |
* poll |
| 80 |
* |
| 81 |
*/ |
| 82 |
/* Updates to this struct must be reflected in PTL_IPS_SIZE in ptl_fwd.h */ |
| 83 |
/* IPS knows it functions as a PTL whenever ptl->ep is non-NULL */ |
| 84 |
struct ptl { |
| 85 |
psm_ep_t ep; /* back ptr */ |
| 86 |
psm_epid_t epid; /* cached from ep */ |
| 87 |
psm_epaddr_t epaddr; /* cached from ep */ |
| 88 |
ips_epaddr_t *ipsaddr; /* cached from epaddr */ |
| 89 |
ptl_ctl_t *ctl; /* cached from init */ |
| 90 |
const psmi_context_t *context; /* cached from init */ |
| 91 |
|
| 92 |
struct ips_spio spioc; /* PIO send control */ |
| 93 |
struct ips_proto proto; /* protocol instance: timerq, epstate, spio */ |
| 94 |
|
| 95 |
/* Receive header queue and receive queue processing */ |
| 96 |
uint32_t runtime_flags; |
| 97 |
struct psmi_timer_ctrl timerq; |
| 98 |
struct ips_epstate epstate; /* map incoming packets */ |
| 99 |
struct ips_recvhdrq_state recvq_state; |
| 100 |
struct ips_recvhdrq recvq; /* HW recvq: epstate, proto */ |
| 101 |
|
| 102 |
/* timer to check the context's status */ |
| 103 |
struct psmi_timer status_timer; |
| 104 |
|
| 105 |
/* context's status check timeout in cycles -- cached */ |
| 106 |
uint64_t status_cyc_timeout; |
| 107 |
|
| 108 |
/* Shared contexts context */ |
| 109 |
struct ptl_shared *recvshc; |
| 110 |
|
| 111 |
/* Rcv thread context */ |
| 112 |
struct ptl_rcvthread *rcvthread; |
| 113 |
}; |
| 114 |
|
| 115 |
/* |
| 116 |
* Sample implementation of shared contexts context. |
| 117 |
* |
| 118 |
* In shared mode, the hardware queue is serviced by more than one process. |
| 119 |
* Each process also mirrors the hardware queue in software (represented by an |
| 120 |
* ips_recvhdrq). For packets we service in the hardware queue that are not |
| 121 |
* destined for us, we write them in other processes's receive queues |
| 122 |
* (represented by an ips_writehdrq). |
| 123 |
* |
| 124 |
*/ |
| 125 |
struct ptl_shared { |
| 126 |
ptl_t *ptl; /* backptr to main ptl */ |
| 127 |
uint32_t subcontext; |
| 128 |
uint32_t subcontext_cnt; |
| 129 |
|
| 130 |
pthread_spinlock_t *context_lock; |
| 131 |
struct ips_subcontext_ureg *subcontext_ureg[INFINIPATH_MAX_SUBCONTEXT]; |
| 132 |
struct ips_recvhdrq recvq; /* subcontext receive queue */ |
| 133 |
struct ips_recvhdrq_state recvq_state; /* subcontext receive queue state */ |
| 134 |
struct ips_writehdrq writeq[INFINIPATH_MAX_SUBCONTEXT]; /* peer subcontexts */ |
| 135 |
}; |
| 136 |
|
| 137 |
/* |
| 138 |
* Connect/disconnect are wrappers around psm proto's connect/disconnect, |
| 139 |
* mostly to abstract away PSM-specific stuff from ips internal structures |
| 140 |
*/ |
| 141 |
psm_error_t ips_ptl_connect(ptl_t *ptl, int numep, |
| 142 |
const psm_epid_t *array_of_epid, |
| 143 |
const int *array_of_epid_mask, |
| 144 |
psm_error_t *array_of_errors, |
| 145 |
psm_epaddr_t *array_of_epaddr, |
| 146 |
uint64_t timeout_in); |
| 147 |
|
| 148 |
psm_error_t ips_ptl_disconnect(ptl_t *ptl, int force, int numep, |
| 149 |
const psm_epaddr_t array_of_epaddr[], |
| 150 |
const int array_of_epaddr_mask[], |
| 151 |
psm_error_t array_of_errors[], |
| 152 |
uint64_t timeout_in); |
| 153 |
|
| 154 |
/* |
| 155 |
* Generic Poll function for ips-level ptl |
| 156 |
*/ |
| 157 |
psm_error_t ips_ptl_poll(ptl_t *ptl, int _ignored); |
| 158 |
psm_error_t ips_ptl_shared_poll(ptl_t *ptl, int _ignored); |
| 159 |
|
| 160 |
/* |
| 161 |
* Support for receive thread |
| 162 |
*/ |
| 163 |
psm_error_t ips_ptl_rcvthread_init(ptl_t *ptl, struct ips_recvhdrq *recvq); |
| 164 |
psm_error_t ips_ptl_rcvthread_fini(ptl_t *ptl); |
| 165 |
|
| 166 |
#endif /* _IPS_PTL_H */ |