Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions | Variables
fcoe_sysfs.c File Reference
#include <linux/module.h>
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/etherdevice.h>
#include <scsi/fcoe_sysfs.h>

Go to the source code of this file.

Macros

#define fcoe_ctlr_id(x)   ((x)->id)
 
#define fcoe_ctlr_work_q_name(x)   ((x)->work_q_name)
 
#define fcoe_ctlr_work_q(x)   ((x)->work_q)
 
#define fcoe_ctlr_devloss_work_q_name(x)   ((x)->devloss_work_q_name)
 
#define fcoe_ctlr_devloss_work_q(x)   ((x)->devloss_work_q)
 
#define fcoe_ctlr_mode(x)   ((x)->mode)
 
#define fcoe_ctlr_fcf_dev_loss_tmo(x)   ((x)->fcf_dev_loss_tmo)
 
#define fcoe_ctlr_link_fail(x)   ((x)->lesb.lesb_link_fail)
 
#define fcoe_ctlr_vlink_fail(x)   ((x)->lesb.lesb_vlink_fail)
 
#define fcoe_ctlr_miss_fka(x)   ((x)->lesb.lesb_miss_fka)
 
#define fcoe_ctlr_symb_err(x)   ((x)->lesb.lesb_symb_err)
 
#define fcoe_ctlr_err_block(x)   ((x)->lesb.lesb_err_block)
 
#define fcoe_ctlr_fcs_error(x)   ((x)->lesb.lesb_fcs_error)
 
#define fcoe_fcf_state(x)   ((x)->state)
 
#define fcoe_fcf_fabric_name(x)   ((x)->fabric_name)
 
#define fcoe_fcf_switch_name(x)   ((x)->switch_name)
 
#define fcoe_fcf_fc_map(x)   ((x)->fc_map)
 
#define fcoe_fcf_vfid(x)   ((x)->vfid)
 
#define fcoe_fcf_mac(x)   ((x)->mac)
 
#define fcoe_fcf_priority(x)   ((x)->priority)
 
#define fcoe_fcf_fka_period(x)   ((x)->fka_period)
 
#define fcoe_fcf_dev_loss_tmo(x)   ((x)->dev_loss_tmo)
 
#define fcoe_fcf_selected(x)   ((x)->selected)
 
#define fcoe_fcf_vlan_id(x)   ((x)->vlan_id)
 
#define FCOE_DEVICE_ATTR(_prefix, _name, _mode, _show, _store)
 
#define fcoe_ctlr_show_function(field, format_string, sz, cast)
 
#define fcoe_fcf_show_function(field, format_string, sz, cast)
 
#define fcoe_ctlr_private_show_function(field, format_string, sz, cast)
 
#define fcoe_fcf_private_show_function(field, format_string, sz, cast)
 
#define fcoe_ctlr_private_rd_attr(field, format_string, sz)
 
#define fcoe_ctlr_rd_attr(field, format_string, sz)
 
#define fcoe_fcf_rd_attr(field, format_string, sz)
 
#define fcoe_fcf_private_rd_attr(field, format_string, sz)
 
#define fcoe_ctlr_private_rd_attr_cast(field, format_string, sz, cast)
 
#define fcoe_fcf_private_rd_attr_cast(field, format_string, sz, cast)
 
#define fcoe_enum_name_search(title, table_type, table)
 
#define FCOE_FCF_STATE_MAX_NAMELEN   50
 
#define FCOE_CTLR_MODE_MAX_NAMELEN   50
 

Functions

 module_param_named (fcf_dev_loss_tmo, fcoe_fcf_dev_loss_tmo, uint, S_IRUGO|S_IWUSR)
 
 MODULE_PARM_DESC (fcf_dev_loss_tmo,"Maximum number of seconds that libfcoe should"" insulate the loss of a fcf. Once this value is"" exceeded, the fcf is removed.")
 
 fcoe_enum_name_search (fcf_state, fcf_state, fcf_state_names)
 
 fcoe_enum_name_search (ctlr_mode, fip_conn_type, fip_conn_type_names)
 
 fcoe_ctlr_private_show_function (fcf_dev_loss_tmo,"%d\n", 20,)
 
 fcoe_ctlr_rd_attr (link_fail,"%u\n", 20)
 
 fcoe_ctlr_rd_attr (vlink_fail,"%u\n", 20)
 
 fcoe_ctlr_rd_attr (miss_fka,"%u\n", 20)
 
 fcoe_ctlr_rd_attr (symb_err,"%u\n", 20)
 
 fcoe_ctlr_rd_attr (err_block,"%u\n", 20)
 
 fcoe_ctlr_rd_attr (fcs_error,"%u\n", 20)
 
 fcoe_fcf_private_rd_attr_cast (fabric_name,"0x%llx\n", 20, unsigned long long)
 
 fcoe_fcf_private_rd_attr_cast (switch_name,"0x%llx\n", 20, unsigned long long)
 
 fcoe_fcf_private_rd_attr (priority,"%u\n", 20)
 
 fcoe_fcf_private_rd_attr (fc_map,"0x%x\n", 20)
 
 fcoe_fcf_private_rd_attr (vfid,"%u\n", 20)
 
 fcoe_fcf_private_rd_attr (mac,"%pM\n", 20)
 
 fcoe_fcf_private_rd_attr (fka_period,"%u\n", 20)
 
 fcoe_fcf_rd_attr (selected,"%u\n", 20)
 
 fcoe_fcf_rd_attr (vlan_id,"%u\n", 20)
 
 fcoe_fcf_private_show_function (dev_loss_tmo,"%d\n", 20)
 
void fcoe_ctlr_device_flush_work (struct fcoe_ctlr_device *ctlr)
 
int fcoe_ctlr_device_queue_work (struct fcoe_ctlr_device *ctlr, struct work_struct *work)
 
void fcoe_ctlr_device_flush_devloss (struct fcoe_ctlr_device *ctlr)
 
int fcoe_ctlr_device_queue_devloss_work (struct fcoe_ctlr_device *ctlr, struct delayed_work *work, unsigned long delay)
 
struct fcoe_ctlr_devicefcoe_ctlr_device_add (struct device *parent, struct fcoe_sysfs_function_template *f, int priv_size)
 
 EXPORT_SYMBOL_GPL (fcoe_ctlr_device_add)
 
void fcoe_ctlr_device_delete (struct fcoe_ctlr_device *ctlr)
 
 EXPORT_SYMBOL_GPL (fcoe_ctlr_device_delete)
 
void fcoe_fcf_device_delete (struct fcoe_fcf_device *fcf)
 
 EXPORT_SYMBOL_GPL (fcoe_fcf_device_delete)
 
struct fcoe_fcf_devicefcoe_fcf_device_add (struct fcoe_ctlr_device *ctlr, struct fcoe_fcf_device *new_fcf)
 
 EXPORT_SYMBOL_GPL (fcoe_fcf_device_add)
 
int __init fcoe_sysfs_setup (void)
 
void __exit fcoe_sysfs_teardown (void)
 

Variables

struct bus_type fcoe_bus_type
 
struct device_type fcoe_ctlr_device_type
 
struct device_type fcoe_fcf_device_type
 

Macro Definition Documentation

#define fcoe_ctlr_devloss_work_q (   x)    ((x)->devloss_work_q)

Definition at line 56 of file fcoe_sysfs.c.

#define fcoe_ctlr_devloss_work_q_name (   x)    ((x)->devloss_work_q_name)

Definition at line 54 of file fcoe_sysfs.c.

#define fcoe_ctlr_err_block (   x)    ((x)->lesb.lesb_err_block)

Definition at line 70 of file fcoe_sysfs.c.

#define fcoe_ctlr_fcf_dev_loss_tmo (   x)    ((x)->fcf_dev_loss_tmo)

Definition at line 60 of file fcoe_sysfs.c.

#define fcoe_ctlr_fcs_error (   x)    ((x)->lesb.lesb_fcs_error)

Definition at line 72 of file fcoe_sysfs.c.

#define fcoe_ctlr_id (   x)    ((x)->id)

Definition at line 48 of file fcoe_sysfs.c.

#define fcoe_ctlr_link_fail (   x)    ((x)->lesb.lesb_link_fail)

Definition at line 62 of file fcoe_sysfs.c.

#define fcoe_ctlr_miss_fka (   x)    ((x)->lesb.lesb_miss_fka)

Definition at line 66 of file fcoe_sysfs.c.

#define fcoe_ctlr_mode (   x)    ((x)->mode)

Definition at line 58 of file fcoe_sysfs.c.

#define FCOE_CTLR_MODE_MAX_NAMELEN   50
#define fcoe_ctlr_private_rd_attr (   field,
  format_string,
  sz 
)
Value:
fcoe_ctlr_private_show_function(field, format_string, sz, ) \
static FCOE_DEVICE_ATTR(ctlr, field, S_IRUGO, \
show_fcoe_ctlr_device_##field, NULL)

Definition at line 180 of file fcoe_sysfs.c.

#define fcoe_ctlr_private_rd_attr_cast (   field,
  format_string,
  sz,
  cast 
)
Value:
fcoe_ctlr_private_show_function(field, format_string, sz, (cast)) \
static FCOE_DEVICE_ATTR(ctlr, field, S_IRUGO, \
show_fcoe_ctlr_device_##field, NULL)

Definition at line 200 of file fcoe_sysfs.c.

#define fcoe_ctlr_private_show_function (   field,
  format_string,
  sz,
  cast 
)
Value:
static ssize_t show_fcoe_ctlr_device_##field(struct device *dev, \
char *buf) \
{ \
return snprintf(buf, sz, format_string, cast fcoe_ctlr_##field(ctlr)); \
}

Definition at line 162 of file fcoe_sysfs.c.

#define fcoe_ctlr_rd_attr (   field,
  format_string,
  sz 
)
Value:
fcoe_ctlr_show_function(field, format_string, sz, ) \
static FCOE_DEVICE_ATTR(ctlr, field, S_IRUGO, \
show_fcoe_ctlr_device_##field, NULL)

Definition at line 185 of file fcoe_sysfs.c.

#define fcoe_ctlr_show_function (   field,
  format_string,
  sz,
  cast 
)
Value:
static ssize_t show_fcoe_ctlr_device_##field(struct device *dev, \
char *buf) \
{ \
if (ctlr->f->get_fcoe_ctlr_##field) \
ctlr->f->get_fcoe_ctlr_##field(ctlr); \
return snprintf(buf, sz, format_string, \
cast fcoe_ctlr_##field(ctlr)); \
}

Definition at line 137 of file fcoe_sysfs.c.

#define fcoe_ctlr_symb_err (   x)    ((x)->lesb.lesb_symb_err)

Definition at line 68 of file fcoe_sysfs.c.

#define fcoe_ctlr_vlink_fail (   x)    ((x)->lesb.lesb_vlink_fail)

Definition at line 64 of file fcoe_sysfs.c.

#define fcoe_ctlr_work_q (   x)    ((x)->work_q)

Definition at line 52 of file fcoe_sysfs.c.

#define fcoe_ctlr_work_q_name (   x)    ((x)->work_q_name)

Definition at line 50 of file fcoe_sysfs.c.

#define FCOE_DEVICE_ATTR (   _prefix,
  _name,
  _mode,
  _show,
  _store 
)
Value:
struct device_attribute device_attr_fcoe_##_prefix##_##_name = \
__ATTR(_name, _mode, _show, _store)

Definition at line 133 of file fcoe_sysfs.c.

#define fcoe_enum_name_search (   title,
  table_type,
  table 
)
Value:
static const char *get_fcoe_##title##_name(enum table_type table_key) \
{ \
int i; \
char *name = NULL; \
for (i = 0; i < ARRAY_SIZE(table); i++) { \
if (table[i].value == table_key) { \
name = table[i].name; \
break; \
} \
} \
return name; \
}

Definition at line 210 of file fcoe_sysfs.c.

#define fcoe_fcf_dev_loss_tmo (   x)    ((x)->dev_loss_tmo)

Definition at line 90 of file fcoe_sysfs.c.

#define fcoe_fcf_fabric_name (   x)    ((x)->fabric_name)

Definition at line 76 of file fcoe_sysfs.c.

#define fcoe_fcf_fc_map (   x)    ((x)->fc_map)

Definition at line 80 of file fcoe_sysfs.c.

#define fcoe_fcf_fka_period (   x)    ((x)->fka_period)

Definition at line 88 of file fcoe_sysfs.c.

#define fcoe_fcf_mac (   x)    ((x)->mac)

Definition at line 84 of file fcoe_sysfs.c.

#define fcoe_fcf_priority (   x)    ((x)->priority)

Definition at line 86 of file fcoe_sysfs.c.

#define fcoe_fcf_private_rd_attr (   field,
  format_string,
  sz 
)
Value:
fcoe_fcf_private_show_function(field, format_string, sz, ) \
static FCOE_DEVICE_ATTR(fcf, field, S_IRUGO, \
show_fcoe_fcf_device_##field, NULL)

Definition at line 195 of file fcoe_sysfs.c.

#define fcoe_fcf_private_rd_attr_cast (   field,
  format_string,
  sz,
  cast 
)
Value:
fcoe_fcf_private_show_function(field, format_string, sz, (cast)) \
static FCOE_DEVICE_ATTR(fcf, field, S_IRUGO, \
show_fcoe_fcf_device_##field, NULL)

Definition at line 205 of file fcoe_sysfs.c.

#define fcoe_fcf_private_show_function (   field,
  format_string,
  sz,
  cast 
)
Value:
static ssize_t show_fcoe_fcf_device_##field(struct device *dev, \
char *buf) \
{ \
return snprintf(buf, sz, format_string, cast fcoe_fcf_##field(fcf)); \
}

Definition at line 171 of file fcoe_sysfs.c.

#define fcoe_fcf_rd_attr (   field,
  format_string,
  sz 
)
Value:
fcoe_fcf_show_function(field, format_string, sz, ) \
static FCOE_DEVICE_ATTR(fcf, field, S_IRUGO, \
show_fcoe_fcf_device_##field, NULL)

Definition at line 190 of file fcoe_sysfs.c.

#define fcoe_fcf_selected (   x)    ((x)->selected)

Definition at line 92 of file fcoe_sysfs.c.

#define fcoe_fcf_show_function (   field,
  format_string,
  sz,
  cast 
)
Value:
static ssize_t show_fcoe_fcf_device_##field(struct device *dev, \
char *buf) \
{ \
if (ctlr->f->get_fcoe_fcf_##field) \
ctlr->f->get_fcoe_fcf_##field(fcf); \
return snprintf(buf, sz, format_string, \
cast fcoe_fcf_##field(fcf)); \
}

Definition at line 149 of file fcoe_sysfs.c.

#define fcoe_fcf_state (   x)    ((x)->state)

Definition at line 74 of file fcoe_sysfs.c.

#define FCOE_FCF_STATE_MAX_NAMELEN   50
#define fcoe_fcf_switch_name (   x)    ((x)->switch_name)

Definition at line 78 of file fcoe_sysfs.c.

#define fcoe_fcf_vfid (   x)    ((x)->vfid)

Definition at line 82 of file fcoe_sysfs.c.

#define fcoe_fcf_vlan_id (   x)    ((x)->vlan_id)

Definition at line 94 of file fcoe_sysfs.c.

Function Documentation

EXPORT_SYMBOL_GPL ( fcoe_ctlr_device_add  )
EXPORT_SYMBOL_GPL ( fcoe_ctlr_device_delete  )
EXPORT_SYMBOL_GPL ( fcoe_fcf_device_delete  )
EXPORT_SYMBOL_GPL ( fcoe_fcf_device_add  )
struct fcoe_ctlr_device* fcoe_ctlr_device_add ( struct device parent,
struct fcoe_sysfs_function_template f,
int  priv_size 
)
read

fcoe_ctlr_device_add() - Add a FIP ctlr to sysfs : The parent device to which the fcoe_ctlr instance should be attached : The LLD's FCoE sysfs function template pointer : Size to be allocated with the fcoe_ctlr_device for the LLD

This routine allocates a FIP ctlr object with some additional memory for the LLD. The FIP ctlr is initialized, added to sysfs and then attributes are added to it.

Definition at line 555 of file fcoe_sysfs.c.

void fcoe_ctlr_device_delete ( struct fcoe_ctlr_device ctlr)

fcoe_ctlr_device_delete() - Delete a FIP ctlr and its subtree from sysfs : A pointer to the ctlr to be deleted

Deletes a FIP ctlr and any fcfs attached to it. Deleting fcfs will cause their childen to be deleted as well.

The ctlr is detached from sysfs and it's resources are freed (work q), but the memory is not freed until its last reference is released.

This routine expects no locks to be held before calling.

TODO: Currently there are no callbacks to clean up LLD data for a fcoe_fcf_device. LLDs must keep this in mind as they need to clean up each of their LLD data for all fcoe_fcf_device before calling fcoe_ctlr_device_delete.

Definition at line 632 of file fcoe_sysfs.c.

void fcoe_ctlr_device_flush_devloss ( struct fcoe_ctlr_device ctlr)

fcoe_ctlr_device_flush_devloss() - Flush a FIP ctlr's devloss workqueue : Pointer to FIP ctlr whose workqueue is to be flushed

Definition at line 495 of file fcoe_sysfs.c.

void fcoe_ctlr_device_flush_work ( struct fcoe_ctlr_device ctlr)

fcoe_ctlr_device_flush_work() - Flush a FIP ctlr's workqueue : Pointer to the FIP ctlr whose workqueue is to be flushed

Definition at line 455 of file fcoe_sysfs.c.

int fcoe_ctlr_device_queue_devloss_work ( struct fcoe_ctlr_device ctlr,
struct delayed_work work,
unsigned long  delay 
)

fcoe_ctlr_device_queue_devloss_work() - Schedule work for a FIP ctlr's devloss workqueue : Pointer to the FIP ctlr who owns the devloss workqueue : Work to queue for execution : jiffies to delay the work queuing

Return value: 1 on success / 0 already queued / < 0 for error

Definition at line 517 of file fcoe_sysfs.c.

int fcoe_ctlr_device_queue_work ( struct fcoe_ctlr_device ctlr,
struct work_struct work 
)

fcoe_ctlr_device_queue_work() - Schedule work for a FIP ctlr's workqueue : Pointer to the FIP ctlr who owns the devloss workqueue : Work to queue for execution

Return value: 1 on success / 0 already queued / < 0 for error

Definition at line 476 of file fcoe_sysfs.c.

fcoe_ctlr_private_show_function ( fcf_dev_loss_tmo  ,
"%d\n"  ,
20   
)
fcoe_ctlr_rd_attr ( link_fail  ,
"%u\n"  ,
20   
)
fcoe_ctlr_rd_attr ( vlink_fail  ,
"%u\n"  ,
20   
)
fcoe_ctlr_rd_attr ( miss_fka  ,
"%u\n"  ,
20   
)
fcoe_ctlr_rd_attr ( symb_err  ,
"%u\n"  ,
20   
)
fcoe_ctlr_rd_attr ( err_block  ,
"%u\n"  ,
20   
)
fcoe_ctlr_rd_attr ( fcs_error  ,
"%u\n"  ,
20   
)
fcoe_enum_name_search ( fcf_state  ,
fcf_state  ,
fcf_state_names   
)

Definition at line 233 of file fcoe_sysfs.c.

fcoe_enum_name_search ( ctlr_mode  ,
fip_conn_type  ,
fip_conn_type_names   
)

Definition at line 257 of file fcoe_sysfs.c.

struct fcoe_fcf_device* fcoe_fcf_device_add ( struct fcoe_ctlr_device ctlr,
struct fcoe_fcf_device new_fcf 
)
read

fcoe_fcf_device_add() - Add a FCoE sysfs fcoe_fcf_device to the system : The fcoe_ctlr_device that will be the fcoe_fcf_device parent : A temporary FCF used for lookups on the current list of fcfs

Expects to be called with the ctlr->lock held

Definition at line 753 of file fcoe_sysfs.c.

void fcoe_fcf_device_delete ( struct fcoe_fcf_device fcf)

fcoe_fcf_device_delete() - Delete a FIP fcf : Pointer to the fcf which is to be deleted

Queues the FIP fcf on the devloss workqueue

Expects the ctlr_attrs mutex to be held for fcf state change.

Definition at line 724 of file fcoe_sysfs.c.

fcoe_fcf_private_rd_attr ( priority  ,
"%u\n"  ,
20   
)
fcoe_fcf_private_rd_attr ( fc_map  ,
"0x%x\n"  ,
20   
)
fcoe_fcf_private_rd_attr ( vfid  ,
"%u\n"  ,
20   
)
fcoe_fcf_private_rd_attr ( mac  ,
"%pM\n"  ,
20   
)
fcoe_fcf_private_rd_attr ( fka_period  ,
"%u\n"  ,
20   
)
fcoe_fcf_private_rd_attr_cast ( fabric_name  ,
"0x%llx\n"  ,
20  ,
unsigned long  long 
)
fcoe_fcf_private_rd_attr_cast ( switch_name  ,
"0x%llx\n"  ,
20  ,
unsigned long  long 
)
fcoe_fcf_private_show_function ( dev_loss_tmo  ,
"%d\n"  ,
20   
)

Definition at line 323 of file fcoe_sysfs.c.

fcoe_fcf_rd_attr ( selected  ,
"%u\n"  ,
20   
)
fcoe_fcf_rd_attr ( vlan_id  ,
"%u\n"  ,
20   
)
int __init fcoe_sysfs_setup ( void  )

Definition at line 815 of file fcoe_sysfs.c.

void __exit fcoe_sysfs_teardown ( void  )

Definition at line 829 of file fcoe_sysfs.c.

module_param_named ( fcf_dev_loss_tmo  ,
fcoe_fcf_dev_loss_tmo  ,
uint  ,
S_IRUGO S_IWUSR 
)
MODULE_PARM_DESC ( fcf_dev_loss_tmo  ,
"Maximum number of seconds that libfcoe should"" insulate the loss of a fcf. Once this value is""  exceeded,
the fcf is removed."   
)

Variable Documentation

struct bus_type fcoe_bus_type
Initial value:
= {
.name = "fcoe",
.match = &fcoe_bus_match,
}

Definition at line 400 of file fcoe_sysfs.c.

struct device_type fcoe_ctlr_device_type
Initial value:
= {
.name = "fcoe_ctlr",
.groups = fcoe_ctlr_attr_groups,
.release = fcoe_ctlr_device_release,
}

Definition at line 434 of file fcoe_sysfs.c.

struct device_type fcoe_fcf_device_type
Initial value:
= {
.name = "fcoe_fcf",
.groups = fcoe_fcf_attr_groups,
.release = fcoe_fcf_device_release,
}

Definition at line 440 of file fcoe_sysfs.c.

char* name

Definition at line 227 of file fcoe_sysfs.c.

enum fip_conn_type value

Definition at line 226 of file fcoe_sysfs.c.