Skip to content

Commit 078ca93

Browse files
martin-gpyigaw
authored andcommitted
nvme-netapp: add nspath tlv handling
Add nspath tlv handling logic to the NetApp plugin. Signed-off-by: Martin George <marting@netapp.com>
1 parent 23e730d commit 078ca93

File tree

1 file changed

+32
-11
lines changed

1 file changed

+32
-11
lines changed

plugins/netapp/netapp-nvme.c

+32-11
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,14 @@ enum {
4646
enum {
4747
ONTAP_C2_LOG_SUPPORTED_LSP = 0x0,
4848
ONTAP_C2_LOG_NSINFO_LSP = 0x1,
49+
ONTAP_C2_LOG_PLATFORM_LSP = 0x2,
4950
};
5051

5152
enum {
52-
ONTAP_VSERVER_TLV = 0x11,
53-
ONTAP_VOLUME_TLV = 0x12,
54-
ONTAP_NS_TLV = 0x13,
53+
ONTAP_VSERVER_NAME_TLV = 0x11,
54+
ONTAP_VOLUME_NAME_TLV = 0x12,
55+
ONTAP_NS_NAME_TLV = 0x13,
56+
ONTAP_NS_PATH_TLV = 0x14,
5557
};
5658

5759
static const char *dev_path = "/dev/";
@@ -134,8 +136,10 @@ static void netapp_get_ontap_labels(char *vsname, char *nspath,
134136
unsigned char *log_data)
135137
{
136138
int lsp, tlv, label_len;
137-
char *vserver_name, *volume_name, *namespace_name;
139+
char *vserver_name, *volume_name, *namespace_name, *namespace_path;
138140
char vol_name[ONTAP_LABEL_LEN], ns_name[ONTAP_LABEL_LEN];
141+
char ns_path[ONTAP_LABEL_LEN];
142+
bool nspath_tlv_available = false;
139143
const char *ontap_vol = "/vol/";
140144
int i, j;
141145

@@ -145,9 +149,9 @@ static void netapp_get_ontap_labels(char *vsname, char *nspath,
145149
/* lsp not related to nsinfo */
146150
return;
147151

148-
/* get the vserver tlv and name */
152+
/* get the vserver name tlv */
149153
tlv = *(__u8 *)&log_data[32];
150-
if (tlv == ONTAP_VSERVER_TLV) {
154+
if (tlv == ONTAP_VSERVER_NAME_TLV) {
151155
label_len = (*(__u16 *)&log_data[34]) * 4;
152156
vserver_name = (char *)&log_data[36];
153157
ontap_labels_to_str(vsname, vserver_name, label_len);
@@ -159,9 +163,9 @@ static void netapp_get_ontap_labels(char *vsname, char *nspath,
159163

160164
i = 36 + label_len;
161165
j = i + 2;
162-
/* get the volume tlv and name */
166+
/* get the volume name tlv */
163167
tlv = *(__u8 *)&log_data[i];
164-
if (tlv == ONTAP_VOLUME_TLV) {
168+
if (tlv == ONTAP_VOLUME_NAME_TLV) {
165169
label_len = (*(__u16 *)&log_data[j]) * 4;
166170
volume_name = (char *)&log_data[j + 2];
167171
ontap_labels_to_str(vol_name, volume_name, label_len);
@@ -173,9 +177,9 @@ static void netapp_get_ontap_labels(char *vsname, char *nspath,
173177

174178
i += 4 + label_len;
175179
j += 4 + label_len;
176-
/* get the namespace tlv and name */
180+
/* get the namespace name tlv */
177181
tlv = *(__u8 *)&log_data[i];
178-
if (tlv == ONTAP_NS_TLV) {
182+
if (tlv == ONTAP_NS_NAME_TLV) {
179183
label_len = (*(__u16 *)&log_data[j]) * 4;
180184
namespace_name = (char *)&log_data[j + 2];
181185
ontap_labels_to_str(ns_name, namespace_name, label_len);
@@ -185,8 +189,25 @@ static void netapp_get_ontap_labels(char *vsname, char *nspath,
185189
return;
186190
}
187191

188-
snprintf(nspath, ONTAP_NS_PATHLEN, "%s%s%s%s", ontap_vol,
192+
i += 4 + label_len;
193+
j += 4 + label_len;
194+
/* get the namespace path tlv if available */
195+
tlv = *(__u8 *)&log_data[i];
196+
if (tlv == ONTAP_NS_PATH_TLV) {
197+
nspath_tlv_available = true;
198+
label_len = (*(__u16 *)&log_data[j]) * 4;
199+
namespace_path = (char *)&log_data[j + 2];
200+
ontap_labels_to_str(ns_path, namespace_path, label_len);
201+
}
202+
203+
if (nspath_tlv_available) {
204+
/* set nspath from the corresponding ns_path string */
205+
snprintf(nspath, ONTAP_NS_PATHLEN, "%s", ns_path);
206+
} else {
207+
/* set nspath by concatenating ontap_vol with ns_name */
208+
snprintf(nspath, ONTAP_NS_PATHLEN, "%s%s%s%s", ontap_vol,
189209
vol_name, "/", ns_name);
210+
}
190211
}
191212

192213
static void netapp_smdevice_json(struct json_object *devices, char *devname,

0 commit comments

Comments
 (0)