linux/drivers/net/ethernet/qlogic/qlcnic/qlcnic_dcb.h
<<
>>
Prefs
   1/*
   2 * QLogic qlcnic NIC Driver
   3 * Copyright (c)  2009-2013 QLogic Corporation
   4 *
   5 * See LICENSE.qlcnic for copyright and licensing details.
   6 */
   7
   8#ifndef __QLCNIC_DCBX_H
   9#define __QLCNIC_DCBX_H
  10
  11#define QLCNIC_DCB_STATE        0
  12#define QLCNIC_DCB_AEN_MODE     1
  13
  14#ifdef CONFIG_QLCNIC_DCB
  15int qlcnic_register_dcb(struct qlcnic_adapter *);
  16#else
  17static inline int qlcnic_register_dcb(struct qlcnic_adapter *adapter)
  18{ return 0; }
  19#endif
  20
  21struct qlcnic_dcb;
  22
  23struct qlcnic_dcb_ops {
  24        int (*query_hw_capability) (struct qlcnic_dcb *, char *);
  25        int (*get_hw_capability) (struct qlcnic_dcb *);
  26        int (*query_cee_param) (struct qlcnic_dcb *, char *, u8);
  27        void (*init_dcbnl_ops) (struct qlcnic_dcb *);
  28        void (*aen_handler) (struct qlcnic_dcb *, void *);
  29        int (*get_cee_cfg) (struct qlcnic_dcb *);
  30        void (*get_info) (struct qlcnic_dcb *);
  31        int (*attach) (struct qlcnic_dcb *);
  32        void (*free) (struct qlcnic_dcb *);
  33};
  34
  35struct qlcnic_dcb {
  36        struct qlcnic_dcb_mbx_params    *param;
  37        struct qlcnic_adapter           *adapter;
  38        struct delayed_work             aen_work;
  39        struct workqueue_struct         *wq;
  40        const struct qlcnic_dcb_ops     *ops;
  41        struct qlcnic_dcb_cfg           *cfg;
  42        unsigned long                   state;
  43};
  44
  45static inline void qlcnic_clear_dcb_ops(struct qlcnic_dcb *dcb)
  46{
  47        kfree(dcb);
  48}
  49
  50static inline int qlcnic_dcb_get_hw_capability(struct qlcnic_dcb *dcb)
  51{
  52        if (dcb && dcb->ops->get_hw_capability)
  53                return dcb->ops->get_hw_capability(dcb);
  54
  55        return 0;
  56}
  57
  58static inline void qlcnic_dcb_free(struct qlcnic_dcb *dcb)
  59{
  60        if (dcb && dcb->ops->free)
  61                dcb->ops->free(dcb);
  62}
  63
  64static inline int qlcnic_dcb_attach(struct qlcnic_dcb *dcb)
  65{
  66        if (dcb && dcb->ops->attach)
  67                return dcb->ops->attach(dcb);
  68
  69        return 0;
  70}
  71
  72static inline int
  73qlcnic_dcb_query_hw_capability(struct qlcnic_dcb *dcb, char *buf)
  74{
  75        if (dcb && dcb->ops->query_hw_capability)
  76                return dcb->ops->query_hw_capability(dcb, buf);
  77
  78        return 0;
  79}
  80
  81static inline void qlcnic_dcb_get_info(struct qlcnic_dcb *dcb)
  82{
  83        if (dcb && dcb->ops->get_info)
  84                dcb->ops->get_info(dcb);
  85}
  86
  87static inline int
  88qlcnic_dcb_query_cee_param(struct qlcnic_dcb *dcb, char *buf, u8 type)
  89{
  90        if (dcb && dcb->ops->query_cee_param)
  91                return dcb->ops->query_cee_param(dcb, buf, type);
  92
  93        return 0;
  94}
  95
  96static inline int qlcnic_dcb_get_cee_cfg(struct qlcnic_dcb *dcb)
  97{
  98        if (dcb && dcb->ops->get_cee_cfg)
  99                return dcb->ops->get_cee_cfg(dcb);
 100
 101        return 0;
 102}
 103
 104static inline void qlcnic_dcb_aen_handler(struct qlcnic_dcb *dcb, void *msg)
 105{
 106        if (dcb && dcb->ops->aen_handler)
 107                dcb->ops->aen_handler(dcb, msg);
 108}
 109
 110static inline void qlcnic_dcb_init_dcbnl_ops(struct qlcnic_dcb *dcb)
 111{
 112        if (dcb && dcb->ops->init_dcbnl_ops)
 113                dcb->ops->init_dcbnl_ops(dcb);
 114}
 115
 116static inline void qlcnic_dcb_enable(struct qlcnic_dcb *dcb)
 117{
 118        if (dcb && qlcnic_dcb_attach(dcb))
 119                qlcnic_clear_dcb_ops(dcb);
 120}
 121#endif
 122