Linux Audio

Check our new training course

Loading...
v6.13.7
  1/* SPDX-License-Identifier: GPL-2.0-only */
  2/*
  3 * Copyright (c) 2011-2012 Intel Corporation.  All rights reserved.
  4 *
 
 
 
 
 
 
 
 
 
 
 
 
 
  5 * Maintained at www.Open-FCoE.org
  6 */
  7
  8#ifndef FCOE_SYSFS
  9#define FCOE_SYSFS
 10
 11#include <linux/if_ether.h>
 12#include <linux/device.h>
 13#include <scsi/fc/fc_fcoe.h>
 14
 15struct fcoe_ctlr_device;
 16struct fcoe_fcf_device;
 17
 18struct fcoe_sysfs_function_template {
 19	void (*get_fcoe_ctlr_link_fail)(struct fcoe_ctlr_device *);
 20	void (*get_fcoe_ctlr_vlink_fail)(struct fcoe_ctlr_device *);
 21	void (*get_fcoe_ctlr_miss_fka)(struct fcoe_ctlr_device *);
 22	void (*get_fcoe_ctlr_symb_err)(struct fcoe_ctlr_device *);
 23	void (*get_fcoe_ctlr_err_block)(struct fcoe_ctlr_device *);
 24	void (*get_fcoe_ctlr_fcs_error)(struct fcoe_ctlr_device *);
 25	void (*set_fcoe_ctlr_mode)(struct fcoe_ctlr_device *);
 26	int  (*set_fcoe_ctlr_enabled)(struct fcoe_ctlr_device *);
 27	void (*get_fcoe_fcf_selected)(struct fcoe_fcf_device *);
 28	void (*get_fcoe_fcf_vlan_id)(struct fcoe_fcf_device *);
 29};
 30
 31#define dev_to_ctlr(d)					\
 32	container_of((d), struct fcoe_ctlr_device, dev)
 33
 34enum fip_conn_type {
 35	FIP_CONN_TYPE_UNKNOWN,
 36	FIP_CONN_TYPE_FABRIC,
 37	FIP_CONN_TYPE_VN2VN,
 38};
 39
 40enum ctlr_enabled_state {
 41	FCOE_CTLR_ENABLED,
 42	FCOE_CTLR_DISABLED,
 43	FCOE_CTLR_UNUSED,
 44};
 45
 46struct fcoe_ctlr_device {
 47	u32				id;
 48
 49	struct device			dev;
 50	struct fcoe_sysfs_function_template *f;
 51
 52	struct list_head		fcfs;
 
 53	struct workqueue_struct		*work_q;
 
 54	struct workqueue_struct		*devloss_work_q;
 55	struct mutex			lock;
 56
 57	int                             fcf_dev_loss_tmo;
 58	enum fip_conn_type              mode;
 59
 60	enum ctlr_enabled_state         enabled;
 61
 62	/* expected in host order for displaying */
 63	struct fcoe_fc_els_lesb         lesb;
 64};
 65
 66static inline void *fcoe_ctlr_device_priv(const struct fcoe_ctlr_device *ctlr)
 67{
 68	return (void *)(ctlr + 1);
 69}
 70
 71/* fcf states */
 72enum fcf_state {
 73	FCOE_FCF_STATE_UNKNOWN,
 74	FCOE_FCF_STATE_DISCONNECTED,
 75	FCOE_FCF_STATE_CONNECTED,
 76	FCOE_FCF_STATE_DELETED,
 77};
 78
 79struct fcoe_fcf_device {
 80	u32		    id;
 81	struct device	    dev;
 82	struct list_head    peers;
 83	struct work_struct  delete_work;
 84	struct delayed_work dev_loss_work;
 85	u32		    dev_loss_tmo;
 86	void                *priv;
 87	enum fcf_state      state;
 88
 89	u64                 fabric_name;
 90	u64                 switch_name;
 91	u32                 fc_map;
 92	u16                 vfid;
 93	u8                  mac[ETH_ALEN];
 94	u8                  priority;
 95	u32                 fka_period;
 96	u8                  selected;
 97	u16                 vlan_id;
 98};
 99
100#define dev_to_fcf(d)					\
101	container_of((d), struct fcoe_fcf_device, dev)
102/* parentage should never be missing */
103#define fcoe_fcf_dev_to_ctlr_dev(x)		\
104	dev_to_ctlr((x)->dev.parent)
105#define fcoe_fcf_device_priv(x)			\
106	((x)->priv)
107
108struct fcoe_ctlr_device *fcoe_ctlr_device_add(struct device *parent,
109			    struct fcoe_sysfs_function_template *f,
110			    int priv_size);
111void fcoe_ctlr_device_delete(struct fcoe_ctlr_device *);
112struct fcoe_fcf_device *fcoe_fcf_device_add(struct fcoe_ctlr_device *,
113					    struct fcoe_fcf_device *);
114void fcoe_fcf_device_delete(struct fcoe_fcf_device *);
115
116int __init fcoe_sysfs_setup(void);
117void __exit fcoe_sysfs_teardown(void);
118
119#endif /* FCOE_SYSFS */
v4.17
 
  1/*
  2 * Copyright (c) 2011-2012 Intel Corporation.  All rights reserved.
  3 *
  4 * This program is free software; you can redistribute it and/or modify it
  5 * under the terms and conditions of the GNU General Public License,
  6 * version 2, as published by the Free Software Foundation.
  7 *
  8 * This program is distributed in the hope it will be useful, but WITHOUT
  9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 10 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 11 * more details.
 12 *
 13 * You should have received a copy of the GNU General Public License along with
 14 * this program; if not, write to the Free Software Foundation, Inc.,
 15 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
 16 *
 17 * Maintained at www.Open-FCoE.org
 18 */
 19
 20#ifndef FCOE_SYSFS
 21#define FCOE_SYSFS
 22
 23#include <linux/if_ether.h>
 24#include <linux/device.h>
 25#include <scsi/fc/fc_fcoe.h>
 26
 27struct fcoe_ctlr_device;
 28struct fcoe_fcf_device;
 29
 30struct fcoe_sysfs_function_template {
 31	void (*get_fcoe_ctlr_link_fail)(struct fcoe_ctlr_device *);
 32	void (*get_fcoe_ctlr_vlink_fail)(struct fcoe_ctlr_device *);
 33	void (*get_fcoe_ctlr_miss_fka)(struct fcoe_ctlr_device *);
 34	void (*get_fcoe_ctlr_symb_err)(struct fcoe_ctlr_device *);
 35	void (*get_fcoe_ctlr_err_block)(struct fcoe_ctlr_device *);
 36	void (*get_fcoe_ctlr_fcs_error)(struct fcoe_ctlr_device *);
 37	void (*set_fcoe_ctlr_mode)(struct fcoe_ctlr_device *);
 38	int  (*set_fcoe_ctlr_enabled)(struct fcoe_ctlr_device *);
 39	void (*get_fcoe_fcf_selected)(struct fcoe_fcf_device *);
 40	void (*get_fcoe_fcf_vlan_id)(struct fcoe_fcf_device *);
 41};
 42
 43#define dev_to_ctlr(d)					\
 44	container_of((d), struct fcoe_ctlr_device, dev)
 45
 46enum fip_conn_type {
 47	FIP_CONN_TYPE_UNKNOWN,
 48	FIP_CONN_TYPE_FABRIC,
 49	FIP_CONN_TYPE_VN2VN,
 50};
 51
 52enum ctlr_enabled_state {
 53	FCOE_CTLR_ENABLED,
 54	FCOE_CTLR_DISABLED,
 55	FCOE_CTLR_UNUSED,
 56};
 57
 58struct fcoe_ctlr_device {
 59	u32				id;
 60
 61	struct device			dev;
 62	struct fcoe_sysfs_function_template *f;
 63
 64	struct list_head		fcfs;
 65	char				work_q_name[20];
 66	struct workqueue_struct		*work_q;
 67	char				devloss_work_q_name[20];
 68	struct workqueue_struct		*devloss_work_q;
 69	struct mutex			lock;
 70
 71	int                             fcf_dev_loss_tmo;
 72	enum fip_conn_type              mode;
 73
 74	enum ctlr_enabled_state         enabled;
 75
 76	/* expected in host order for displaying */
 77	struct fcoe_fc_els_lesb         lesb;
 78};
 79
 80static inline void *fcoe_ctlr_device_priv(const struct fcoe_ctlr_device *ctlr)
 81{
 82	return (void *)(ctlr + 1);
 83}
 84
 85/* fcf states */
 86enum fcf_state {
 87	FCOE_FCF_STATE_UNKNOWN,
 88	FCOE_FCF_STATE_DISCONNECTED,
 89	FCOE_FCF_STATE_CONNECTED,
 90	FCOE_FCF_STATE_DELETED,
 91};
 92
 93struct fcoe_fcf_device {
 94	u32		    id;
 95	struct device	    dev;
 96	struct list_head    peers;
 97	struct work_struct  delete_work;
 98	struct delayed_work dev_loss_work;
 99	u32		    dev_loss_tmo;
100	void                *priv;
101	enum fcf_state      state;
102
103	u64                 fabric_name;
104	u64                 switch_name;
105	u32                 fc_map;
106	u16                 vfid;
107	u8                  mac[ETH_ALEN];
108	u8                  priority;
109	u32                 fka_period;
110	u8                  selected;
111	u16                 vlan_id;
112};
113
114#define dev_to_fcf(d)					\
115	container_of((d), struct fcoe_fcf_device, dev)
116/* parentage should never be missing */
117#define fcoe_fcf_dev_to_ctlr_dev(x)		\
118	dev_to_ctlr((x)->dev.parent)
119#define fcoe_fcf_device_priv(x)			\
120	((x)->priv)
121
122struct fcoe_ctlr_device *fcoe_ctlr_device_add(struct device *parent,
123			    struct fcoe_sysfs_function_template *f,
124			    int priv_size);
125void fcoe_ctlr_device_delete(struct fcoe_ctlr_device *);
126struct fcoe_fcf_device *fcoe_fcf_device_add(struct fcoe_ctlr_device *,
127					    struct fcoe_fcf_device *);
128void fcoe_fcf_device_delete(struct fcoe_fcf_device *);
129
130int __init fcoe_sysfs_setup(void);
131void __exit fcoe_sysfs_teardown(void);
132
133#endif /* FCOE_SYSFS */