12874c5fdSThomas Gleixner // SPDX-License-Identifier: GPL-2.0-or-later
233f810b2SJeff Kirsher /******************************************************************************
333f810b2SJeff Kirsher *
433f810b2SJeff Kirsher * (C)Copyright 1998,1999 SysKonnect,
533f810b2SJeff Kirsher * a business unit of Schneider & Koch & Co. Datensysteme GmbH.
633f810b2SJeff Kirsher *
733f810b2SJeff Kirsher * See the file "skfddi.c" for further information.
833f810b2SJeff Kirsher *
933f810b2SJeff Kirsher * The information in this file is provided "AS IS" without warranty.
1033f810b2SJeff Kirsher *
1133f810b2SJeff Kirsher ******************************************************************************/
1233f810b2SJeff Kirsher
1333f810b2SJeff Kirsher /*
1433f810b2SJeff Kirsher * *******************************************************************
1533f810b2SJeff Kirsher * This SBA code implements the Synchronous Bandwidth Allocation
1633f810b2SJeff Kirsher * functions described in the "FDDI Synchronous Forum Implementer's
1733f810b2SJeff Kirsher * Agreement" dated December 1th, 1993.
1833f810b2SJeff Kirsher * *******************************************************************
1933f810b2SJeff Kirsher *
2033f810b2SJeff Kirsher * PURPOSE: The purpose of this function is to control
2133f810b2SJeff Kirsher * synchronous allocations on a single FDDI segment.
2233f810b2SJeff Kirsher * Allocations are limited to the primary FDDI ring.
2333f810b2SJeff Kirsher * The SBM provides recovery mechanisms to recover
2433f810b2SJeff Kirsher * unused bandwidth also resolves T_Neg and
2533f810b2SJeff Kirsher * reconfiguration changes. Many of the SBM state
2633f810b2SJeff Kirsher * machine inputs are sourced by the underlying
2733f810b2SJeff Kirsher * FDDI sub-system supporting the SBA application.
2833f810b2SJeff Kirsher *
2933f810b2SJeff Kirsher * *******************************************************************
3033f810b2SJeff Kirsher */
3133f810b2SJeff Kirsher
3233f810b2SJeff Kirsher #include "h/types.h"
3333f810b2SJeff Kirsher #include "h/fddi.h"
3433f810b2SJeff Kirsher #include "h/smc.h"
3533f810b2SJeff Kirsher #include "h/smt_p.h"
3633f810b2SJeff Kirsher
3733f810b2SJeff Kirsher
3833f810b2SJeff Kirsher #ifndef SLIM_SMT
3933f810b2SJeff Kirsher
4033f810b2SJeff Kirsher #ifdef ESS
4133f810b2SJeff Kirsher
4233f810b2SJeff Kirsher #ifndef lint
4333f810b2SJeff Kirsher #define LINT_USE(x)
4433f810b2SJeff Kirsher #else
4533f810b2SJeff Kirsher #define LINT_USE(x) (x)=(x)
4633f810b2SJeff Kirsher #endif
4733f810b2SJeff Kirsher #define MS2BCLK(x) ((x)*12500L)
4833f810b2SJeff Kirsher
4933f810b2SJeff Kirsher /*
5033f810b2SJeff Kirsher -------------------------------------------------------------
5133f810b2SJeff Kirsher LOCAL VARIABLES:
5233f810b2SJeff Kirsher -------------------------------------------------------------
5333f810b2SJeff Kirsher */
5433f810b2SJeff Kirsher
5533f810b2SJeff Kirsher static const u_short plist_raf_alc_res[] = { SMT_P0012, SMT_P320B, SMT_P320F,
5633f810b2SJeff Kirsher SMT_P3210, SMT_P0019, SMT_P001A,
5733f810b2SJeff Kirsher SMT_P001D, 0 } ;
5833f810b2SJeff Kirsher
5933f810b2SJeff Kirsher static const u_short plist_raf_chg_req[] = { SMT_P320B, SMT_P320F, SMT_P3210,
6033f810b2SJeff Kirsher SMT_P001A, 0 } ;
6133f810b2SJeff Kirsher
6233f810b2SJeff Kirsher static const struct fddi_addr smt_sba_da = {{0x80,0x01,0x43,0x00,0x80,0x0C}} ;
6333f810b2SJeff Kirsher static const struct fddi_addr null_addr = {{0,0,0,0,0,0}} ;
6433f810b2SJeff Kirsher
6533f810b2SJeff Kirsher /*
6633f810b2SJeff Kirsher -------------------------------------------------------------
6733f810b2SJeff Kirsher GLOBAL VARIABLES:
6833f810b2SJeff Kirsher -------------------------------------------------------------
6933f810b2SJeff Kirsher */
7033f810b2SJeff Kirsher
7133f810b2SJeff Kirsher
7233f810b2SJeff Kirsher /*
7333f810b2SJeff Kirsher -------------------------------------------------------------
7433f810b2SJeff Kirsher LOCAL FUNCTIONS:
7533f810b2SJeff Kirsher -------------------------------------------------------------
7633f810b2SJeff Kirsher */
7733f810b2SJeff Kirsher
7833f810b2SJeff Kirsher static void ess_send_response(struct s_smc *smc, struct smt_header *sm,
7933f810b2SJeff Kirsher int sba_cmd);
8033f810b2SJeff Kirsher static void ess_config_fifo(struct s_smc *smc);
8133f810b2SJeff Kirsher static void ess_send_alc_req(struct s_smc *smc);
8233f810b2SJeff Kirsher static void ess_send_frame(struct s_smc *smc, SMbuf *mb);
8333f810b2SJeff Kirsher
8433f810b2SJeff Kirsher /*
8533f810b2SJeff Kirsher -------------------------------------------------------------
8633f810b2SJeff Kirsher EXTERNAL FUNCTIONS:
8733f810b2SJeff Kirsher -------------------------------------------------------------
8833f810b2SJeff Kirsher */
8933f810b2SJeff Kirsher
9033f810b2SJeff Kirsher /*
9133f810b2SJeff Kirsher -------------------------------------------------------------
9233f810b2SJeff Kirsher PUBLIC FUNCTIONS:
9333f810b2SJeff Kirsher -------------------------------------------------------------
9433f810b2SJeff Kirsher */
9533f810b2SJeff Kirsher
9633f810b2SJeff Kirsher void ess_timer_poll(struct s_smc *smc);
9733f810b2SJeff Kirsher void ess_para_change(struct s_smc *smc);
9833f810b2SJeff Kirsher int ess_raf_received_pack(struct s_smc *smc, SMbuf *mb, struct smt_header *sm,
9933f810b2SJeff Kirsher int fs);
10033f810b2SJeff Kirsher static int process_bw_alloc(struct s_smc *smc, long int payload, long int overhead);
10133f810b2SJeff Kirsher
10233f810b2SJeff Kirsher
10333f810b2SJeff Kirsher /*
10433f810b2SJeff Kirsher * --------------------------------------------------------------------------
10533f810b2SJeff Kirsher * End Station Support (ESS)
10633f810b2SJeff Kirsher * --------------------------------------------------------------------------
10733f810b2SJeff Kirsher */
10833f810b2SJeff Kirsher
10933f810b2SJeff Kirsher /*
11033f810b2SJeff Kirsher * evaluate the RAF frame
11133f810b2SJeff Kirsher */
ess_raf_received_pack(struct s_smc * smc,SMbuf * mb,struct smt_header * sm,int fs)11233f810b2SJeff Kirsher int ess_raf_received_pack(struct s_smc *smc, SMbuf *mb, struct smt_header *sm,
11333f810b2SJeff Kirsher int fs)
11433f810b2SJeff Kirsher {
11533f810b2SJeff Kirsher void *p ; /* universal pointer */
11633f810b2SJeff Kirsher struct smt_p_0016 *cmd ; /* para: command for the ESS */
11733f810b2SJeff Kirsher SMbuf *db ;
11833f810b2SJeff Kirsher u_long msg_res_type ; /* recource type */
11933f810b2SJeff Kirsher u_long payload, overhead ;
12033f810b2SJeff Kirsher int local ;
12133f810b2SJeff Kirsher int i ;
12233f810b2SJeff Kirsher
12333f810b2SJeff Kirsher /*
12433f810b2SJeff Kirsher * Message Processing Code
12533f810b2SJeff Kirsher */
12633f810b2SJeff Kirsher local = ((fs & L_INDICATOR) != 0) ;
12733f810b2SJeff Kirsher
12833f810b2SJeff Kirsher /*
12933f810b2SJeff Kirsher * get the resource type
13033f810b2SJeff Kirsher */
13133f810b2SJeff Kirsher if (!(p = (void *) sm_to_para(smc,sm,SMT_P0015))) {
1325671e8c1SJoe Perches DB_ESS("ESS: RAF frame error, parameter type not found");
13333f810b2SJeff Kirsher return fs;
13433f810b2SJeff Kirsher }
13533f810b2SJeff Kirsher msg_res_type = ((struct smt_p_0015 *)p)->res_type ;
13633f810b2SJeff Kirsher
13733f810b2SJeff Kirsher /*
13833f810b2SJeff Kirsher * get the pointer to the ESS command
13933f810b2SJeff Kirsher */
14033f810b2SJeff Kirsher if (!(cmd = (struct smt_p_0016 *) sm_to_para(smc,sm,SMT_P0016))) {
14133f810b2SJeff Kirsher /*
14233f810b2SJeff Kirsher * error in frame: para ESS command was not found
14333f810b2SJeff Kirsher */
1445671e8c1SJoe Perches DB_ESS("ESS: RAF frame error, parameter command not found");
14533f810b2SJeff Kirsher return fs;
14633f810b2SJeff Kirsher }
14733f810b2SJeff Kirsher
1485671e8c1SJoe Perches DB_ESSN(2, "fc %x ft %x", sm->smt_class, sm->smt_type);
1495671e8c1SJoe Perches DB_ESSN(2, "ver %x tran %x", sm->smt_version, sm->smt_tid);
150*c19b05b8STetsuo Handa DB_ESSN(2, "stn_id %pM", &sm->smt_source);
15133f810b2SJeff Kirsher
1525671e8c1SJoe Perches DB_ESSN(2, "infolen %x res %lx", sm->smt_len, msg_res_type);
1535671e8c1SJoe Perches DB_ESSN(2, "sbacmd %x", cmd->sba_cmd);
15433f810b2SJeff Kirsher
15533f810b2SJeff Kirsher /*
15633f810b2SJeff Kirsher * evaluate the ESS command
15733f810b2SJeff Kirsher */
15833f810b2SJeff Kirsher switch (cmd->sba_cmd) {
15933f810b2SJeff Kirsher
16033f810b2SJeff Kirsher /*
16133f810b2SJeff Kirsher * Process an ESS Allocation Request
16233f810b2SJeff Kirsher */
16333f810b2SJeff Kirsher case REQUEST_ALLOCATION :
16433f810b2SJeff Kirsher /*
16533f810b2SJeff Kirsher * check for an RAF Request (Allocation Request)
16633f810b2SJeff Kirsher */
16733f810b2SJeff Kirsher if (sm->smt_type == SMT_REQUEST) {
16833f810b2SJeff Kirsher /*
16933f810b2SJeff Kirsher * process the Allocation request only if the frame is
17033f810b2SJeff Kirsher * local and no static allocation is used
17133f810b2SJeff Kirsher */
17233f810b2SJeff Kirsher if (!local || smc->mib.fddiESSPayload)
17333f810b2SJeff Kirsher return fs;
17433f810b2SJeff Kirsher
17533f810b2SJeff Kirsher p = (void *) sm_to_para(smc,sm,SMT_P0019) ;
17633f810b2SJeff Kirsher for (i = 0; i < 5; i++) {
17733f810b2SJeff Kirsher if (((struct smt_p_0019 *)p)->alloc_addr.a[i]) {
17833f810b2SJeff Kirsher return fs;
17933f810b2SJeff Kirsher }
18033f810b2SJeff Kirsher }
18133f810b2SJeff Kirsher
18233f810b2SJeff Kirsher /*
18333f810b2SJeff Kirsher * Note: The Application should send a LAN_LOC_FRAME.
18433f810b2SJeff Kirsher * The ESS do not send the Frame to the network!
18533f810b2SJeff Kirsher */
18633f810b2SJeff Kirsher smc->ess.alloc_trans_id = sm->smt_tid ;
1875671e8c1SJoe Perches DB_ESS("ESS: save Alloc Req Trans ID %x", sm->smt_tid);
18833f810b2SJeff Kirsher p = (void *) sm_to_para(smc,sm,SMT_P320F) ;
18933f810b2SJeff Kirsher ((struct smt_p_320f *)p)->mib_payload =
19033f810b2SJeff Kirsher smc->mib.a[PATH0].fddiPATHSbaPayload ;
19133f810b2SJeff Kirsher p = (void *) sm_to_para(smc,sm,SMT_P3210) ;
19233f810b2SJeff Kirsher ((struct smt_p_3210 *)p)->mib_overhead =
19333f810b2SJeff Kirsher smc->mib.a[PATH0].fddiPATHSbaOverhead ;
19433f810b2SJeff Kirsher sm->smt_dest = smt_sba_da ;
19533f810b2SJeff Kirsher
19633f810b2SJeff Kirsher if (smc->ess.local_sba_active)
19733f810b2SJeff Kirsher return fs | I_INDICATOR;
19833f810b2SJeff Kirsher
19933f810b2SJeff Kirsher if (!(db = smt_get_mbuf(smc)))
20033f810b2SJeff Kirsher return fs;
20133f810b2SJeff Kirsher
20233f810b2SJeff Kirsher db->sm_len = mb->sm_len ;
20333f810b2SJeff Kirsher db->sm_off = mb->sm_off ;
20433f810b2SJeff Kirsher memcpy(((char *)(db->sm_data+db->sm_off)),(char *)sm,
20533f810b2SJeff Kirsher (int)db->sm_len) ;
20633f810b2SJeff Kirsher dump_smt(smc,
20733f810b2SJeff Kirsher (struct smt_header *)(db->sm_data+db->sm_off),
20833f810b2SJeff Kirsher "RAF") ;
20933f810b2SJeff Kirsher smt_send_frame(smc,db,FC_SMT_INFO,0) ;
21033f810b2SJeff Kirsher return fs;
21133f810b2SJeff Kirsher }
21233f810b2SJeff Kirsher
21333f810b2SJeff Kirsher /*
21433f810b2SJeff Kirsher * The RAF frame is an Allocation Response !
21533f810b2SJeff Kirsher * check the parameters
21633f810b2SJeff Kirsher */
21733f810b2SJeff Kirsher if (smt_check_para(smc,sm,plist_raf_alc_res)) {
2185671e8c1SJoe Perches DB_ESS("ESS: RAF with para problem, ignoring");
21933f810b2SJeff Kirsher return fs;
22033f810b2SJeff Kirsher }
22133f810b2SJeff Kirsher
22233f810b2SJeff Kirsher /*
22333f810b2SJeff Kirsher * VERIFY THE FRAME IS WELL BUILT:
22433f810b2SJeff Kirsher *
22533f810b2SJeff Kirsher * 1. path index = primary ring only
22633f810b2SJeff Kirsher * 2. resource type = sync bw only
22733f810b2SJeff Kirsher * 3. trans action id = alloc_trans_id
22833f810b2SJeff Kirsher * 4. reason code = success
22933f810b2SJeff Kirsher *
23033f810b2SJeff Kirsher * If any are violated, discard the RAF frame
23133f810b2SJeff Kirsher */
23233f810b2SJeff Kirsher if ((((struct smt_p_320b *)sm_to_para(smc,sm,SMT_P320B))->path_index
23333f810b2SJeff Kirsher != PRIMARY_RING) ||
23433f810b2SJeff Kirsher (msg_res_type != SYNC_BW) ||
23533f810b2SJeff Kirsher (((struct smt_p_reason *)sm_to_para(smc,sm,SMT_P0012))->rdf_reason
23633f810b2SJeff Kirsher != SMT_RDF_SUCCESS) ||
23733f810b2SJeff Kirsher (sm->smt_tid != smc->ess.alloc_trans_id)) {
23833f810b2SJeff Kirsher
2395671e8c1SJoe Perches DB_ESS("ESS: Allocation Response not accepted");
24033f810b2SJeff Kirsher return fs;
24133f810b2SJeff Kirsher }
24233f810b2SJeff Kirsher
24333f810b2SJeff Kirsher /*
24433f810b2SJeff Kirsher * Extract message parameters
24533f810b2SJeff Kirsher */
24633f810b2SJeff Kirsher p = (void *) sm_to_para(smc,sm,SMT_P320F) ;
24733f810b2SJeff Kirsher if (!p) {
24833f810b2SJeff Kirsher printk(KERN_ERR "ESS: sm_to_para failed");
24933f810b2SJeff Kirsher return fs;
25033f810b2SJeff Kirsher }
25133f810b2SJeff Kirsher payload = ((struct smt_p_320f *)p)->mib_payload ;
25233f810b2SJeff Kirsher p = (void *) sm_to_para(smc,sm,SMT_P3210) ;
25333f810b2SJeff Kirsher if (!p) {
25433f810b2SJeff Kirsher printk(KERN_ERR "ESS: sm_to_para failed");
25533f810b2SJeff Kirsher return fs;
25633f810b2SJeff Kirsher }
25733f810b2SJeff Kirsher overhead = ((struct smt_p_3210 *)p)->mib_overhead ;
25833f810b2SJeff Kirsher
2595671e8c1SJoe Perches DB_ESSN(2, "payload= %lx overhead= %lx",
2605671e8c1SJoe Perches payload, overhead);
26133f810b2SJeff Kirsher
26233f810b2SJeff Kirsher /*
26333f810b2SJeff Kirsher * process the bandwidth allocation
26433f810b2SJeff Kirsher */
26533f810b2SJeff Kirsher (void)process_bw_alloc(smc,(long)payload,(long)overhead) ;
26633f810b2SJeff Kirsher
26733f810b2SJeff Kirsher return fs;
26833f810b2SJeff Kirsher /* end of Process Allocation Request */
26933f810b2SJeff Kirsher
27033f810b2SJeff Kirsher /*
27133f810b2SJeff Kirsher * Process an ESS Change Request
27233f810b2SJeff Kirsher */
27333f810b2SJeff Kirsher case CHANGE_ALLOCATION :
27433f810b2SJeff Kirsher /*
27533f810b2SJeff Kirsher * except only replies
27633f810b2SJeff Kirsher */
27733f810b2SJeff Kirsher if (sm->smt_type != SMT_REQUEST) {
2785671e8c1SJoe Perches DB_ESS("ESS: Do not process Change Responses");
27933f810b2SJeff Kirsher return fs;
28033f810b2SJeff Kirsher }
28133f810b2SJeff Kirsher
28233f810b2SJeff Kirsher /*
28333f810b2SJeff Kirsher * check the para for the Change Request
28433f810b2SJeff Kirsher */
28533f810b2SJeff Kirsher if (smt_check_para(smc,sm,plist_raf_chg_req)) {
2865671e8c1SJoe Perches DB_ESS("ESS: RAF with para problem, ignoring");
28733f810b2SJeff Kirsher return fs;
28833f810b2SJeff Kirsher }
28933f810b2SJeff Kirsher
29033f810b2SJeff Kirsher /*
29133f810b2SJeff Kirsher * Verify the path index and resource
29233f810b2SJeff Kirsher * type are correct. If any of
29333f810b2SJeff Kirsher * these are false, don't process this
29433f810b2SJeff Kirsher * change request frame.
29533f810b2SJeff Kirsher */
29633f810b2SJeff Kirsher if ((((struct smt_p_320b *)sm_to_para(smc,sm,SMT_P320B))->path_index
29733f810b2SJeff Kirsher != PRIMARY_RING) || (msg_res_type != SYNC_BW)) {
2985671e8c1SJoe Perches DB_ESS("ESS: RAF frame with para problem, ignoring");
29933f810b2SJeff Kirsher return fs;
30033f810b2SJeff Kirsher }
30133f810b2SJeff Kirsher
30233f810b2SJeff Kirsher /*
30333f810b2SJeff Kirsher * Extract message queue parameters
30433f810b2SJeff Kirsher */
30533f810b2SJeff Kirsher p = (void *) sm_to_para(smc,sm,SMT_P320F) ;
30633f810b2SJeff Kirsher payload = ((struct smt_p_320f *)p)->mib_payload ;
30733f810b2SJeff Kirsher p = (void *) sm_to_para(smc,sm,SMT_P3210) ;
30833f810b2SJeff Kirsher overhead = ((struct smt_p_3210 *)p)->mib_overhead ;
30933f810b2SJeff Kirsher
310*c19b05b8STetsuo Handa DB_ESSN(2, "ESS: Change Request from %pM",
311*c19b05b8STetsuo Handa &sm->smt_source);
3125671e8c1SJoe Perches DB_ESSN(2, "payload= %lx overhead= %lx",
3135671e8c1SJoe Perches payload, overhead);
31433f810b2SJeff Kirsher
31533f810b2SJeff Kirsher /*
31633f810b2SJeff Kirsher * process the bandwidth allocation
31733f810b2SJeff Kirsher */
31833f810b2SJeff Kirsher if(!process_bw_alloc(smc,(long)payload,(long)overhead))
31933f810b2SJeff Kirsher return fs;
32033f810b2SJeff Kirsher
32133f810b2SJeff Kirsher /*
32233f810b2SJeff Kirsher * send an RAF Change Reply
32333f810b2SJeff Kirsher */
32433f810b2SJeff Kirsher ess_send_response(smc,sm,CHANGE_ALLOCATION) ;
32533f810b2SJeff Kirsher
32633f810b2SJeff Kirsher return fs;
32733f810b2SJeff Kirsher /* end of Process Change Request */
32833f810b2SJeff Kirsher
32933f810b2SJeff Kirsher /*
33033f810b2SJeff Kirsher * Process Report Response
33133f810b2SJeff Kirsher */
33233f810b2SJeff Kirsher case REPORT_ALLOCATION :
33333f810b2SJeff Kirsher /*
33433f810b2SJeff Kirsher * except only requests
33533f810b2SJeff Kirsher */
33633f810b2SJeff Kirsher if (sm->smt_type != SMT_REQUEST) {
3375671e8c1SJoe Perches DB_ESS("ESS: Do not process a Report Reply");
33833f810b2SJeff Kirsher return fs;
33933f810b2SJeff Kirsher }
34033f810b2SJeff Kirsher
341*c19b05b8STetsuo Handa DB_ESSN(2, "ESS: Report Request from %pM",
342*c19b05b8STetsuo Handa &sm->smt_source);
34333f810b2SJeff Kirsher
34433f810b2SJeff Kirsher /*
34533f810b2SJeff Kirsher * verify that the resource type is sync bw only
34633f810b2SJeff Kirsher */
34733f810b2SJeff Kirsher if (msg_res_type != SYNC_BW) {
3485671e8c1SJoe Perches DB_ESS("ESS: ignoring RAF with para problem");
34933f810b2SJeff Kirsher return fs;
35033f810b2SJeff Kirsher }
35133f810b2SJeff Kirsher
35233f810b2SJeff Kirsher /*
35333f810b2SJeff Kirsher * send an RAF Change Reply
35433f810b2SJeff Kirsher */
35533f810b2SJeff Kirsher ess_send_response(smc,sm,REPORT_ALLOCATION) ;
35633f810b2SJeff Kirsher
35733f810b2SJeff Kirsher return fs;
35833f810b2SJeff Kirsher /* end of Process Report Request */
35933f810b2SJeff Kirsher
36033f810b2SJeff Kirsher default:
36133f810b2SJeff Kirsher /*
36233f810b2SJeff Kirsher * error in frame
36333f810b2SJeff Kirsher */
3645671e8c1SJoe Perches DB_ESS("ESS: ignoring RAF with bad sba_cmd");
36533f810b2SJeff Kirsher break ;
36633f810b2SJeff Kirsher }
36733f810b2SJeff Kirsher
36833f810b2SJeff Kirsher return fs;
36933f810b2SJeff Kirsher }
37033f810b2SJeff Kirsher
37133f810b2SJeff Kirsher /*
37233f810b2SJeff Kirsher * determines the synchronous bandwidth, set the TSYNC register and the
37333f810b2SJeff Kirsher * mib variables SBAPayload, SBAOverhead and fddiMACT-NEG.
37433f810b2SJeff Kirsher */
process_bw_alloc(struct s_smc * smc,long int payload,long int overhead)37533f810b2SJeff Kirsher static int process_bw_alloc(struct s_smc *smc, long int payload, long int overhead)
37633f810b2SJeff Kirsher {
37733f810b2SJeff Kirsher /*
37833f810b2SJeff Kirsher * determine the synchronous bandwidth (sync_bw) in bytes per T-NEG,
37933f810b2SJeff Kirsher * if the payload is greater than zero.
38033f810b2SJeff Kirsher * For the SBAPayload and the SBAOverhead we have the following
38133f810b2SJeff Kirsher * unite quations
38233f810b2SJeff Kirsher * _ _
38333f810b2SJeff Kirsher * | bytes |
38433f810b2SJeff Kirsher * SBAPayload = | 8000 ------ |
38533f810b2SJeff Kirsher * | s |
38633f810b2SJeff Kirsher * - -
38733f810b2SJeff Kirsher * _ _
38833f810b2SJeff Kirsher * | bytes |
38933f810b2SJeff Kirsher * SBAOverhead = | ------ |
39033f810b2SJeff Kirsher * | T-NEG |
39133f810b2SJeff Kirsher * - -
39233f810b2SJeff Kirsher *
39333f810b2SJeff Kirsher * T-NEG is described by the equation:
39433f810b2SJeff Kirsher *
39533f810b2SJeff Kirsher * (-) fddiMACT-NEG
39633f810b2SJeff Kirsher * T-NEG = -------------------
39733f810b2SJeff Kirsher * 12500000 1/s
39833f810b2SJeff Kirsher *
39933f810b2SJeff Kirsher * The number of bytes we are able to send is the payload
40033f810b2SJeff Kirsher * plus the overhead.
40133f810b2SJeff Kirsher *
40233f810b2SJeff Kirsher * bytes T-NEG SBAPayload 8000 bytes/s
40333f810b2SJeff Kirsher * sync_bw = SBAOverhead ------ + -----------------------------
40433f810b2SJeff Kirsher * T-NEG T-NEG
40533f810b2SJeff Kirsher *
40633f810b2SJeff Kirsher *
40733f810b2SJeff Kirsher * 1
40833f810b2SJeff Kirsher * sync_bw = SBAOverhead + ---- (-)fddiMACT-NEG * SBAPayload
40933f810b2SJeff Kirsher * 1562
41033f810b2SJeff Kirsher *
41133f810b2SJeff Kirsher */
41233f810b2SJeff Kirsher
41333f810b2SJeff Kirsher /*
41433f810b2SJeff Kirsher * set the mib attributes fddiPATHSbaOverhead, fddiPATHSbaPayload
41533f810b2SJeff Kirsher */
41633f810b2SJeff Kirsher /* if (smt_set_obj(smc,SMT_P320F,payload,S_SET)) {
4175671e8c1SJoe Perches DB_ESS("ESS: SMT does not accept the payload value");
41833f810b2SJeff Kirsher return FALSE;
41933f810b2SJeff Kirsher }
42033f810b2SJeff Kirsher if (smt_set_obj(smc,SMT_P3210,overhead,S_SET)) {
4215671e8c1SJoe Perches DB_ESS("ESS: SMT does not accept the overhead value");
42233f810b2SJeff Kirsher return FALSE;
42333f810b2SJeff Kirsher } */
42433f810b2SJeff Kirsher
42533f810b2SJeff Kirsher /* premliminary */
42633f810b2SJeff Kirsher if (payload > MAX_PAYLOAD || overhead > 5000) {
4275671e8c1SJoe Perches DB_ESS("ESS: payload / overhead not accepted");
42833f810b2SJeff Kirsher return FALSE;
42933f810b2SJeff Kirsher }
43033f810b2SJeff Kirsher
43133f810b2SJeff Kirsher /*
43233f810b2SJeff Kirsher * start the iterative allocation process if the payload or the overhead
43333f810b2SJeff Kirsher * are smaller than the parsed values
43433f810b2SJeff Kirsher */
43533f810b2SJeff Kirsher if (smc->mib.fddiESSPayload &&
43633f810b2SJeff Kirsher ((u_long)payload != smc->mib.fddiESSPayload ||
43733f810b2SJeff Kirsher (u_long)overhead != smc->mib.fddiESSOverhead)) {
43833f810b2SJeff Kirsher smc->ess.raf_act_timer_poll = TRUE ;
43933f810b2SJeff Kirsher smc->ess.timer_count = 0 ;
44033f810b2SJeff Kirsher }
44133f810b2SJeff Kirsher
44233f810b2SJeff Kirsher /*
44333f810b2SJeff Kirsher * evulate the Payload
44433f810b2SJeff Kirsher */
44533f810b2SJeff Kirsher if (payload) {
4465671e8c1SJoe Perches DB_ESSN(2, "ESS: turn SMT_ST_SYNC_SERVICE bit on");
44733f810b2SJeff Kirsher smc->ess.sync_bw_available = TRUE ;
44833f810b2SJeff Kirsher
44933f810b2SJeff Kirsher smc->ess.sync_bw = overhead -
45033f810b2SJeff Kirsher (long)smc->mib.m[MAC0].fddiMACT_Neg *
45133f810b2SJeff Kirsher payload / 1562 ;
45233f810b2SJeff Kirsher }
45333f810b2SJeff Kirsher else {
4545671e8c1SJoe Perches DB_ESSN(2, "ESS: turn SMT_ST_SYNC_SERVICE bit off");
45533f810b2SJeff Kirsher smc->ess.sync_bw_available = FALSE ;
45633f810b2SJeff Kirsher smc->ess.sync_bw = 0 ;
45733f810b2SJeff Kirsher overhead = 0 ;
45833f810b2SJeff Kirsher }
45933f810b2SJeff Kirsher
46033f810b2SJeff Kirsher smc->mib.a[PATH0].fddiPATHSbaPayload = payload ;
46133f810b2SJeff Kirsher smc->mib.a[PATH0].fddiPATHSbaOverhead = overhead ;
46233f810b2SJeff Kirsher
46333f810b2SJeff Kirsher
4645671e8c1SJoe Perches DB_ESSN(2, "tsync = %lx", smc->ess.sync_bw);
46533f810b2SJeff Kirsher
46633f810b2SJeff Kirsher ess_config_fifo(smc) ;
46733f810b2SJeff Kirsher set_formac_tsync(smc,smc->ess.sync_bw) ;
46833f810b2SJeff Kirsher return TRUE;
46933f810b2SJeff Kirsher }
47033f810b2SJeff Kirsher
ess_send_response(struct s_smc * smc,struct smt_header * sm,int sba_cmd)47133f810b2SJeff Kirsher static void ess_send_response(struct s_smc *smc, struct smt_header *sm,
47233f810b2SJeff Kirsher int sba_cmd)
47333f810b2SJeff Kirsher {
47433f810b2SJeff Kirsher struct smt_sba_chg *chg ;
47533f810b2SJeff Kirsher SMbuf *mb ;
47633f810b2SJeff Kirsher void *p ;
47733f810b2SJeff Kirsher
47833f810b2SJeff Kirsher /*
47933f810b2SJeff Kirsher * get and initialize the response frame
48033f810b2SJeff Kirsher */
48133f810b2SJeff Kirsher if (sba_cmd == CHANGE_ALLOCATION) {
48233f810b2SJeff Kirsher if (!(mb=smt_build_frame(smc,SMT_RAF,SMT_REPLY,
48333f810b2SJeff Kirsher sizeof(struct smt_sba_chg))))
48433f810b2SJeff Kirsher return ;
48533f810b2SJeff Kirsher }
48633f810b2SJeff Kirsher else {
48733f810b2SJeff Kirsher if (!(mb=smt_build_frame(smc,SMT_RAF,SMT_REPLY,
48833f810b2SJeff Kirsher sizeof(struct smt_sba_rep_res))))
48933f810b2SJeff Kirsher return ;
49033f810b2SJeff Kirsher }
49133f810b2SJeff Kirsher
49233f810b2SJeff Kirsher chg = smtod(mb,struct smt_sba_chg *) ;
49333f810b2SJeff Kirsher chg->smt.smt_tid = sm->smt_tid ;
49433f810b2SJeff Kirsher chg->smt.smt_dest = sm->smt_source ;
49533f810b2SJeff Kirsher
49633f810b2SJeff Kirsher /* set P15 */
49733f810b2SJeff Kirsher chg->s_type.para.p_type = SMT_P0015 ;
49833f810b2SJeff Kirsher chg->s_type.para.p_len = sizeof(struct smt_p_0015) - PARA_LEN ;
49933f810b2SJeff Kirsher chg->s_type.res_type = SYNC_BW ;
50033f810b2SJeff Kirsher
50133f810b2SJeff Kirsher /* set P16 */
50233f810b2SJeff Kirsher chg->cmd.para.p_type = SMT_P0016 ;
50333f810b2SJeff Kirsher chg->cmd.para.p_len = sizeof(struct smt_p_0016) - PARA_LEN ;
50433f810b2SJeff Kirsher chg->cmd.sba_cmd = sba_cmd ;
50533f810b2SJeff Kirsher
50633f810b2SJeff Kirsher /* set P320B */
50733f810b2SJeff Kirsher chg->path.para.p_type = SMT_P320B ;
50833f810b2SJeff Kirsher chg->path.para.p_len = sizeof(struct smt_p_320b) - PARA_LEN ;
50933f810b2SJeff Kirsher chg->path.mib_index = SBAPATHINDEX ;
51033f810b2SJeff Kirsher chg->path.path_pad = 0;
51133f810b2SJeff Kirsher chg->path.path_index = PRIMARY_RING ;
51233f810b2SJeff Kirsher
51333f810b2SJeff Kirsher /* set P320F */
51433f810b2SJeff Kirsher chg->payload.para.p_type = SMT_P320F ;
51533f810b2SJeff Kirsher chg->payload.para.p_len = sizeof(struct smt_p_320f) - PARA_LEN ;
51633f810b2SJeff Kirsher chg->payload.mib_index = SBAPATHINDEX ;
51733f810b2SJeff Kirsher chg->payload.mib_payload = smc->mib.a[PATH0].fddiPATHSbaPayload ;
51833f810b2SJeff Kirsher
51933f810b2SJeff Kirsher /* set P3210 */
52033f810b2SJeff Kirsher chg->overhead.para.p_type = SMT_P3210 ;
52133f810b2SJeff Kirsher chg->overhead.para.p_len = sizeof(struct smt_p_3210) - PARA_LEN ;
52233f810b2SJeff Kirsher chg->overhead.mib_index = SBAPATHINDEX ;
52333f810b2SJeff Kirsher chg->overhead.mib_overhead = smc->mib.a[PATH0].fddiPATHSbaOverhead ;
52433f810b2SJeff Kirsher
52533f810b2SJeff Kirsher if (sba_cmd == CHANGE_ALLOCATION) {
52633f810b2SJeff Kirsher /* set P1A */
52733f810b2SJeff Kirsher chg->cat.para.p_type = SMT_P001A ;
52833f810b2SJeff Kirsher chg->cat.para.p_len = sizeof(struct smt_p_001a) - PARA_LEN ;
52933f810b2SJeff Kirsher p = (void *) sm_to_para(smc,sm,SMT_P001A) ;
53033f810b2SJeff Kirsher chg->cat.category = ((struct smt_p_001a *)p)->category ;
53133f810b2SJeff Kirsher }
53233f810b2SJeff Kirsher dump_smt(smc,(struct smt_header *)chg,"RAF") ;
53333f810b2SJeff Kirsher ess_send_frame(smc,mb) ;
53433f810b2SJeff Kirsher }
53533f810b2SJeff Kirsher
ess_timer_poll(struct s_smc * smc)53633f810b2SJeff Kirsher void ess_timer_poll(struct s_smc *smc)
53733f810b2SJeff Kirsher {
53833f810b2SJeff Kirsher if (!smc->ess.raf_act_timer_poll)
53933f810b2SJeff Kirsher return ;
54033f810b2SJeff Kirsher
5415671e8c1SJoe Perches DB_ESSN(2, "ESS: timer_poll");
54233f810b2SJeff Kirsher
54333f810b2SJeff Kirsher smc->ess.timer_count++ ;
54433f810b2SJeff Kirsher if (smc->ess.timer_count == 10) {
54533f810b2SJeff Kirsher smc->ess.timer_count = 0 ;
54633f810b2SJeff Kirsher ess_send_alc_req(smc) ;
54733f810b2SJeff Kirsher }
54833f810b2SJeff Kirsher }
54933f810b2SJeff Kirsher
ess_send_alc_req(struct s_smc * smc)55033f810b2SJeff Kirsher static void ess_send_alc_req(struct s_smc *smc)
55133f810b2SJeff Kirsher {
55233f810b2SJeff Kirsher struct smt_sba_alc_req *req ;
55333f810b2SJeff Kirsher SMbuf *mb ;
55433f810b2SJeff Kirsher
55533f810b2SJeff Kirsher /*
55633f810b2SJeff Kirsher * send never allocation request where the requested payload and
55733f810b2SJeff Kirsher * overhead is zero or deallocate bandwidth when no bandwidth is
55833f810b2SJeff Kirsher * parsed
55933f810b2SJeff Kirsher */
56033f810b2SJeff Kirsher if (!smc->mib.fddiESSPayload) {
56133f810b2SJeff Kirsher smc->mib.fddiESSOverhead = 0 ;
56233f810b2SJeff Kirsher }
56333f810b2SJeff Kirsher else {
56433f810b2SJeff Kirsher if (!smc->mib.fddiESSOverhead)
56533f810b2SJeff Kirsher smc->mib.fddiESSOverhead = DEFAULT_OV ;
56633f810b2SJeff Kirsher }
56733f810b2SJeff Kirsher
56833f810b2SJeff Kirsher if (smc->mib.fddiESSOverhead ==
56933f810b2SJeff Kirsher smc->mib.a[PATH0].fddiPATHSbaOverhead &&
57033f810b2SJeff Kirsher smc->mib.fddiESSPayload ==
57133f810b2SJeff Kirsher smc->mib.a[PATH0].fddiPATHSbaPayload){
57233f810b2SJeff Kirsher smc->ess.raf_act_timer_poll = FALSE ;
57333f810b2SJeff Kirsher smc->ess.timer_count = 7 ; /* next RAF alc req after 3 s */
57433f810b2SJeff Kirsher return ;
57533f810b2SJeff Kirsher }
57633f810b2SJeff Kirsher
57733f810b2SJeff Kirsher /*
57833f810b2SJeff Kirsher * get and initialize the response frame
57933f810b2SJeff Kirsher */
58033f810b2SJeff Kirsher if (!(mb=smt_build_frame(smc,SMT_RAF,SMT_REQUEST,
58133f810b2SJeff Kirsher sizeof(struct smt_sba_alc_req))))
58233f810b2SJeff Kirsher return ;
58333f810b2SJeff Kirsher req = smtod(mb,struct smt_sba_alc_req *) ;
58433f810b2SJeff Kirsher req->smt.smt_tid = smc->ess.alloc_trans_id = smt_get_tid(smc) ;
58533f810b2SJeff Kirsher req->smt.smt_dest = smt_sba_da ;
58633f810b2SJeff Kirsher
58733f810b2SJeff Kirsher /* set P15 */
58833f810b2SJeff Kirsher req->s_type.para.p_type = SMT_P0015 ;
58933f810b2SJeff Kirsher req->s_type.para.p_len = sizeof(struct smt_p_0015) - PARA_LEN ;
59033f810b2SJeff Kirsher req->s_type.res_type = SYNC_BW ;
59133f810b2SJeff Kirsher
59233f810b2SJeff Kirsher /* set P16 */
59333f810b2SJeff Kirsher req->cmd.para.p_type = SMT_P0016 ;
59433f810b2SJeff Kirsher req->cmd.para.p_len = sizeof(struct smt_p_0016) - PARA_LEN ;
59533f810b2SJeff Kirsher req->cmd.sba_cmd = REQUEST_ALLOCATION ;
59633f810b2SJeff Kirsher
59733f810b2SJeff Kirsher /*
59833f810b2SJeff Kirsher * set the parameter type and parameter length of all used
59933f810b2SJeff Kirsher * parameters
60033f810b2SJeff Kirsher */
60133f810b2SJeff Kirsher
60233f810b2SJeff Kirsher /* set P320B */
60333f810b2SJeff Kirsher req->path.para.p_type = SMT_P320B ;
60433f810b2SJeff Kirsher req->path.para.p_len = sizeof(struct smt_p_320b) - PARA_LEN ;
60533f810b2SJeff Kirsher req->path.mib_index = SBAPATHINDEX ;
60633f810b2SJeff Kirsher req->path.path_pad = 0;
60733f810b2SJeff Kirsher req->path.path_index = PRIMARY_RING ;
60833f810b2SJeff Kirsher
60933f810b2SJeff Kirsher /* set P0017 */
61033f810b2SJeff Kirsher req->pl_req.para.p_type = SMT_P0017 ;
61133f810b2SJeff Kirsher req->pl_req.para.p_len = sizeof(struct smt_p_0017) - PARA_LEN ;
61233f810b2SJeff Kirsher req->pl_req.sba_pl_req = smc->mib.fddiESSPayload -
61333f810b2SJeff Kirsher smc->mib.a[PATH0].fddiPATHSbaPayload ;
61433f810b2SJeff Kirsher
61533f810b2SJeff Kirsher /* set P0018 */
61633f810b2SJeff Kirsher req->ov_req.para.p_type = SMT_P0018 ;
61733f810b2SJeff Kirsher req->ov_req.para.p_len = sizeof(struct smt_p_0018) - PARA_LEN ;
61833f810b2SJeff Kirsher req->ov_req.sba_ov_req = smc->mib.fddiESSOverhead -
61933f810b2SJeff Kirsher smc->mib.a[PATH0].fddiPATHSbaOverhead ;
62033f810b2SJeff Kirsher
62133f810b2SJeff Kirsher /* set P320F */
62233f810b2SJeff Kirsher req->payload.para.p_type = SMT_P320F ;
62333f810b2SJeff Kirsher req->payload.para.p_len = sizeof(struct smt_p_320f) - PARA_LEN ;
62433f810b2SJeff Kirsher req->payload.mib_index = SBAPATHINDEX ;
62533f810b2SJeff Kirsher req->payload.mib_payload = smc->mib.a[PATH0].fddiPATHSbaPayload ;
62633f810b2SJeff Kirsher
62733f810b2SJeff Kirsher /* set P3210 */
62833f810b2SJeff Kirsher req->overhead.para.p_type = SMT_P3210 ;
62933f810b2SJeff Kirsher req->overhead.para.p_len = sizeof(struct smt_p_3210) - PARA_LEN ;
63033f810b2SJeff Kirsher req->overhead.mib_index = SBAPATHINDEX ;
63133f810b2SJeff Kirsher req->overhead.mib_overhead = smc->mib.a[PATH0].fddiPATHSbaOverhead ;
63233f810b2SJeff Kirsher
63333f810b2SJeff Kirsher /* set P19 */
63433f810b2SJeff Kirsher req->a_addr.para.p_type = SMT_P0019 ;
63533f810b2SJeff Kirsher req->a_addr.para.p_len = sizeof(struct smt_p_0019) - PARA_LEN ;
63633f810b2SJeff Kirsher req->a_addr.sba_pad = 0;
63733f810b2SJeff Kirsher req->a_addr.alloc_addr = null_addr ;
63833f810b2SJeff Kirsher
63933f810b2SJeff Kirsher /* set P1A */
64033f810b2SJeff Kirsher req->cat.para.p_type = SMT_P001A ;
64133f810b2SJeff Kirsher req->cat.para.p_len = sizeof(struct smt_p_001a) - PARA_LEN ;
64233f810b2SJeff Kirsher req->cat.category = smc->mib.fddiESSCategory ;
64333f810b2SJeff Kirsher
64433f810b2SJeff Kirsher /* set P1B */
64533f810b2SJeff Kirsher req->tneg.para.p_type = SMT_P001B ;
64633f810b2SJeff Kirsher req->tneg.para.p_len = sizeof(struct smt_p_001b) - PARA_LEN ;
64733f810b2SJeff Kirsher req->tneg.max_t_neg = smc->mib.fddiESSMaxTNeg ;
64833f810b2SJeff Kirsher
64933f810b2SJeff Kirsher /* set P1C */
65033f810b2SJeff Kirsher req->segm.para.p_type = SMT_P001C ;
65133f810b2SJeff Kirsher req->segm.para.p_len = sizeof(struct smt_p_001c) - PARA_LEN ;
65233f810b2SJeff Kirsher req->segm.min_seg_siz = smc->mib.fddiESSMinSegmentSize ;
65333f810b2SJeff Kirsher
65433f810b2SJeff Kirsher dump_smt(smc,(struct smt_header *)req,"RAF") ;
65533f810b2SJeff Kirsher ess_send_frame(smc,mb) ;
65633f810b2SJeff Kirsher }
65733f810b2SJeff Kirsher
ess_send_frame(struct s_smc * smc,SMbuf * mb)65833f810b2SJeff Kirsher static void ess_send_frame(struct s_smc *smc, SMbuf *mb)
65933f810b2SJeff Kirsher {
66033f810b2SJeff Kirsher /*
66133f810b2SJeff Kirsher * check if the frame must be send to the own ESS
66233f810b2SJeff Kirsher */
66333f810b2SJeff Kirsher if (smc->ess.local_sba_active) {
66433f810b2SJeff Kirsher /*
66533f810b2SJeff Kirsher * Send the Change Reply to the local SBA
66633f810b2SJeff Kirsher */
6675671e8c1SJoe Perches DB_ESS("ESS:Send to the local SBA");
66833f810b2SJeff Kirsher if (!smc->ess.sba_reply_pend)
66933f810b2SJeff Kirsher smc->ess.sba_reply_pend = mb ;
67033f810b2SJeff Kirsher else {
6715671e8c1SJoe Perches DB_ESS("Frame is lost - another frame was pending");
67233f810b2SJeff Kirsher smt_free_mbuf(smc,mb) ;
67333f810b2SJeff Kirsher }
67433f810b2SJeff Kirsher }
67533f810b2SJeff Kirsher else {
67633f810b2SJeff Kirsher /*
67733f810b2SJeff Kirsher * Send the SBA RAF Change Reply to the network
67833f810b2SJeff Kirsher */
6795671e8c1SJoe Perches DB_ESS("ESS:Send to the network");
68033f810b2SJeff Kirsher smt_send_frame(smc,mb,FC_SMT_INFO,0) ;
68133f810b2SJeff Kirsher }
68233f810b2SJeff Kirsher }
68333f810b2SJeff Kirsher
ess_para_change(struct s_smc * smc)68433f810b2SJeff Kirsher void ess_para_change(struct s_smc *smc)
68533f810b2SJeff Kirsher {
68633f810b2SJeff Kirsher (void)process_bw_alloc(smc,(long)smc->mib.a[PATH0].fddiPATHSbaPayload,
68733f810b2SJeff Kirsher (long)smc->mib.a[PATH0].fddiPATHSbaOverhead) ;
68833f810b2SJeff Kirsher }
68933f810b2SJeff Kirsher
ess_config_fifo(struct s_smc * smc)69033f810b2SJeff Kirsher static void ess_config_fifo(struct s_smc *smc)
69133f810b2SJeff Kirsher {
69233f810b2SJeff Kirsher /*
69333f810b2SJeff Kirsher * if nothing to do exit
69433f810b2SJeff Kirsher */
69533f810b2SJeff Kirsher if (smc->mib.a[PATH0].fddiPATHSbaPayload) {
69633f810b2SJeff Kirsher if (smc->hw.fp.fifo.fifo_config_mode & SYNC_TRAFFIC_ON &&
69733f810b2SJeff Kirsher (smc->hw.fp.fifo.fifo_config_mode&SEND_ASYNC_AS_SYNC) ==
69833f810b2SJeff Kirsher smc->mib.fddiESSSynchTxMode) {
69933f810b2SJeff Kirsher return ;
70033f810b2SJeff Kirsher }
70133f810b2SJeff Kirsher }
70233f810b2SJeff Kirsher else {
70333f810b2SJeff Kirsher if (!(smc->hw.fp.fifo.fifo_config_mode & SYNC_TRAFFIC_ON)) {
70433f810b2SJeff Kirsher return ;
70533f810b2SJeff Kirsher }
70633f810b2SJeff Kirsher }
70733f810b2SJeff Kirsher
70833f810b2SJeff Kirsher /*
70933f810b2SJeff Kirsher * split up the FIFO and reinitialize the queues
71033f810b2SJeff Kirsher */
71133f810b2SJeff Kirsher formac_reinit_tx(smc) ;
71233f810b2SJeff Kirsher }
71333f810b2SJeff Kirsher
71433f810b2SJeff Kirsher #endif /* ESS */
71533f810b2SJeff Kirsher
71633f810b2SJeff Kirsher #endif /* no SLIM_SMT */
71733f810b2SJeff Kirsher
718