Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * This file is part of the Chelsio T4 Ethernet driver for Linux.
0003  *
0004  * Copyright (c) 2016 Chelsio Communications, Inc. All rights reserved.
0005  *
0006  * This software is available to you under a choice of one of two
0007  * licenses.  You may choose to be licensed under the terms of the GNU
0008  * General Public License (GPL) Version 2, available from the file
0009  * COPYING in the main directory of this source tree, or the
0010  * OpenIB.org BSD license below:
0011  *
0012  *     Redistribution and use in source and binary forms, with or
0013  *     without modification, are permitted provided that the following
0014  *     conditions are met:
0015  *
0016  *      - Redistributions of source code must retain the above
0017  *        copyright notice, this list of conditions and the following
0018  *        disclaimer.
0019  *
0020  *      - Redistributions in binary form must reproduce the above
0021  *        copyright notice, this list of conditions and the following
0022  *        disclaimer in the documentation and/or other materials
0023  *        provided with the distribution.
0024  *
0025  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
0026  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
0027  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
0028  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
0029  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
0030  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
0031  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
0032  * SOFTWARE.
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 /* Max rate that can be set to a scheduling class is 100 Gbps */
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 {      /* per port scheduling 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  /* __CXGB4_SCHED_H */