-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable Pfcwd Queries #332
Enable Pfcwd Queries #332
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -110,7 +110,7 @@ func initAliasMap() error { | |
func initCountersPfcwdNameMap() error { | ||
var err error | ||
if len(countersPfcwdNameMap) == 0 { | ||
countersPfcwdNameMap, err = getPfcwdMap() | ||
countersPfcwdNameMap, err = GetPfcwdMap() | ||
if err != nil { | ||
return err | ||
} | ||
|
@@ -119,10 +119,11 @@ func initCountersPfcwdNameMap() error { | |
} | ||
|
||
// Get the mapping between sonic interface name and oids of their PFC-WD enabled queues in COUNTERS_DB | ||
func getPfcwdMap() (map[string]map[string]string, error) { | ||
func GetPfcwdMap() (map[string]map[string]string, error) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All other function names use camelcase format, should we go back to the previous name? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Making this function public for testing. Capitalizing the first letter in the function name makes it public. |
||
var pfcwdName_map = make(map[string]map[string]string) | ||
|
||
dbName := "CONFIG_DB" | ||
pfcwdTableName := "PFC_WD" | ||
redis_client_map, err := GetRedisClientsForDb(dbName) | ||
if err != nil { | ||
return nil, err | ||
|
@@ -134,8 +135,8 @@ func getPfcwdMap() (map[string]map[string]string, error) { | |
log.V(1).Infof("Can not connect to %v in namsespace %v, err: %v", dbName, namespace, err) | ||
return nil, err | ||
} | ||
|
||
keyName := fmt.Sprintf("PFC_WD_TABLE%v*", separator) | ||
keyName := fmt.Sprintf("%s%v*", pfcwdTableName, separator) | ||
resp, err := redisDb.Keys(keyName).Result() | ||
if err != nil { | ||
log.V(1).Infof("redis get keys failed for %v in namsepace %v, key = %v, err: %v", dbName, namespace, keyName, err) | ||
|
@@ -149,7 +150,10 @@ func getPfcwdMap() (map[string]map[string]string, error) { | |
} | ||
|
||
for _, key := range resp { | ||
name := key[13:] | ||
if strings.Contains(key, "GLOBAL") || strings.Contains(key, "global") { // ignore PFC_WD|global / PFC_WD|GLOBAL | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we ignore PFC_WD|global? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No counters associated with global since it is not a port. We are trying to create a mapping of oid from port name and pfc queue index which we will use to retrieve pfc wd counters. We ignore global since it serves no purpose for building the mapping since no port is associated with global |
||
continue | ||
} | ||
name := key[len(keyName) - 1:] | ||
pfcwdName_map[name] = make(map[string]string) | ||
} | ||
|
||
|
@@ -164,7 +168,15 @@ func getPfcwdMap() (map[string]map[string]string, error) { | |
log.V(1).Infof("PFC WD not enabled on device") | ||
return nil, nil | ||
} | ||
qos_key := resp[0] | ||
|
||
var qos_key string | ||
for _, key := range resp { | ||
if strings.Contains(key, "GLOBAL") || strings.Contains(key, "global") { // ignore PORT_QOS_MAP|global / PORT_QOS_MAP|GLOBAL | ||
continue | ||
} | ||
qos_key = key | ||
break | ||
} | ||
|
||
fieldName := "pfc_enable" | ||
priorities, err := redisDb.HGet(qos_key, fieldName).Result() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
connection close on error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a defer statement that will stop the server connection, if there is an error, before the function exits, the defer statement will be called.