Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions api/agent.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ yanet_shm_detach(struct yanet_shm *shm);
struct dp_config *
yanet_shm_dp_config(struct yanet_shm *shm, uint32_t instance_idx);

struct dp_config *
yanet_shm_global_dp_config(struct yanet_shm *shm);

// Attaches a module agent to shared memory.
//
// Creates a new agent for a specific module in the given dataplane instance.
Expand Down
3 changes: 3 additions & 0 deletions api/counter.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ yanet_get_chain_counters(
const char *chain_name
);

struct counter_handle_list *
yanet_get_nic_counters(struct dp_config *dp_config);

// Get module counters, optionally filtered by name.
struct counter_handle_list *
yanet_get_module_counters(
Expand Down
17 changes: 17 additions & 0 deletions controlplane/ffi/shm.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ func (m *SharedMemory) DPConfig(instanceIdx uint32) *DPConfig {
return &DPConfig{ptr: ptr}
}

func (m *SharedMemory) DPGlobalConfig() *DPConfig {
ptr := C.yanet_shm_global_dp_config(m.ptr)

return &DPConfig{ptr: ptr}
}

// AgentAttach attaches a module agent to shared memory on the dataplane instance.
func (m *SharedMemory) AgentAttach(
name string,
Expand Down Expand Up @@ -754,6 +760,17 @@ func (m *DPConfig) PerformanceCounters(
return result, nil
}

func (m *DPConfig) NICCounters() []CounterInfo {
counters := C.yanet_get_nic_counters(m.ptr)
defer C.yanet_counter_handle_list_free(counters)

if counters == nil {
return nil
}

return m.encodeCounters(counters)
}

type ModuleReference struct {
Device string
Pipeline string
Expand Down
14 changes: 14 additions & 0 deletions controlplane/internal/gateway/counters_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,20 @@ func (m *CountersService) Module(
return response, nil
}

func (m *CountersService) NIC(
ctx context.Context,
request *ynpb.NICCounterRequest,
) (*ynpb.CountersResponse, error) {
dpConfig := m.shm.DPGlobalConfig()
counterValues := dpConfig.NICCounters()

Comment on lines +132 to +138
response := &ynpb.CountersResponse{
Counters: m.encodeCounters(counterValues),
}

return response, nil
}

func (m *CountersService) Perf(
ctx context.Context,
request *ynpb.PerfCountersRequest,
Expand Down
3 changes: 3 additions & 0 deletions controlplane/ynpb/counters.proto
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ service CountersService {
rpc Function(FunctionCountersRequest) returns (CountersResponse) {}
rpc Chain(ChainCountersRequest) returns (CountersResponse) {}
rpc Module(ModuleCountersRequest) returns (CountersResponse) {}
rpc NIC(NICCounterRequest) returns (CountersResponse) {}
rpc Perf(PerfCountersRequest) returns (PerfCountersResponse) {}
}

message DeviceCountersRequest { string device = 1; }

message NICCounterRequest { string device = 1; }

message PipelineCountersRequest {
string device = 1;
string pipeline = 2;
Expand Down
71 changes: 70 additions & 1 deletion dataplane/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ enum state {
state_connection_dst,

state_loglevel,

state_globalstats,
state_globalstat,
state_globalstat_dp_memory,
state_globalstat_cp_memory,

state_updatetimes,
state_updatetime,
state_updatetime_nic_updatetime,
};

int
Expand Down Expand Up @@ -129,6 +138,18 @@ dataplane_config_init(FILE *file, struct dataplane_config **config) {
goto error;
state = state_instance;
break;
case state_globalstat_dp_memory:
dataplane->globalstat.dp_memory = strtol(start, &end, 10);
if (*end != '\0')
goto error;
state = state_globalstat;
break;
case state_globalstat_cp_memory:
dataplane->globalstat.cp_memory = strtol(start, &end, 10);
if (*end != '\0')
goto error;
state = state_globalstat;
break;

case state_device_port_name:
strtcpy(device->port_name,
Expand Down Expand Up @@ -207,6 +228,13 @@ dataplane_config_init(FILE *file, struct dataplane_config **config) {
goto error;
state = state_connection;
break;
case state_updatetime_nic_updatetime:
dataplane->updatetimes.nic_updatetime =
strtol(start, &end, 10);
if (*end != '\0')
goto error;
state = state_updatetime;
break;

case state_empty:
if (!strcmp("dataplane", start)) {
Expand All @@ -226,6 +254,10 @@ dataplane_config_init(FILE *file, struct dataplane_config **config) {
state = state_devices;
} else if (!strcmp("connections", start)) {
state = state_connections;
} else if (!strcmp("globalstats", start)) {
state = state_globalstats;
} else if (!strcmp("updatetimes", start)) {
state = state_updatetimes;
} else if (!strcmp("loglevel", start)) {
state = state_loglevel;
} else {
Expand Down Expand Up @@ -287,7 +319,22 @@ dataplane_config_init(FILE *file, struct dataplane_config **config) {
}
break;
}

case state_globalstat:
if (!strcmp("dp_memory", start)) {
state = state_globalstat_dp_memory;
} else if (!strcmp("cp_memory", start)) {
state = state_globalstat_cp_memory;
} else {
goto error;
}
break;
case state_updatetime:
if (!strcmp("nic_updatetime", start)) {
state = state_updatetime_nic_updatetime;
} else {
goto error;
}
break;
default:
goto error;
}
Expand Down Expand Up @@ -322,6 +369,12 @@ dataplane_config_init(FILE *file, struct dataplane_config **config) {
case state_connections:
state = state_dataplane;
break;
case state_globalstats:
state = state_dataplane;
break;
case state_updatetimes:
state = state_dataplane;
break;
default:
goto error;
}
Expand All @@ -333,6 +386,14 @@ dataplane_config_init(FILE *file, struct dataplane_config **config) {
break;
case state_dataplane:
break;
case state_globalstats: {
state = state_globalstat;
break;
}
case state_updatetimes: {
state = state_updatetime;
break;
}
case state_instances: {
++dataplane->instance_count;

Expand Down Expand Up @@ -433,6 +494,9 @@ dataplane_config_init(FILE *file, struct dataplane_config **config) {
case state_connection:
state = state_connections;
break;
case state_globalstat:
state = state_dataplane;
break;
default:
goto error;
}
Expand All @@ -449,6 +513,11 @@ dataplane_config_init(FILE *file, struct dataplane_config **config) {

yaml_parser_delete(&parser);

// TODO: delete
dataplane->globalstat.cp_memory = (1 << 30) / 2;
dataplane->globalstat.dp_memory = (1 << 30) / 2;
dataplane->updatetimes.nic_updatetime = 1;

Comment on lines +516 to +520
*config = dataplane;

return 0;
Expand Down
14 changes: 14 additions & 0 deletions dataplane/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ struct dataplane_connection_config {
uint64_t dst_device_id;
};

struct dataplane_globalstat_config {
uint64_t dp_memory;
uint64_t cp_memory;
};

struct dataplane_events_updatetime {
uint64_t nic_updatetime;
};


struct dataplane_config {
char storage[80];
uint64_t dpdk_memory;
Expand All @@ -46,6 +56,10 @@ struct dataplane_config {
struct dataplane_device_config *devices;
uint64_t connection_count;
struct dataplane_connection_config *connections;

struct dataplane_globalstat_config globalstat;
struct dataplane_events_updatetime updatetimes;

char loglevel[32];
};

Expand Down
Loading
Loading