Thomas Gleixner | 2874c5f | 2019-05-27 08:55:01 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /****************************************************************************** |
| 3 | * |
| 4 | * (C)Copyright 1998,1999 SysKonnect, |
| 5 | * a business unit of Schneider & Koch & Co. Datensysteme GmbH. |
| 6 | * |
| 7 | * See the file "skfddi.c" for further information. |
| 8 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | * The information in this file is provided "AS IS" without warranty. |
| 10 | * |
| 11 | ******************************************************************************/ |
| 12 | |
| 13 | /* |
| 14 | * ******************************************************************* |
| 15 | * This SBA code implements the Synchronous Bandwidth Allocation |
| 16 | * functions described in the "FDDI Synchronous Forum Implementer's |
| 17 | * Agreement" dated December 1th, 1993. |
| 18 | * ******************************************************************* |
| 19 | * |
| 20 | * PURPOSE: The purpose of this function is to control |
| 21 | * synchronous allocations on a single FDDI segment. |
| 22 | * Allocations are limited to the primary FDDI ring. |
| 23 | * The SBM provides recovery mechanisms to recover |
| 24 | * unused bandwidth also resolves T_Neg and |
| 25 | * reconfiguration changes. Many of the SBM state |
| 26 | * machine inputs are sourced by the underlying |
| 27 | * FDDI sub-system supporting the SBA application. |
| 28 | * |
| 29 | * ******************************************************************* |
| 30 | */ |
| 31 | |
| 32 | #include "h/types.h" |
| 33 | #include "h/fddi.h" |
| 34 | #include "h/smc.h" |
| 35 | #include "h/smt_p.h" |
| 36 | |
| 37 | |
| 38 | #ifndef SLIM_SMT |
| 39 | |
| 40 | #ifdef ESS |
| 41 | |
| 42 | #ifndef lint |
| 43 | static const char ID_sccs[] = "@(#)ess.c 1.10 96/02/23 (C) SK" ; |
| 44 | #define LINT_USE(x) |
| 45 | #else |
| 46 | #define LINT_USE(x) (x)=(x) |
| 47 | #endif |
| 48 | #define MS2BCLK(x) ((x)*12500L) |
| 49 | |
| 50 | /* |
| 51 | ------------------------------------------------------------- |
| 52 | LOCAL VARIABLES: |
| 53 | ------------------------------------------------------------- |
| 54 | */ |
| 55 | |
| 56 | static const u_short plist_raf_alc_res[] = { SMT_P0012, SMT_P320B, SMT_P320F, |
| 57 | SMT_P3210, SMT_P0019, SMT_P001A, |
| 58 | SMT_P001D, 0 } ; |
| 59 | |
| 60 | static const u_short plist_raf_chg_req[] = { SMT_P320B, SMT_P320F, SMT_P3210, |
| 61 | SMT_P001A, 0 } ; |
| 62 | |
| 63 | static const struct fddi_addr smt_sba_da = {{0x80,0x01,0x43,0x00,0x80,0x0C}} ; |
| 64 | static const struct fddi_addr null_addr = {{0,0,0,0,0,0}} ; |
| 65 | |
| 66 | /* |
| 67 | ------------------------------------------------------------- |
| 68 | GLOBAL VARIABLES: |
| 69 | ------------------------------------------------------------- |
| 70 | */ |
| 71 | |
| 72 | |
| 73 | /* |
| 74 | ------------------------------------------------------------- |
| 75 | LOCAL FUNCTIONS: |
| 76 | ------------------------------------------------------------- |
| 77 | */ |
| 78 | |
| 79 | static void ess_send_response(struct s_smc *smc, struct smt_header *sm, |
| 80 | int sba_cmd); |
| 81 | static void ess_config_fifo(struct s_smc *smc); |
| 82 | static void ess_send_alc_req(struct s_smc *smc); |
| 83 | static void ess_send_frame(struct s_smc *smc, SMbuf *mb); |
| 84 | |
| 85 | /* |
| 86 | ------------------------------------------------------------- |
| 87 | EXTERNAL FUNCTIONS: |
| 88 | ------------------------------------------------------------- |
| 89 | */ |
| 90 | |
| 91 | /* |
| 92 | ------------------------------------------------------------- |
| 93 | PUBLIC FUNCTIONS: |
| 94 | ------------------------------------------------------------- |
| 95 | */ |
| 96 | |
| 97 | void ess_timer_poll(struct s_smc *smc); |
| 98 | void ess_para_change(struct s_smc *smc); |
| 99 | int ess_raf_received_pack(struct s_smc *smc, SMbuf *mb, struct smt_header *sm, |
| 100 | int fs); |
Adrian Bunk | 7aa55fc | 2005-06-21 01:47:06 -0700 | [diff] [blame] | 101 | static int process_bw_alloc(struct s_smc *smc, long int payload, long int overhead); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | |
| 103 | |
| 104 | /* |
| 105 | * -------------------------------------------------------------------------- |
| 106 | * End Station Support (ESS) |
| 107 | * -------------------------------------------------------------------------- |
| 108 | */ |
| 109 | |
| 110 | /* |
| 111 | * evaluate the RAF frame |
| 112 | */ |
| 113 | int ess_raf_received_pack(struct s_smc *smc, SMbuf *mb, struct smt_header *sm, |
| 114 | int fs) |
| 115 | { |
| 116 | void *p ; /* universal pointer */ |
| 117 | struct smt_p_0016 *cmd ; /* para: command for the ESS */ |
| 118 | SMbuf *db ; |
| 119 | u_long msg_res_type ; /* recource type */ |
| 120 | u_long payload, overhead ; |
| 121 | int local ; |
| 122 | int i ; |
| 123 | |
| 124 | /* |
| 125 | * Message Processing Code |
| 126 | */ |
| 127 | local = ((fs & L_INDICATOR) != 0) ; |
| 128 | |
| 129 | /* |
| 130 | * get the resource type |
| 131 | */ |
| 132 | if (!(p = (void *) sm_to_para(smc,sm,SMT_P0015))) { |
Joe Perches | 5671e8c | 2016-12-21 19:54:53 -0800 | [diff] [blame] | 133 | DB_ESS("ESS: RAF frame error, parameter type not found"); |
Eric Dumazet | 807540b | 2010-09-23 05:40:09 +0000 | [diff] [blame] | 134 | return fs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | } |
| 136 | msg_res_type = ((struct smt_p_0015 *)p)->res_type ; |
| 137 | |
| 138 | /* |
| 139 | * get the pointer to the ESS command |
| 140 | */ |
| 141 | if (!(cmd = (struct smt_p_0016 *) sm_to_para(smc,sm,SMT_P0016))) { |
| 142 | /* |
| 143 | * error in frame: para ESS command was not found |
| 144 | */ |
Joe Perches | 5671e8c | 2016-12-21 19:54:53 -0800 | [diff] [blame] | 145 | DB_ESS("ESS: RAF frame error, parameter command not found"); |
Eric Dumazet | 807540b | 2010-09-23 05:40:09 +0000 | [diff] [blame] | 146 | return fs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 147 | } |
| 148 | |
Joe Perches | 5671e8c | 2016-12-21 19:54:53 -0800 | [diff] [blame] | 149 | DB_ESSN(2, "fc %x ft %x", sm->smt_class, sm->smt_type); |
| 150 | DB_ESSN(2, "ver %x tran %x", sm->smt_version, sm->smt_tid); |
| 151 | DB_ESSN(2, "stn_id %s", addr_to_string(&sm->smt_source)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | |
Joe Perches | 5671e8c | 2016-12-21 19:54:53 -0800 | [diff] [blame] | 153 | DB_ESSN(2, "infolen %x res %lx", sm->smt_len, msg_res_type); |
| 154 | DB_ESSN(2, "sbacmd %x", cmd->sba_cmd); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 155 | |
| 156 | /* |
| 157 | * evaluate the ESS command |
| 158 | */ |
| 159 | switch (cmd->sba_cmd) { |
| 160 | |
| 161 | /* |
| 162 | * Process an ESS Allocation Request |
| 163 | */ |
| 164 | case REQUEST_ALLOCATION : |
| 165 | /* |
| 166 | * check for an RAF Request (Allocation Request) |
| 167 | */ |
| 168 | if (sm->smt_type == SMT_REQUEST) { |
| 169 | /* |
| 170 | * process the Allocation request only if the frame is |
| 171 | * local and no static allocation is used |
| 172 | */ |
| 173 | if (!local || smc->mib.fddiESSPayload) |
Eric Dumazet | 807540b | 2010-09-23 05:40:09 +0000 | [diff] [blame] | 174 | return fs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 175 | |
| 176 | p = (void *) sm_to_para(smc,sm,SMT_P0019) ; |
| 177 | for (i = 0; i < 5; i++) { |
| 178 | if (((struct smt_p_0019 *)p)->alloc_addr.a[i]) { |
Eric Dumazet | 807540b | 2010-09-23 05:40:09 +0000 | [diff] [blame] | 179 | return fs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 180 | } |
| 181 | } |
| 182 | |
| 183 | /* |
| 184 | * Note: The Application should send a LAN_LOC_FRAME. |
| 185 | * The ESS do not send the Frame to the network! |
| 186 | */ |
| 187 | smc->ess.alloc_trans_id = sm->smt_tid ; |
Joe Perches | 5671e8c | 2016-12-21 19:54:53 -0800 | [diff] [blame] | 188 | DB_ESS("ESS: save Alloc Req Trans ID %x", sm->smt_tid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 189 | p = (void *) sm_to_para(smc,sm,SMT_P320F) ; |
| 190 | ((struct smt_p_320f *)p)->mib_payload = |
| 191 | smc->mib.a[PATH0].fddiPATHSbaPayload ; |
| 192 | p = (void *) sm_to_para(smc,sm,SMT_P3210) ; |
| 193 | ((struct smt_p_3210 *)p)->mib_overhead = |
| 194 | smc->mib.a[PATH0].fddiPATHSbaOverhead ; |
| 195 | sm->smt_dest = smt_sba_da ; |
| 196 | |
| 197 | if (smc->ess.local_sba_active) |
Eric Dumazet | 807540b | 2010-09-23 05:40:09 +0000 | [diff] [blame] | 198 | return fs | I_INDICATOR; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 199 | |
| 200 | if (!(db = smt_get_mbuf(smc))) |
Eric Dumazet | 807540b | 2010-09-23 05:40:09 +0000 | [diff] [blame] | 201 | return fs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 202 | |
| 203 | db->sm_len = mb->sm_len ; |
| 204 | db->sm_off = mb->sm_off ; |
| 205 | memcpy(((char *)(db->sm_data+db->sm_off)),(char *)sm, |
| 206 | (int)db->sm_len) ; |
| 207 | dump_smt(smc, |
| 208 | (struct smt_header *)(db->sm_data+db->sm_off), |
| 209 | "RAF") ; |
| 210 | smt_send_frame(smc,db,FC_SMT_INFO,0) ; |
Eric Dumazet | 807540b | 2010-09-23 05:40:09 +0000 | [diff] [blame] | 211 | return fs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 212 | } |
| 213 | |
| 214 | /* |
| 215 | * The RAF frame is an Allocation Response ! |
| 216 | * check the parameters |
| 217 | */ |
| 218 | if (smt_check_para(smc,sm,plist_raf_alc_res)) { |
Joe Perches | 5671e8c | 2016-12-21 19:54:53 -0800 | [diff] [blame] | 219 | DB_ESS("ESS: RAF with para problem, ignoring"); |
Eric Dumazet | 807540b | 2010-09-23 05:40:09 +0000 | [diff] [blame] | 220 | return fs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 221 | } |
| 222 | |
| 223 | /* |
| 224 | * VERIFY THE FRAME IS WELL BUILT: |
| 225 | * |
| 226 | * 1. path index = primary ring only |
| 227 | * 2. resource type = sync bw only |
| 228 | * 3. trans action id = alloc_trans_id |
| 229 | * 4. reason code = success |
| 230 | * |
| 231 | * If any are violated, discard the RAF frame |
| 232 | */ |
| 233 | if ((((struct smt_p_320b *)sm_to_para(smc,sm,SMT_P320B))->path_index |
| 234 | != PRIMARY_RING) || |
| 235 | (msg_res_type != SYNC_BW) || |
| 236 | (((struct smt_p_reason *)sm_to_para(smc,sm,SMT_P0012))->rdf_reason |
| 237 | != SMT_RDF_SUCCESS) || |
| 238 | (sm->smt_tid != smc->ess.alloc_trans_id)) { |
| 239 | |
Joe Perches | 5671e8c | 2016-12-21 19:54:53 -0800 | [diff] [blame] | 240 | DB_ESS("ESS: Allocation Response not accepted"); |
Eric Dumazet | 807540b | 2010-09-23 05:40:09 +0000 | [diff] [blame] | 241 | return fs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 242 | } |
| 243 | |
| 244 | /* |
| 245 | * Extract message parameters |
| 246 | */ |
| 247 | p = (void *) sm_to_para(smc,sm,SMT_P320F) ; |
| 248 | if (!p) { |
| 249 | printk(KERN_ERR "ESS: sm_to_para failed"); |
| 250 | return fs; |
| 251 | } |
| 252 | payload = ((struct smt_p_320f *)p)->mib_payload ; |
| 253 | p = (void *) sm_to_para(smc,sm,SMT_P3210) ; |
| 254 | if (!p) { |
| 255 | printk(KERN_ERR "ESS: sm_to_para failed"); |
| 256 | return fs; |
| 257 | } |
| 258 | overhead = ((struct smt_p_3210 *)p)->mib_overhead ; |
| 259 | |
Joe Perches | 5671e8c | 2016-12-21 19:54:53 -0800 | [diff] [blame] | 260 | DB_ESSN(2, "payload= %lx overhead= %lx", |
| 261 | payload, overhead); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 262 | |
| 263 | /* |
| 264 | * process the bandwidth allocation |
| 265 | */ |
| 266 | (void)process_bw_alloc(smc,(long)payload,(long)overhead) ; |
| 267 | |
Eric Dumazet | 807540b | 2010-09-23 05:40:09 +0000 | [diff] [blame] | 268 | return fs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 269 | /* end of Process Allocation Request */ |
| 270 | |
| 271 | /* |
| 272 | * Process an ESS Change Request |
| 273 | */ |
| 274 | case CHANGE_ALLOCATION : |
| 275 | /* |
| 276 | * except only replies |
| 277 | */ |
| 278 | if (sm->smt_type != SMT_REQUEST) { |
Joe Perches | 5671e8c | 2016-12-21 19:54:53 -0800 | [diff] [blame] | 279 | DB_ESS("ESS: Do not process Change Responses"); |
Eric Dumazet | 807540b | 2010-09-23 05:40:09 +0000 | [diff] [blame] | 280 | return fs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 281 | } |
| 282 | |
| 283 | /* |
| 284 | * check the para for the Change Request |
| 285 | */ |
| 286 | if (smt_check_para(smc,sm,plist_raf_chg_req)) { |
Joe Perches | 5671e8c | 2016-12-21 19:54:53 -0800 | [diff] [blame] | 287 | DB_ESS("ESS: RAF with para problem, ignoring"); |
Eric Dumazet | 807540b | 2010-09-23 05:40:09 +0000 | [diff] [blame] | 288 | return fs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 289 | } |
| 290 | |
| 291 | /* |
| 292 | * Verify the path index and resource |
| 293 | * type are correct. If any of |
| 294 | * these are false, don't process this |
| 295 | * change request frame. |
| 296 | */ |
| 297 | if ((((struct smt_p_320b *)sm_to_para(smc,sm,SMT_P320B))->path_index |
| 298 | != PRIMARY_RING) || (msg_res_type != SYNC_BW)) { |
Joe Perches | 5671e8c | 2016-12-21 19:54:53 -0800 | [diff] [blame] | 299 | DB_ESS("ESS: RAF frame with para problem, ignoring"); |
Eric Dumazet | 807540b | 2010-09-23 05:40:09 +0000 | [diff] [blame] | 300 | return fs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 301 | } |
| 302 | |
| 303 | /* |
| 304 | * Extract message queue parameters |
| 305 | */ |
| 306 | p = (void *) sm_to_para(smc,sm,SMT_P320F) ; |
| 307 | payload = ((struct smt_p_320f *)p)->mib_payload ; |
| 308 | p = (void *) sm_to_para(smc,sm,SMT_P3210) ; |
| 309 | overhead = ((struct smt_p_3210 *)p)->mib_overhead ; |
| 310 | |
Joe Perches | 5671e8c | 2016-12-21 19:54:53 -0800 | [diff] [blame] | 311 | DB_ESSN(2, "ESS: Change Request from %s", |
| 312 | addr_to_string(&sm->smt_source)); |
| 313 | DB_ESSN(2, "payload= %lx overhead= %lx", |
| 314 | payload, overhead); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 315 | |
| 316 | /* |
| 317 | * process the bandwidth allocation |
| 318 | */ |
| 319 | if(!process_bw_alloc(smc,(long)payload,(long)overhead)) |
Eric Dumazet | 807540b | 2010-09-23 05:40:09 +0000 | [diff] [blame] | 320 | return fs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 321 | |
| 322 | /* |
| 323 | * send an RAF Change Reply |
| 324 | */ |
| 325 | ess_send_response(smc,sm,CHANGE_ALLOCATION) ; |
| 326 | |
Eric Dumazet | 807540b | 2010-09-23 05:40:09 +0000 | [diff] [blame] | 327 | return fs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 328 | /* end of Process Change Request */ |
| 329 | |
| 330 | /* |
| 331 | * Process Report Response |
| 332 | */ |
| 333 | case REPORT_ALLOCATION : |
| 334 | /* |
| 335 | * except only requests |
| 336 | */ |
| 337 | if (sm->smt_type != SMT_REQUEST) { |
Joe Perches | 5671e8c | 2016-12-21 19:54:53 -0800 | [diff] [blame] | 338 | DB_ESS("ESS: Do not process a Report Reply"); |
Eric Dumazet | 807540b | 2010-09-23 05:40:09 +0000 | [diff] [blame] | 339 | return fs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 340 | } |
| 341 | |
Joe Perches | 5671e8c | 2016-12-21 19:54:53 -0800 | [diff] [blame] | 342 | DB_ESSN(2, "ESS: Report Request from %s", |
| 343 | addr_to_string(&sm->smt_source)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 344 | |
| 345 | /* |
| 346 | * verify that the resource type is sync bw only |
| 347 | */ |
| 348 | if (msg_res_type != SYNC_BW) { |
Joe Perches | 5671e8c | 2016-12-21 19:54:53 -0800 | [diff] [blame] | 349 | DB_ESS("ESS: ignoring RAF with para problem"); |
Eric Dumazet | 807540b | 2010-09-23 05:40:09 +0000 | [diff] [blame] | 350 | return fs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 351 | } |
| 352 | |
| 353 | /* |
| 354 | * send an RAF Change Reply |
| 355 | */ |
| 356 | ess_send_response(smc,sm,REPORT_ALLOCATION) ; |
| 357 | |
Eric Dumazet | 807540b | 2010-09-23 05:40:09 +0000 | [diff] [blame] | 358 | return fs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 359 | /* end of Process Report Request */ |
| 360 | |
| 361 | default: |
| 362 | /* |
| 363 | * error in frame |
| 364 | */ |
Joe Perches | 5671e8c | 2016-12-21 19:54:53 -0800 | [diff] [blame] | 365 | DB_ESS("ESS: ignoring RAF with bad sba_cmd"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 366 | break ; |
| 367 | } |
| 368 | |
Eric Dumazet | 807540b | 2010-09-23 05:40:09 +0000 | [diff] [blame] | 369 | return fs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 370 | } |
| 371 | |
| 372 | /* |
| 373 | * determines the synchronous bandwidth, set the TSYNC register and the |
| 374 | * mib variables SBAPayload, SBAOverhead and fddiMACT-NEG. |
| 375 | */ |
Adrian Bunk | 7aa55fc | 2005-06-21 01:47:06 -0700 | [diff] [blame] | 376 | static int process_bw_alloc(struct s_smc *smc, long int payload, long int overhead) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 377 | { |
| 378 | /* |
| 379 | * determine the synchronous bandwidth (sync_bw) in bytes per T-NEG, |
| 380 | * if the payload is greater than zero. |
| 381 | * For the SBAPayload and the SBAOverhead we have the following |
| 382 | * unite quations |
| 383 | * _ _ |
| 384 | * | bytes | |
| 385 | * SBAPayload = | 8000 ------ | |
| 386 | * | s | |
| 387 | * - - |
| 388 | * _ _ |
| 389 | * | bytes | |
| 390 | * SBAOverhead = | ------ | |
| 391 | * | T-NEG | |
| 392 | * - - |
| 393 | * |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 394 | * T-NEG is described by the equation: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 395 | * |
| 396 | * (-) fddiMACT-NEG |
| 397 | * T-NEG = ------------------- |
| 398 | * 12500000 1/s |
| 399 | * |
| 400 | * The number of bytes we are able to send is the payload |
| 401 | * plus the overhead. |
| 402 | * |
| 403 | * bytes T-NEG SBAPayload 8000 bytes/s |
| 404 | * sync_bw = SBAOverhead ------ + ----------------------------- |
| 405 | * T-NEG T-NEG |
| 406 | * |
| 407 | * |
| 408 | * 1 |
| 409 | * sync_bw = SBAOverhead + ---- (-)fddiMACT-NEG * SBAPayload |
| 410 | * 1562 |
| 411 | * |
| 412 | */ |
| 413 | |
| 414 | /* |
| 415 | * set the mib attributes fddiPATHSbaOverhead, fddiPATHSbaPayload |
| 416 | */ |
| 417 | /* if (smt_set_obj(smc,SMT_P320F,payload,S_SET)) { |
Joe Perches | 5671e8c | 2016-12-21 19:54:53 -0800 | [diff] [blame] | 418 | DB_ESS("ESS: SMT does not accept the payload value"); |
Eric Dumazet | 807540b | 2010-09-23 05:40:09 +0000 | [diff] [blame] | 419 | return FALSE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 420 | } |
| 421 | if (smt_set_obj(smc,SMT_P3210,overhead,S_SET)) { |
Joe Perches | 5671e8c | 2016-12-21 19:54:53 -0800 | [diff] [blame] | 422 | DB_ESS("ESS: SMT does not accept the overhead value"); |
Eric Dumazet | 807540b | 2010-09-23 05:40:09 +0000 | [diff] [blame] | 423 | return FALSE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 424 | } */ |
| 425 | |
| 426 | /* premliminary */ |
| 427 | if (payload > MAX_PAYLOAD || overhead > 5000) { |
Joe Perches | 5671e8c | 2016-12-21 19:54:53 -0800 | [diff] [blame] | 428 | DB_ESS("ESS: payload / overhead not accepted"); |
Eric Dumazet | 807540b | 2010-09-23 05:40:09 +0000 | [diff] [blame] | 429 | return FALSE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 430 | } |
| 431 | |
| 432 | /* |
| 433 | * start the iterative allocation process if the payload or the overhead |
| 434 | * are smaller than the parsed values |
| 435 | */ |
| 436 | if (smc->mib.fddiESSPayload && |
| 437 | ((u_long)payload != smc->mib.fddiESSPayload || |
| 438 | (u_long)overhead != smc->mib.fddiESSOverhead)) { |
| 439 | smc->ess.raf_act_timer_poll = TRUE ; |
| 440 | smc->ess.timer_count = 0 ; |
| 441 | } |
| 442 | |
| 443 | /* |
| 444 | * evulate the Payload |
| 445 | */ |
| 446 | if (payload) { |
Joe Perches | 5671e8c | 2016-12-21 19:54:53 -0800 | [diff] [blame] | 447 | DB_ESSN(2, "ESS: turn SMT_ST_SYNC_SERVICE bit on"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 448 | smc->ess.sync_bw_available = TRUE ; |
| 449 | |
| 450 | smc->ess.sync_bw = overhead - |
| 451 | (long)smc->mib.m[MAC0].fddiMACT_Neg * |
| 452 | payload / 1562 ; |
| 453 | } |
| 454 | else { |
Joe Perches | 5671e8c | 2016-12-21 19:54:53 -0800 | [diff] [blame] | 455 | DB_ESSN(2, "ESS: turn SMT_ST_SYNC_SERVICE bit off"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 456 | smc->ess.sync_bw_available = FALSE ; |
| 457 | smc->ess.sync_bw = 0 ; |
| 458 | overhead = 0 ; |
| 459 | } |
| 460 | |
| 461 | smc->mib.a[PATH0].fddiPATHSbaPayload = payload ; |
| 462 | smc->mib.a[PATH0].fddiPATHSbaOverhead = overhead ; |
| 463 | |
| 464 | |
Joe Perches | 5671e8c | 2016-12-21 19:54:53 -0800 | [diff] [blame] | 465 | DB_ESSN(2, "tsync = %lx", smc->ess.sync_bw); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 466 | |
| 467 | ess_config_fifo(smc) ; |
| 468 | set_formac_tsync(smc,smc->ess.sync_bw) ; |
Eric Dumazet | 807540b | 2010-09-23 05:40:09 +0000 | [diff] [blame] | 469 | return TRUE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 470 | } |
| 471 | |
| 472 | static void ess_send_response(struct s_smc *smc, struct smt_header *sm, |
| 473 | int sba_cmd) |
| 474 | { |
| 475 | struct smt_sba_chg *chg ; |
| 476 | SMbuf *mb ; |
| 477 | void *p ; |
| 478 | |
| 479 | /* |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 480 | * get and initialize the response frame |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 481 | */ |
| 482 | if (sba_cmd == CHANGE_ALLOCATION) { |
| 483 | if (!(mb=smt_build_frame(smc,SMT_RAF,SMT_REPLY, |
| 484 | sizeof(struct smt_sba_chg)))) |
| 485 | return ; |
| 486 | } |
| 487 | else { |
| 488 | if (!(mb=smt_build_frame(smc,SMT_RAF,SMT_REPLY, |
| 489 | sizeof(struct smt_sba_rep_res)))) |
| 490 | return ; |
| 491 | } |
| 492 | |
| 493 | chg = smtod(mb,struct smt_sba_chg *) ; |
| 494 | chg->smt.smt_tid = sm->smt_tid ; |
| 495 | chg->smt.smt_dest = sm->smt_source ; |
| 496 | |
| 497 | /* set P15 */ |
| 498 | chg->s_type.para.p_type = SMT_P0015 ; |
| 499 | chg->s_type.para.p_len = sizeof(struct smt_p_0015) - PARA_LEN ; |
| 500 | chg->s_type.res_type = SYNC_BW ; |
| 501 | |
| 502 | /* set P16 */ |
| 503 | chg->cmd.para.p_type = SMT_P0016 ; |
| 504 | chg->cmd.para.p_len = sizeof(struct smt_p_0016) - PARA_LEN ; |
| 505 | chg->cmd.sba_cmd = sba_cmd ; |
| 506 | |
| 507 | /* set P320B */ |
| 508 | chg->path.para.p_type = SMT_P320B ; |
| 509 | chg->path.para.p_len = sizeof(struct smt_p_320b) - PARA_LEN ; |
| 510 | chg->path.mib_index = SBAPATHINDEX ; |
Takashi Iwai | c22ce6d | 2008-08-20 16:34:35 -0700 | [diff] [blame] | 511 | chg->path.path_pad = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 512 | chg->path.path_index = PRIMARY_RING ; |
| 513 | |
| 514 | /* set P320F */ |
| 515 | chg->payload.para.p_type = SMT_P320F ; |
| 516 | chg->payload.para.p_len = sizeof(struct smt_p_320f) - PARA_LEN ; |
| 517 | chg->payload.mib_index = SBAPATHINDEX ; |
| 518 | chg->payload.mib_payload = smc->mib.a[PATH0].fddiPATHSbaPayload ; |
| 519 | |
| 520 | /* set P3210 */ |
| 521 | chg->overhead.para.p_type = SMT_P3210 ; |
| 522 | chg->overhead.para.p_len = sizeof(struct smt_p_3210) - PARA_LEN ; |
| 523 | chg->overhead.mib_index = SBAPATHINDEX ; |
| 524 | chg->overhead.mib_overhead = smc->mib.a[PATH0].fddiPATHSbaOverhead ; |
| 525 | |
| 526 | if (sba_cmd == CHANGE_ALLOCATION) { |
| 527 | /* set P1A */ |
| 528 | chg->cat.para.p_type = SMT_P001A ; |
| 529 | chg->cat.para.p_len = sizeof(struct smt_p_001a) - PARA_LEN ; |
| 530 | p = (void *) sm_to_para(smc,sm,SMT_P001A) ; |
| 531 | chg->cat.category = ((struct smt_p_001a *)p)->category ; |
| 532 | } |
| 533 | dump_smt(smc,(struct smt_header *)chg,"RAF") ; |
| 534 | ess_send_frame(smc,mb) ; |
| 535 | } |
| 536 | |
| 537 | void ess_timer_poll(struct s_smc *smc) |
| 538 | { |
| 539 | if (!smc->ess.raf_act_timer_poll) |
| 540 | return ; |
| 541 | |
Joe Perches | 5671e8c | 2016-12-21 19:54:53 -0800 | [diff] [blame] | 542 | DB_ESSN(2, "ESS: timer_poll"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 543 | |
| 544 | smc->ess.timer_count++ ; |
| 545 | if (smc->ess.timer_count == 10) { |
| 546 | smc->ess.timer_count = 0 ; |
| 547 | ess_send_alc_req(smc) ; |
| 548 | } |
| 549 | } |
| 550 | |
| 551 | static void ess_send_alc_req(struct s_smc *smc) |
| 552 | { |
| 553 | struct smt_sba_alc_req *req ; |
| 554 | SMbuf *mb ; |
| 555 | |
| 556 | /* |
| 557 | * send never allocation request where the requested payload and |
Daniel Mack | 551e378 | 2010-01-28 16:11:51 +0800 | [diff] [blame] | 558 | * overhead is zero or deallocate bandwidth when no bandwidth is |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 559 | * parsed |
| 560 | */ |
| 561 | if (!smc->mib.fddiESSPayload) { |
| 562 | smc->mib.fddiESSOverhead = 0 ; |
| 563 | } |
| 564 | else { |
| 565 | if (!smc->mib.fddiESSOverhead) |
| 566 | smc->mib.fddiESSOverhead = DEFAULT_OV ; |
| 567 | } |
| 568 | |
| 569 | if (smc->mib.fddiESSOverhead == |
| 570 | smc->mib.a[PATH0].fddiPATHSbaOverhead && |
| 571 | smc->mib.fddiESSPayload == |
| 572 | smc->mib.a[PATH0].fddiPATHSbaPayload){ |
| 573 | smc->ess.raf_act_timer_poll = FALSE ; |
| 574 | smc->ess.timer_count = 7 ; /* next RAF alc req after 3 s */ |
| 575 | return ; |
| 576 | } |
| 577 | |
| 578 | /* |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 579 | * get and initialize the response frame |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 580 | */ |
| 581 | if (!(mb=smt_build_frame(smc,SMT_RAF,SMT_REQUEST, |
| 582 | sizeof(struct smt_sba_alc_req)))) |
| 583 | return ; |
| 584 | req = smtod(mb,struct smt_sba_alc_req *) ; |
| 585 | req->smt.smt_tid = smc->ess.alloc_trans_id = smt_get_tid(smc) ; |
| 586 | req->smt.smt_dest = smt_sba_da ; |
| 587 | |
| 588 | /* set P15 */ |
| 589 | req->s_type.para.p_type = SMT_P0015 ; |
| 590 | req->s_type.para.p_len = sizeof(struct smt_p_0015) - PARA_LEN ; |
| 591 | req->s_type.res_type = SYNC_BW ; |
| 592 | |
| 593 | /* set P16 */ |
| 594 | req->cmd.para.p_type = SMT_P0016 ; |
| 595 | req->cmd.para.p_len = sizeof(struct smt_p_0016) - PARA_LEN ; |
| 596 | req->cmd.sba_cmd = REQUEST_ALLOCATION ; |
| 597 | |
| 598 | /* |
Paulius Zaleckas | efad798b | 2008-02-03 15:42:53 +0200 | [diff] [blame] | 599 | * set the parameter type and parameter length of all used |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 600 | * parameters |
| 601 | */ |
| 602 | |
| 603 | /* set P320B */ |
| 604 | req->path.para.p_type = SMT_P320B ; |
| 605 | req->path.para.p_len = sizeof(struct smt_p_320b) - PARA_LEN ; |
| 606 | req->path.mib_index = SBAPATHINDEX ; |
Takashi Iwai | c22ce6d | 2008-08-20 16:34:35 -0700 | [diff] [blame] | 607 | req->path.path_pad = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 608 | req->path.path_index = PRIMARY_RING ; |
| 609 | |
| 610 | /* set P0017 */ |
| 611 | req->pl_req.para.p_type = SMT_P0017 ; |
| 612 | req->pl_req.para.p_len = sizeof(struct smt_p_0017) - PARA_LEN ; |
| 613 | req->pl_req.sba_pl_req = smc->mib.fddiESSPayload - |
| 614 | smc->mib.a[PATH0].fddiPATHSbaPayload ; |
| 615 | |
| 616 | /* set P0018 */ |
| 617 | req->ov_req.para.p_type = SMT_P0018 ; |
| 618 | req->ov_req.para.p_len = sizeof(struct smt_p_0018) - PARA_LEN ; |
| 619 | req->ov_req.sba_ov_req = smc->mib.fddiESSOverhead - |
| 620 | smc->mib.a[PATH0].fddiPATHSbaOverhead ; |
| 621 | |
| 622 | /* set P320F */ |
| 623 | req->payload.para.p_type = SMT_P320F ; |
| 624 | req->payload.para.p_len = sizeof(struct smt_p_320f) - PARA_LEN ; |
| 625 | req->payload.mib_index = SBAPATHINDEX ; |
| 626 | req->payload.mib_payload = smc->mib.a[PATH0].fddiPATHSbaPayload ; |
| 627 | |
| 628 | /* set P3210 */ |
| 629 | req->overhead.para.p_type = SMT_P3210 ; |
| 630 | req->overhead.para.p_len = sizeof(struct smt_p_3210) - PARA_LEN ; |
| 631 | req->overhead.mib_index = SBAPATHINDEX ; |
| 632 | req->overhead.mib_overhead = smc->mib.a[PATH0].fddiPATHSbaOverhead ; |
| 633 | |
| 634 | /* set P19 */ |
| 635 | req->a_addr.para.p_type = SMT_P0019 ; |
| 636 | req->a_addr.para.p_len = sizeof(struct smt_p_0019) - PARA_LEN ; |
Takashi Iwai | c22ce6d | 2008-08-20 16:34:35 -0700 | [diff] [blame] | 637 | req->a_addr.sba_pad = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 638 | req->a_addr.alloc_addr = null_addr ; |
| 639 | |
| 640 | /* set P1A */ |
| 641 | req->cat.para.p_type = SMT_P001A ; |
| 642 | req->cat.para.p_len = sizeof(struct smt_p_001a) - PARA_LEN ; |
| 643 | req->cat.category = smc->mib.fddiESSCategory ; |
| 644 | |
| 645 | /* set P1B */ |
| 646 | req->tneg.para.p_type = SMT_P001B ; |
| 647 | req->tneg.para.p_len = sizeof(struct smt_p_001b) - PARA_LEN ; |
| 648 | req->tneg.max_t_neg = smc->mib.fddiESSMaxTNeg ; |
| 649 | |
| 650 | /* set P1C */ |
| 651 | req->segm.para.p_type = SMT_P001C ; |
| 652 | req->segm.para.p_len = sizeof(struct smt_p_001c) - PARA_LEN ; |
| 653 | req->segm.min_seg_siz = smc->mib.fddiESSMinSegmentSize ; |
| 654 | |
| 655 | dump_smt(smc,(struct smt_header *)req,"RAF") ; |
| 656 | ess_send_frame(smc,mb) ; |
| 657 | } |
| 658 | |
| 659 | static void ess_send_frame(struct s_smc *smc, SMbuf *mb) |
| 660 | { |
| 661 | /* |
| 662 | * check if the frame must be send to the own ESS |
| 663 | */ |
| 664 | if (smc->ess.local_sba_active) { |
| 665 | /* |
| 666 | * Send the Change Reply to the local SBA |
| 667 | */ |
Joe Perches | 5671e8c | 2016-12-21 19:54:53 -0800 | [diff] [blame] | 668 | DB_ESS("ESS:Send to the local SBA"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 669 | if (!smc->ess.sba_reply_pend) |
| 670 | smc->ess.sba_reply_pend = mb ; |
| 671 | else { |
Joe Perches | 5671e8c | 2016-12-21 19:54:53 -0800 | [diff] [blame] | 672 | DB_ESS("Frame is lost - another frame was pending"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 673 | smt_free_mbuf(smc,mb) ; |
| 674 | } |
| 675 | } |
| 676 | else { |
| 677 | /* |
| 678 | * Send the SBA RAF Change Reply to the network |
| 679 | */ |
Joe Perches | 5671e8c | 2016-12-21 19:54:53 -0800 | [diff] [blame] | 680 | DB_ESS("ESS:Send to the network"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 681 | smt_send_frame(smc,mb,FC_SMT_INFO,0) ; |
| 682 | } |
| 683 | } |
| 684 | |
| 685 | void ess_para_change(struct s_smc *smc) |
| 686 | { |
| 687 | (void)process_bw_alloc(smc,(long)smc->mib.a[PATH0].fddiPATHSbaPayload, |
| 688 | (long)smc->mib.a[PATH0].fddiPATHSbaOverhead) ; |
| 689 | } |
| 690 | |
| 691 | static void ess_config_fifo(struct s_smc *smc) |
| 692 | { |
| 693 | /* |
| 694 | * if nothing to do exit |
| 695 | */ |
| 696 | if (smc->mib.a[PATH0].fddiPATHSbaPayload) { |
| 697 | if (smc->hw.fp.fifo.fifo_config_mode & SYNC_TRAFFIC_ON && |
| 698 | (smc->hw.fp.fifo.fifo_config_mode&SEND_ASYNC_AS_SYNC) == |
| 699 | smc->mib.fddiESSSynchTxMode) { |
| 700 | return ; |
| 701 | } |
| 702 | } |
| 703 | else { |
| 704 | if (!(smc->hw.fp.fifo.fifo_config_mode & SYNC_TRAFFIC_ON)) { |
| 705 | return ; |
| 706 | } |
| 707 | } |
| 708 | |
| 709 | /* |
| 710 | * split up the FIFO and reinitialize the queues |
| 711 | */ |
| 712 | formac_reinit_tx(smc) ; |
| 713 | } |
| 714 | |
| 715 | #endif /* ESS */ |
| 716 | |
| 717 | #endif /* no SLIM_SMT */ |
| 718 | |