|
Packit |
a132db |
/*
|
|
Packit |
a132db |
* Copyright(c) 2009 Intel Corporation. All rights reserved.
|
|
Packit |
a132db |
*
|
|
Packit |
a132db |
* This program is free software; you can redistribute it and/or modify it
|
|
Packit |
a132db |
* under the terms and conditions of the GNU General Public License,
|
|
Packit |
a132db |
* version 2, as published by the Free Software Foundation.
|
|
Packit |
a132db |
*
|
|
Packit |
a132db |
* This program is distributed in the hope it will be useful, but WITHOUT
|
|
Packit |
a132db |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
Packit |
a132db |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
Packit |
a132db |
* more details.
|
|
Packit |
a132db |
*
|
|
Packit |
a132db |
* You should have received a copy of the GNU General Public License along with
|
|
Packit |
a132db |
* this program; if not, write to the Free Software Foundation, Inc.,
|
|
Packit |
a132db |
* 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
|
Packit |
a132db |
*
|
|
Packit |
a132db |
* Maintained at www.Open-FCoE.org
|
|
Packit |
a132db |
*/
|
|
Packit |
a132db |
|
|
Packit |
a132db |
#ifndef _FCOEMON_H_
|
|
Packit |
a132db |
#define _FCOEMON_H_
|
|
Packit |
a132db |
|
|
Packit |
a132db |
#include "fcoe_utils.h"
|
|
Packit |
a132db |
|
|
Packit |
a132db |
struct fcoe_config {
|
|
Packit |
a132db |
int debug;
|
|
Packit |
a132db |
int use_syslog;
|
|
Packit |
a132db |
int dcb_init;
|
|
Packit |
a132db |
struct fcoe_port *port;
|
|
Packit |
a132db |
} fcoe_config;
|
|
Packit |
a132db |
|
|
Packit |
a132db |
/*
|
|
Packit |
a132db |
* Log message.
|
|
Packit |
a132db |
*/
|
|
Packit |
a132db |
#define FCM_LOG(...) \
|
|
Packit |
a132db |
do { \
|
|
Packit |
a132db |
sa_log(__VA_ARGS__); \
|
|
Packit |
a132db |
} while (0)
|
|
Packit |
a132db |
|
|
Packit |
a132db |
#define FCM_LOG_ERR(error, ...) \
|
|
Packit |
a132db |
do { \
|
|
Packit |
a132db |
sa_log_err(error, NULL, __VA_ARGS__); \
|
|
Packit |
a132db |
} while (0)
|
|
Packit |
a132db |
|
|
Packit |
a132db |
#define FCM_LOG_DBG(fmt, args...) \
|
|
Packit |
a132db |
do { \
|
|
Packit |
a132db |
sa_log_debug(fmt, ##args); \
|
|
Packit |
a132db |
} while (0)
|
|
Packit |
a132db |
|
|
Packit |
a132db |
#define FCM_LOG_DEV_DBG(fcm, fmt, args...) \
|
|
Packit |
a132db |
do { \
|
|
Packit |
a132db |
sa_log_debug("%s, " fmt, fcm->ifname, ##args); \
|
|
Packit |
a132db |
} while (0)
|
|
Packit |
a132db |
|
|
Packit |
a132db |
#define FCM_LOG_DEV(fcm, fmt, args...) \
|
|
Packit |
a132db |
do { \
|
|
Packit |
a132db |
sa_log("%s, " fmt, fcm->ifname, ##args); \
|
|
Packit |
a132db |
} while (0)
|
|
Packit |
a132db |
|
|
Packit |
a132db |
/*
|
|
Packit |
a132db |
* States for HBAs relative to the DCB daemon.
|
|
Packit |
a132db |
* States advance sequentially if conditions are right.
|
|
Packit |
a132db |
*/
|
|
Packit |
a132db |
enum fcm_dcbd_state {
|
|
Packit |
a132db |
FCD_INIT = 0, /* starting state */
|
|
Packit |
a132db |
FCD_GET_DCB_STATE, /* getting DCB state */
|
|
Packit |
a132db |
FCD_SEND_CONF, /* set proposed configuration */
|
|
Packit |
a132db |
FCD_GET_PFC_CONFIG, /* getting PFC configuration */
|
|
Packit |
a132db |
FCD_GET_APP_CONFIG, /* getting APP configuration */
|
|
Packit |
a132db |
FCD_GET_PFC_OPER, /* getting PFC operational mode */
|
|
Packit |
a132db |
FCD_GET_APP_OPER, /* getting AAP operational mode */
|
|
Packit |
a132db |
FCD_GET_PEER, /* getting peer configuration */
|
|
Packit |
a132db |
FCD_DONE, /* DCB exchanges complete */
|
|
Packit |
a132db |
FCD_ERROR, /* DCB error or port unknown by DCB */
|
|
Packit |
a132db |
};
|
|
Packit |
a132db |
|
|
Packit |
a132db |
/*
|
|
Packit |
a132db |
* States for IEEE DCB devices.
|
|
Packit |
a132db |
*/
|
|
Packit |
a132db |
enum ieee_state {
|
|
Packit |
a132db |
IEEE_INIT = 0, /* Starting state */
|
|
Packit |
a132db |
IEEE_GET_STATE, /* Getting IEEE DCB state */
|
|
Packit |
a132db |
IEEE_DONE, /* Received IEEE DCB state */
|
|
Packit |
a132db |
IEEE_ACTIVE, /* IEEE is in ACTIVE state */
|
|
Packit |
a132db |
IEEE_ERROR, /* Error receiving IEEE DCB state */
|
|
Packit |
a132db |
};
|
|
Packit |
a132db |
|
|
Packit |
a132db |
#define MSG_RBUF sizeof(int)
|
|
Packit |
a132db |
struct sock_info {
|
|
Packit |
a132db |
int sock;
|
|
Packit |
a132db |
struct sockaddr_un from;
|
|
Packit |
a132db |
socklen_t fromlen;
|
|
Packit |
a132db |
};
|
|
Packit |
a132db |
|
|
Packit |
a132db |
/*
|
|
Packit |
a132db |
* Action codes for FCoE ports
|
|
Packit |
a132db |
*/
|
|
Packit |
a132db |
enum fcp_action {
|
|
Packit |
a132db |
FCP_WAIT = 0, /* waiting for something to happen */
|
|
Packit |
a132db |
FCP_CREATE_IF, /* create FCoE interface */
|
|
Packit |
a132db |
FCP_DESTROY_IF, /* destroy FCoE interface */
|
|
Packit |
a132db |
FCP_RESET_IF, /* reset FCoE interface */
|
|
Packit |
a132db |
FCP_SCAN_IF, /* scan FCoE interface */
|
|
Packit |
a132db |
FCP_ENABLE_IF, /* enable FCoE interface */
|
|
Packit |
a132db |
FCP_DISABLE_IF, /* disable FCoE interface */
|
|
Packit |
a132db |
FCP_ACTIVATE_IF, /* create or enable FCoE interface */
|
|
Packit |
a132db |
FCP_ERROR, /* error condition */
|
|
Packit |
a132db |
FCP_VLAN_DISC, /* start VLAN discovery */
|
|
Packit |
a132db |
};
|
|
Packit |
a132db |
|
|
Packit |
a132db |
#define FCM_DCBD_STATES { \
|
|
Packit |
a132db |
{ "INIT", FCD_INIT }, \
|
|
Packit |
a132db |
{ "GET_DCB_STATE", FCD_GET_DCB_STATE }, \
|
|
Packit |
a132db |
{ "SEND_CONF", FCD_SEND_CONF }, \
|
|
Packit |
a132db |
{ "GET_PFC_CONFIG", FCD_GET_PFC_CONFIG }, \
|
|
Packit |
a132db |
{ "GET_APP_CONFIG", FCD_GET_APP_CONFIG }, \
|
|
Packit |
a132db |
{ "GET_PFC_OPER", FCD_GET_PFC_OPER }, \
|
|
Packit |
a132db |
{ "GET_APP_OPER", FCD_GET_APP_OPER }, \
|
|
Packit |
a132db |
{ "GET_PEER", FCD_GET_PEER }, \
|
|
Packit |
a132db |
{ "DONE", FCD_DONE }, \
|
|
Packit |
a132db |
{ "ERROR", FCD_ERROR }, \
|
|
Packit |
a132db |
{ NULL, 0 } \
|
|
Packit |
a132db |
}
|
|
Packit |
a132db |
|
|
Packit |
a132db |
struct feature_info {
|
|
Packit |
a132db |
u_int32_t enable; /* enable/disable feature */
|
|
Packit |
a132db |
u_int32_t advertise; /* enable/disable advertise */
|
|
Packit |
a132db |
u_int32_t willing; /* enable/disable willing mode */
|
|
Packit |
a132db |
u_int32_t syncd; /* synchronized with switch */
|
|
Packit |
a132db |
u_int32_t op_mode; /* operational mode */
|
|
Packit |
a132db |
u_int32_t op_vers; /* feature operational version */
|
|
Packit |
a132db |
u_int32_t op_error; /* operational error */
|
|
Packit |
a132db |
u_int32_t subtype; /* subtype */
|
|
Packit |
a132db |
union {
|
|
Packit |
a132db |
u_int32_t pfcup;
|
|
Packit |
a132db |
u_int32_t appcfg;
|
|
Packit |
a132db |
} u;
|
|
Packit |
a132db |
};
|
|
Packit |
a132db |
|
|
Packit |
a132db |
/*
|
|
Packit |
a132db |
* Description of potential FCoE network interface.
|
|
Packit |
a132db |
*/
|
|
Packit |
a132db |
struct fcm_netif {
|
|
Packit |
a132db |
TAILQ_ENTRY(fcm_netif) ff_list; /* list linkage */
|
|
Packit |
a132db |
u_int32_t ff_enabled:1; /* operational status */
|
|
Packit |
a132db |
u_int32_t ff_dcb_state; /* DCB feature state */
|
|
Packit |
a132db |
u_int32_t dcbx_cap; /* DCBX capability */
|
|
Packit |
a132db |
enum ieee_state ieee_state; /* IEEE state */
|
|
Packit |
a132db |
u_int32_t ieee_resp_pending;/* IEEE response pending */
|
|
Packit |
a132db |
u_int32_t ieee_pfc_info; /* IEEE pfc info */
|
|
Packit |
a132db |
u_int32_t ieee_app_info; /* IEEE app info */
|
|
Packit |
a132db |
struct feature_info ff_pfc_info; /* PFC feature info */
|
|
Packit |
a132db |
struct feature_info ff_app_info; /* App feature info */
|
|
Packit |
a132db |
u_int8_t ff_operstate; /* RFC 2863 operational status */
|
|
Packit |
a132db |
enum fcm_dcbd_state ff_dcbd_state; /* DCB daemon state */
|
|
Packit |
a132db |
char ifname[IFNAMSIZ]; /* Ethernet interface name */
|
|
Packit |
a132db |
int response_pending; /* dcbd query in progress */
|
|
Packit |
a132db |
int dcbd_retry_cnt; /* Number of query attempts */
|
|
Packit |
a132db |
struct sa_timer dcbd_retry_timer; /* dcbd retry timer */
|
|
Packit |
a132db |
};
|
|
Packit |
a132db |
|
|
Packit |
a132db |
/*
|
|
Packit |
a132db |
* Description of fcoe socket server interface
|
|
Packit |
a132db |
*/
|
|
Packit |
a132db |
struct fcm_srv_info {
|
|
Packit |
a132db |
int srv_sock;
|
|
Packit |
a132db |
};
|
|
Packit |
a132db |
|
|
Packit |
a132db |
TAILQ_HEAD(fcm_netif_head, fcm_netif);
|
|
Packit |
a132db |
|
|
Packit |
a132db |
struct fcm_netif_head fcm_netif_head;
|
|
Packit |
a132db |
|
|
Packit |
a132db |
static void fcm_dcbd_init(void);
|
|
Packit |
a132db |
static void fcm_dcbd_shutdown(void);
|
|
Packit |
a132db |
static void fcm_fcoe_init(void);
|
|
Packit |
a132db |
static struct fcm_netif *fcm_netif_lookup(char *);
|
|
Packit |
a132db |
static struct fcm_netif *fcm_netif_lookup_create(char *);
|
|
Packit |
a132db |
static int fcm_link_init(void);
|
|
Packit |
a132db |
static void fcm_dcbd_state_set(struct fcm_netif *, enum fcm_dcbd_state);
|
|
Packit |
a132db |
|
|
Packit |
a132db |
#endif /* _FCOEMON_H_ */
|