"Fossies" - the Fresh Open Source Software Archive

Member "aoe-87/linux/drivers/block/aoe/aoe.h" (23 Feb 2017, 6912 Bytes) of package /linux/misc/aoe-87.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "aoe.h" see the Fossies "Dox" file reference documentation.

    1 /* Copyright (c) 2013 Coraid, Inc.  See COPYING for GPL terms. */
    2 #define VERSION "87"
    3 #define AOE_MAJOR 152
    4 #define DEVICE_NAME "aoe"
    5 #define DEVICE_SUBDIR "etherd"
    6 
    7 /* AOE_PARTITIONS and DEVSUBDIR are set in the Makefile */
    8 
    9 #define WHITESPACE " \t\v\f\n,"
   10 /* for compatibility, so that this driver builds for kernels with
   11  * or without AoE already in them
   12  */
   13 #ifndef ETH_P_AOE
   14 #define ETH_P_AOE 0x88a2
   15 #endif
   16 
   17 enum {
   18     AOECMD_ATA,
   19     AOECMD_CFG,
   20     AOECMD_VEND_MIN = 0xf0,
   21 
   22     AOEFL_RSP = (1<<3),
   23     AOEFL_ERR = (1<<2),
   24 
   25     AOEAFL_EXT = (1<<6),
   26     AOEAFL_DEV = (1<<4),
   27     AOEAFL_ASYNC = (1<<1),
   28     AOEAFL_WRITE = (1<<0),
   29 
   30     AOECCMD_READ = 0,
   31     AOECCMD_TEST,
   32     AOECCMD_PTEST,
   33     AOECCMD_SET,
   34     AOECCMD_FSET,
   35 
   36     AOE_HVER = 0x10,
   37 };
   38 
   39 struct aoe_hdr {
   40     unsigned char dst[6];
   41     unsigned char src[6];
   42     u16 type;
   43     unsigned char verfl;
   44     unsigned char err;
   45     u16 major;
   46     unsigned char minor;
   47     unsigned char cmd;
   48     u32 tag;
   49 };
   50 
   51 struct aoe_atahdr {
   52     unsigned char aflags;
   53     unsigned char errfeat;
   54     unsigned char scnt;
   55     unsigned char cmdstat;
   56     unsigned char lba0;
   57     unsigned char lba1;
   58     unsigned char lba2;
   59     unsigned char lba3;
   60     unsigned char lba4;
   61     unsigned char lba5;
   62     unsigned char res[2];
   63 };
   64 
   65 struct aoe_cfghdr {
   66     u16 bufcnt;
   67     u16 fwver;
   68     unsigned char scnt;
   69     unsigned char aoeccmd;
   70     unsigned char cslen[2];
   71 };
   72 
   73 enum {
   74     DEVFL_UP = 1,   /* device is installed in system and ready for AoE->ATA commands */
   75     DEVFL_TKILL = (1<<1),   /* flag for timer to know when to kill self */
   76     DEVFL_EXT = (1<<2), /* device accepts lba48 commands */
   77     DEVFL_GDALLOC = (1<<3), /* need to alloc gendisk */
   78     DEVFL_GD_NOW = (1<<4),  /* allocating gendisk */
   79     DEVFL_KICKME = (1<<5),  /* slow polling network card catch */
   80     DEVFL_NEWSIZE = (1<<6), /* need to update dev size in block layer */
   81     DEVFL_FREEING = (1<<7), /* set when device is being cleaned up */
   82     DEVFL_FREED = (1<<8),   /* device has been cleaned up */
   83 };
   84 
   85 enum {
   86     DEFAULTBCNT = 2 * 512,  /* 2 sectors */
   87     MIN_BUFS = 16,
   88     NTARGETS = 4,
   89     NAOEIFS = 8,
   90     NSKBPOOLMAX = 256,
   91     NFACTIVE = 61,
   92 
   93     TIMERTICK = HZ / 10,
   94     RTTSCALE = 8,
   95     RTTDSCALE = 3,
   96     RTTAVG_INIT = USEC_PER_SEC / 4 << RTTSCALE,
   97     RTTDEV_INIT = RTTAVG_INIT / 4,
   98 
   99     HARD_SCORN_SECS = 10,   /* try another remote port after this */
  100     MAX_TAINT = 1000,   /* cap on aoetgt taint */
  101 };
  102 
  103 struct buf {
  104     ulong nframesout;
  105     struct bio *bio;
  106     struct bvec_iter iter;
  107     struct request *rq;
  108 };
  109 
  110 enum frame_flags {
  111     FFL_PROBE = 1,
  112 };
  113 
  114 struct frame {
  115     struct list_head head;
  116     u32 tag;
  117     struct timeval sent;    /* high-res time packet was sent */
  118     u32 sent_jiffs;     /* low-res jiffies-based sent time */
  119     ulong waited;
  120     ulong waited_total;
  121     struct aoetgt *t;       /* parent target I belong to */
  122     struct sk_buff *skb;        /* command skb freed on module exit */
  123     struct sk_buff *r_skb;      /* response skb for async processing */
  124     struct buf *buf;
  125     struct bvec_iter iter;
  126     ushort nout;        /* value of nout when skb was sent */
  127     char flags;
  128 };
  129 
  130 struct aoeif {
  131     struct net_device *nd;
  132     ulong lost;
  133     int bcnt;
  134 };
  135 
  136 struct aoetgt {
  137     unsigned char addr[6];
  138     ushort nframes;     /* cap on frames to use */
  139     struct aoedev *d;           /* parent device I belong to */
  140     struct list_head ffree;         /* list of free frames */
  141     struct aoeif ifs[NAOEIFS];
  142     struct aoeif *ifp;  /* current aoeif in use */
  143     ushort nout;        /* number of AoE commands outstanding */
  144     ushort maxout;      /* current value for max outstanding */
  145     ushort next_cwnd;   /* incr maxout after decrementing to zero */
  146     ushort ssthresh;    /* slow start threshold */
  147     ulong falloc;       /* number of allocated frames */
  148     ulong lost;     /* AoE commands w/o response */
  149     int taint;      /* how much we want to avoid this aoetgt */
  150     int minbcnt;
  151     int wpkts, rpkts;
  152     char nout_probes;
  153 };
  154 
  155 struct aoedev {
  156     struct aoedev *next;
  157     ulong sysminor;
  158     ulong aoemajor;
  159     u32 rttavg;     /* scaled AoE round trip time average */
  160     u32 rttdev;     /* scaled round trip time mean deviation */
  161     u16 aoeminor;
  162     u16 flags;
  163     u16 nopen;      /* (bd_openers isn't available without sleeping) */
  164     u16 fw_ver;     /* version of blade's firmware */
  165     u16 lasttag;        /* last tag sent */
  166     u16 useme;
  167     ulong ref;
  168     struct work_struct work;/* disk create work struct */
  169     struct gendisk *gd;
  170     struct dentry *debugfs;
  171     struct request_queue *blkq;
  172     struct hd_geometry geo;
  173     sector_t ssize;
  174     struct timer_list timer;
  175     spinlock_t lock;
  176     struct sk_buff *skbpool_hd;
  177     struct sk_buff *skbpool_tl;
  178     int nskbpool;
  179     mempool_t *bufpool; /* for deadlock-free Buf allocation */
  180     struct {        /* pointers to work in progress */
  181         struct buf *buf;
  182         struct bio *nxbio;
  183         struct request *rq;
  184     } ip;
  185     ulong maxbcnt;
  186     struct list_head factive[NFACTIVE]; /* hash of active frames */
  187     struct list_head rexmitq; /* deferred retransmissions */
  188     struct aoetgt **targets;
  189     ulong ntargets;     /* number of allocated aoetgt pointers */
  190     struct aoetgt **tgt;    /* target in use when working */
  191     ulong kicked;
  192     void *dbg;      /* opaque handle for aoedbg */
  193     char ident[512];
  194 };
  195 
  196 /* kthread tracking */
  197 struct ktstate {
  198     struct completion rendez;
  199     struct task_struct *task;
  200     wait_queue_head_t *waitq;
  201     int (*fn) (int);
  202     char name[12];
  203     spinlock_t *lock;
  204     int id;
  205     int active;
  206 };
  207 
  208 int aoeblk_init(void);
  209 void aoeblk_exit(void);
  210 void aoeblk_gdalloc(void *);
  211 void aoedisk_rm_debugfs(struct aoedev *d);
  212 void aoedisk_rm_sysfs(struct aoedev *d);
  213 void aoe_bio_pagedec(struct bio *);
  214 
  215 int aoechr_init(void);
  216 void aoechr_exit(void);
  217 void aoechr_error(char *);
  218 
  219 void aoecmd_work(struct aoedev *d);
  220 void aoecmd_cfg(ushort aoemajor, unsigned char aoeminor);
  221 struct sk_buff *aoecmd_ata_rsp(struct sk_buff *);
  222 void aoecmd_cfg_rsp(struct sk_buff *);
  223 void aoecmd_sleepwork(struct work_struct *);
  224 void aoecmd_wreset(struct aoetgt *t);
  225 void aoecmd_cleanslate(struct aoedev *);
  226 void aoecmd_exit(void);
  227 int aoecmd_init(void);
  228 struct sk_buff *aoecmd_ata_id(struct aoedev *);
  229 void aoe_freetframe(struct frame *);
  230 void aoe_bio_pagedec(struct bio *);
  231 void aoe_bio_pageinc(struct bio *);
  232 void aoe_flush_iocq(void);
  233 void aoe_flush_iocq_by_index(int);
  234 void aoe_end_request(struct aoedev *, struct request *, int);
  235 int aoe_ktstart(struct ktstate *k);
  236 void aoe_ktstop(struct ktstate *k);
  237 
  238 int aoedev_init(void);
  239 void aoedev_exit(void);
  240 struct aoedev *aoedev_by_aoeaddr(ulong maj, int min, int do_alloc);
  241 void aoedev_downdev(struct aoedev *d);
  242 int aoedev_flush(const char __user *str, size_t size);
  243 void aoe_failbuf(struct aoedev *, struct buf *);
  244 void aoedev_put(struct aoedev *);
  245 
  246 int aoenet_init(void);
  247 void aoenet_exit(void);
  248 void aoenet_xmit(struct sk_buff *);
  249 int is_aoe_netif(struct net_device *ifp);
  250 int set_aoe_iflist(const char __user *str, size_t size);
  251 
  252 unsigned long long mac_addr(char addr[6]);
  253 
  254 /* for compatibility with older 2.6 kernels lacking kcalloc
  255  */
  256 extern void *aoe_kcalloc(size_t, size_t, int);
  257 
  258 #define AOEDBG_ACTIVE 0
  259 void __init aoedbg_init(void);
  260 void aoedbg_print(char *fmt, ...);
  261 void aoedbg_rtt(struct aoedev *d, struct aoe_hdr *h, struct frame *f, int rtt);
  262 void aoedbg_devinit(struct aoedev *d);
  263 void aoedbg_undbg(struct aoedev *d);
  264 void aoedbg_exit(void);