File: fcoemon.h

package info (click to toggle)
fcoe-utils 1.0.31+git20160622.5dfd3e4-5
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,060 kB
  • sloc: ansic: 11,919; sh: 1,298; makefile: 81
file content (181 lines) | stat: -rw-r--r-- 5,930 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
/*
 * Copyright(c) 2009 Intel Corporation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms and conditions of the GNU General Public License,
 * version 2, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Maintained at www.Open-FCoE.org
 */

#ifndef _FCOEMON_H_
#define _FCOEMON_H_

#include "fcoe_utils.h"

struct fcoe_config {
	int debug;
	int use_syslog;
	int dcb_init;
	struct fcoe_port *port;
} fcoe_config;

/*
 * Log message.
 */
#define FCM_LOG(...)							\
	do {								\
		sa_log(__VA_ARGS__);					\
	} while (0)

#define FCM_LOG_ERR(error, ...) \
	do {								\
		sa_log_err(error, NULL, __VA_ARGS__);			\
	} while (0)

#define FCM_LOG_DBG(fmt, args...)					\
	do {								\
		sa_log_debug(fmt, ##args);				\
	} while (0)

#define FCM_LOG_DEV_DBG(fcm, fmt, args...)				\
	do {								\
		sa_log_debug("%s, " fmt, fcm->ifname, ##args);	\
	} while (0)

#define FCM_LOG_DEV(fcm, fmt, args...)				\
	do {							\
		sa_log("%s, " fmt, fcm->ifname, ##args);	\
	} while (0)

/*
 * States for HBAs relative to the DCB daemon.
 * States advance sequentially if conditions are right.
 */
enum fcm_dcbd_state {
   FCD_INIT = 0,        /* starting state */
   FCD_GET_DCB_STATE,   /* getting DCB state */
   FCD_SEND_CONF,       /* set proposed configuration */
   FCD_GET_PFC_CONFIG,  /* getting PFC configuration */
   FCD_GET_APP_CONFIG,  /* getting APP configuration */
   FCD_GET_PFC_OPER,    /* getting PFC operational mode */
   FCD_GET_APP_OPER,    /* getting operational mode */
   FCD_GET_PEER,        /* getting peer configuration */
   FCD_DONE,            /* DCB exchanges complete */
   FCD_ERROR,           /* DCB error or port unknown by DCB */
};

/*
 * States for IEEE DCB devices.
 */
enum ieee_state {
	IEEE_INIT = 0,	/* Starting state */
	IEEE_GET_STATE,	/* Getting IEEE DCB state */
	IEEE_DONE,	/* Received IEEE DCB state */
	IEEE_ACTIVE,	/* IEEE is in ACTIVE state */
	IEEE_ERROR,	/* Error receiving IEEE DCB state */
};

#define MSG_RBUF sizeof(int)
struct sock_info {
	int sock;
	struct sockaddr_un from;
	socklen_t fromlen;
};

/*
 * Action codes for FCoE ports
*/
enum fcp_action {
   FCP_WAIT = 0,        /* waiting for something to happen */
   FCP_CREATE_IF,       /* create FCoE interface */
   FCP_DESTROY_IF,      /* destroy FCoE interface */
   FCP_RESET_IF,        /* reset FCoE interface */
   FCP_SCAN_IF,         /* scan FCoE interface */
   FCP_ENABLE_IF,       /* enable FCoE interface */
   FCP_DISABLE_IF,      /* disable FCoE interface */
   FCP_ACTIVATE_IF,     /* create or enable FCoE interface */
   FCP_ERROR,           /* error condition */
   FCP_VLAN_DISC,       /* start VLAN discovery */
};

#define FCM_DCBD_STATES {                         \
    { "INIT",             FCD_INIT },             \
    { "GET_DCB_STATE",    FCD_GET_DCB_STATE },    \
    { "SEND_CONF",        FCD_SEND_CONF },        \
    { "GET_PFC_CONFIG",   FCD_GET_PFC_CONFIG },   \
    { "GET_APP_CONFIG",   FCD_GET_APP_CONFIG },   \
    { "GET_PFC_OPER",     FCD_GET_PFC_OPER },     \
    { "GET_APP_OPER",     FCD_GET_APP_OPER },     \
    { "GET_PEER",         FCD_GET_PEER },         \
    { "DONE",             FCD_DONE },             \
    { "ERROR",            FCD_ERROR },            \
    { NULL,               0 }                     \
}

struct feature_info {
   u_int32_t	enable;    /* enable/disable feature */
   u_int32_t	advertise; /* enable/disable advertise */
   u_int32_t	willing;   /* enable/disable willing mode */
   u_int32_t	syncd;     /* synchronized with switch */
   u_int32_t	op_mode;   /* operational mode */
   u_int32_t	op_vers;   /* feature operational version */
   u_int32_t	op_error;  /* operational error */
   u_int32_t	subtype;   /* subtype */
   union {
      u_int32_t pfcup;
      u_int32_t appcfg;
   } u;
};

/*
 * Description of potential FCoE network interface.
 */
struct fcm_netif {
   TAILQ_ENTRY(fcm_netif) ff_list;          /* list linkage */
   u_int32_t             ff_enabled:1;     /* operational status */
   u_int32_t             ff_dcb_state;     /* DCB feature state */
   u_int32_t		 dcbx_cap;	   /* DCBX capability */
   enum ieee_state	 ieee_state;	   /* IEEE state */
   u_int32_t		 ieee_resp_pending;/* IEEE response pending */
   u_int32_t		 ieee_pfc_info;	   /* IEEE pfc info */
   u_int32_t		 ieee_app_info;	   /* IEEE app info */
   struct feature_info   ff_pfc_info;      /* PFC feature info */
   struct feature_info   ff_app_info;      /* App feature info */
   u_int8_t              ff_operstate;     /* RFC 2863 operational status */
   enum fcm_dcbd_state   ff_dcbd_state;    /* DCB daemon state */
   char                  ifname[IFNAMSIZ]; /* Ethernet interface name */
   int                   response_pending; /* dcbd query in progress */
   int                   dcbd_retry_cnt;   /* Number of query attempts */
   struct sa_timer       dcbd_retry_timer; /* dcbd retry timer */
};

/*
 * Description of fcoe socket server interface
 */
struct fcm_srv_info {
	int srv_sock;
};

TAILQ_HEAD(fcm_netif_head, fcm_netif);

struct fcm_netif_head fcm_netif_head;

static void fcm_dcbd_init(void);
static void fcm_dcbd_shutdown(void);
static void fcm_fcoe_init(void);
static struct fcm_netif *fcm_netif_lookup(char *);
static struct fcm_netif *fcm_netif_lookup_create(char *);
static int fcm_link_init(void);
static void fcm_dcbd_state_set(struct fcm_netif *, enum fcm_dcbd_state);

#endif /* _FCOEMON_H_ */