Skip to content

Commit

Permalink
Merge pull request #720 from ywc689/tc2
Browse files Browse the repository at this point in the history
TC per-lcore tuning
  • Loading branch information
ywc689 authored Apr 15, 2021
2 parents 0e359e2 + 632ea8b commit e2bfc75
Show file tree
Hide file tree
Showing 34 changed files with 2,258 additions and 884 deletions.
Binary file added doc/pics/tc/fifo-qsch.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/pics/tc/pfifo_fast-qsch.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/pics/tc/tbf-qsch.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
862 changes: 862 additions & 0 deletions doc/tc.md

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions doc/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ DPVS Tutorial
- [KNI for virtual device](#vdev-kni)
* [UDP Option of Address (UOA)](#uoa)
* [Launch DPVS in Virtual Machine (Ubuntu)](#Ubuntu16.04)
* [Traffic Control(TC)](#tc)
* [Debug DPVS](#debug)
- [Debug with Log](#debug-with-log)
- [Packet Capture and Tcpdump](#packet-capture)
Expand Down Expand Up @@ -1151,6 +1152,12 @@ worker_defs {

```
<a id='tc'/>
# Traffic Control(TC)
Please refer to doc [tc.md](tc.md).
<a id='debug'/>
# Debug DPVS
Expand Down
4 changes: 4 additions & 0 deletions include/conf/match.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ static inline int parse_match(const char *pattern, uint8_t *proto,
*proto = IPPROTO_TCP;
} else if (strcmp(tok, "udp") == 0) {
*proto = IPPROTO_UDP;
} else if (strcmp(tok, "icmp") == 0) {
*proto = IPPROTO_ICMP;
} else if (strcmp(tok, "icmp6") == 0) {
*proto = IPPROTO_ICMPV6;
} else if (strncmp(tok, "from=", strlen("from=")) == 0) {
tok += strlen("from=");

Expand Down
22 changes: 14 additions & 8 deletions include/conf/tc.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
#include "tc/sch.h"
#include "tc/cls.h"

#define TC_F_OPS_STATS 0x0001
#define TC_F_OPS_VERBOSE 0x0002

typedef enum {
TC_OBJ_QSCH,
TC_OBJ_CLS,
Expand All @@ -39,6 +42,7 @@ typedef enum {
* scheduler section
*/
struct tc_qsch_param {
lcoreid_t cid;
tc_handle_t handle;
tc_handle_t where; /* TC_H_ROOT | TC_H_INGRESS | parent */
char kind[TCNAMESIZ]; /* qsch type: bfifo, tbf, ... */
Expand All @@ -50,23 +54,18 @@ struct tc_qsch_param {
} qopt;

/* get only */
int cls_cnt;
uint32_t flags;
struct qsch_qstats qstats;
struct qsch_bstats bstats;

/* master only, to fill stats from workers. */
struct qsch_qstats qstats_cpus[DPVS_MAX_LCORE];
struct qsch_bstats bstats_cpus[DPVS_MAX_LCORE];
} __attribute__((__packed__));

struct tc_qsch_stats {
struct qsch_qstats qstats;
struct qsch_bstats bstats;
} __attribute__((__packed__));

/**
* classifier section
*/
struct tc_cls_param {
lcoreid_t cid;
tc_handle_t sch_id; /* ID of Qsch attached to */
tc_handle_t handle; /* or class-id */
char kind[TCNAMESIZ]; /* tc_cls type: "match", ... */
Expand All @@ -88,6 +87,7 @@ union tc_param {

struct tc_conf {
tc_obj_t obj; /* schedler, classifier, ... */
uint32_t op_flags; /* TC_F_OPS_XXX */
char ifname[IFNAMSIZ];
union tc_param param; /* object specific parameters */
} __attribute__((__packed__));
Expand All @@ -102,6 +102,12 @@ static inline tc_handle_t tc_handle_atoi(const char *handle)
if (sscanf(handle, "%x:", &maj) == 1)
return (maj << 16);

if (!strncmp(handle, "root", 4))
return TC_H_ROOT;

if (!strncmp(handle, "ingress", 7))
return TC_H_INGRESS;

return TC_H_UNSPEC;
}

Expand Down
8 changes: 6 additions & 2 deletions include/ctrl.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ int msg_dump(const struct dpvs_msg *msg, char *buf, int len);
#define MSG_TYPE_BLKLST_ADD 9
#define MSG_TYPE_BLKLST_DEL 10
#define MSG_TYPE_STATS_GET 11
#define MSG_TYPE_TC_STATS 13
#define MSG_TYPE_CONN_GET 14
#define MSG_TYPE_CONN_GET_ALL 15
#define MSG_TYPE_IPV6_STATS 16
Expand All @@ -209,10 +208,15 @@ int msg_dump(const struct dpvs_msg *msg, char *buf, int len);
#define MSG_TYPE_IFA_SYNC 24
#define MSG_TYPE_WHTLST_ADD 25
#define MSG_TYPE_WHTLST_DEL 26
#define MSG_TYPE_TC_QSCH_GET 27
#define MSG_TYPE_TC_QSCH_SET 28
#define MSG_TYPE_TC_CLS_GET 29
#define MSG_TYPE_TC_CLS_SET 30
#define MSG_TYPE_IPVS_RANGE_START 100

/* for svc per_core, refer to service.h*/
enum {
MSG_TYPE_SVC_SET_FLUSH = MSG_TYPE_WHTLST_DEL + 1,
MSG_TYPE_SVC_SET_FLUSH = MSG_TYPE_IPVS_RANGE_START,
MSG_TYPE_SVC_SET_ZERO,
MSG_TYPE_SVC_SET_ADD,
MSG_TYPE_SVC_SET_EDIT,
Expand Down
6 changes: 6 additions & 0 deletions include/global_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ extern dpvs_lcore_role_t g_lcore_role[DPVS_MAX_LCORE];
* */
extern int g_lcore_index[DPVS_MAX_LCORE];
extern int g_lcore_num;
extern lcoreid_t g_master_lcore_id;
extern lcoreid_t g_kni_lcore_id;
extern uint8_t g_slave_lcore_num;
extern uint8_t g_isol_rx_lcore_num;
extern uint64_t g_slave_lcore_mask;
extern uint64_t g_isol_rx_lcore_mask;

int global_data_init(void);
int global_data_term(void);
Expand Down
2 changes: 1 addition & 1 deletion include/ipvs/redirect.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ struct dp_vs_redirect *dp_vs_redirect_get(int af, uint16_t proto,
void dp_vs_redirect_init(struct dp_vs_conn *conn);
int dp_vs_redirect_table_init(void);
int dp_vs_redirect_pkt(struct rte_mbuf *mbuf, lcoreid_t peer_cid);
void dp_vs_redirect_ring_proc(struct netif_queue_conf *qconf, lcoreid_t cid);
void dp_vs_redirect_ring_proc(lcoreid_t cid);
int dp_vs_redirects_init(void);
int dp_vs_redirects_term(void);

Expand Down
10 changes: 6 additions & 4 deletions include/netif.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ struct netif_port {
struct netif_kni kni; /* kni device */
union netif_bond *bond; /* bonding conf */
struct vlan_info *vlan_info; /* VLANs info for real device */
struct netif_tc tc; /* traffic control */
struct netif_tc tc[DPVS_MAX_LCORE]; /* traffic control */
struct netif_ops *netif_ops;
} __rte_cache_aligned;

Expand All @@ -269,8 +269,10 @@ int netif_register_master_xmit_msg(void);
int netif_lcore_conf_set(int lcores, const struct netif_lcore_conf *lconf);
bool is_lcore_id_valid(lcoreid_t cid);
bool netif_lcore_is_fwd_worker(lcoreid_t cid);
void lcore_process_packets(struct netif_queue_conf *qconf, struct rte_mbuf **mbufs,
lcoreid_t cid, uint16_t count, bool pkts_from_ring);
void lcore_process_packets(struct rte_mbuf **mbufs, lcoreid_t cid,
uint16_t count, bool pkts_from_ring);
int netif_rcv_mbuf(struct netif_port *dev, lcoreid_t cid,
struct rte_mbuf *mbuf, bool pkts_from_ring);

/************************** protocol API *****************************/
int netif_register_pkt(struct pkt_type *pt);
Expand Down Expand Up @@ -325,7 +327,7 @@ static inline void *netif_priv(struct netif_port *dev)

static inline struct netif_tc *netif_tc(struct netif_port *dev)
{
return &dev->tc;
return &dev->tc[rte_lcore_id()];
}

static inline uint16_t dpvs_rte_eth_dev_count(void)
Expand Down
3 changes: 2 additions & 1 deletion include/tc/cls.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ struct tc_cls_ops {
int (*dump)(struct tc_cls *cls, void *arg);

struct list_head list;
rte_atomic32_t refcnt;
};

/* classifier */
Expand Down Expand Up @@ -86,6 +85,8 @@ int tc_cls_change(struct tc_cls *cls, const void *arg);

struct tc_cls *tc_cls_lookup(struct Qsch *sch, tc_handle_t handle);

tc_handle_t cls_alloc_handle(struct Qsch *sch);

#endif /* __DPVS__ */

#endif /* __DPVS_TC_CLS_H__ */
Loading

0 comments on commit e2bfc75

Please sign in to comment.