0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035 #ifndef __CXGB4_SCHED_H
0036 #define __CXGB4_SCHED_H
0037
0038 #include <linux/spinlock.h>
0039 #include <linux/atomic.h>
0040
0041 #define SCHED_CLS_NONE 0xff
0042
0043 #define FW_SCHED_CLS_NONE 0xffffffff
0044
0045
0046 #define SCHED_MAX_RATE_KBPS 100000000U
0047
0048 enum {
0049 SCHED_STATE_ACTIVE,
0050 SCHED_STATE_UNUSED,
0051 };
0052
0053 enum sched_fw_ops {
0054 SCHED_FW_OP_ADD,
0055 SCHED_FW_OP_DEL,
0056 };
0057
0058 enum sched_bind_type {
0059 SCHED_QUEUE,
0060 SCHED_FLOWC,
0061 };
0062
0063 struct sched_queue_entry {
0064 struct list_head list;
0065 unsigned int cntxt_id;
0066 struct ch_sched_queue param;
0067 };
0068
0069 struct sched_flowc_entry {
0070 struct list_head list;
0071 struct ch_sched_flowc param;
0072 };
0073
0074 struct sched_class {
0075 u8 state;
0076 u8 idx;
0077 struct ch_sched_params info;
0078 enum sched_bind_type bind_type;
0079 struct list_head entry_list;
0080 atomic_t refcnt;
0081 };
0082
0083 struct sched_table {
0084 u8 sched_size;
0085 struct sched_class tab[];
0086 };
0087
0088 static inline bool can_sched(struct net_device *dev)
0089 {
0090 struct port_info *pi = netdev2pinfo(dev);
0091
0092 return !pi->sched_tbl ? false : true;
0093 }
0094
0095 static inline bool valid_class_id(struct net_device *dev, u8 class_id)
0096 {
0097 struct port_info *pi = netdev2pinfo(dev);
0098
0099 if ((class_id > pi->sched_tbl->sched_size - 1) &&
0100 (class_id != SCHED_CLS_NONE))
0101 return false;
0102
0103 return true;
0104 }
0105
0106 struct sched_class *cxgb4_sched_queue_lookup(struct net_device *dev,
0107 struct ch_sched_queue *p);
0108 int cxgb4_sched_class_bind(struct net_device *dev, void *arg,
0109 enum sched_bind_type type);
0110 int cxgb4_sched_class_unbind(struct net_device *dev, void *arg,
0111 enum sched_bind_type type);
0112
0113 struct sched_class *cxgb4_sched_class_alloc(struct net_device *dev,
0114 struct ch_sched_params *p);
0115 void cxgb4_sched_class_free(struct net_device *dev, u8 classid);
0116
0117 struct sched_table *t4_init_sched(unsigned int size);
0118 void t4_cleanup_sched(struct adapter *adap);
0119 #endif