Skip to content

Commit ee8e42a

Browse files
authored
fix how to extract property from vfp port state (#541)
This pull request updates the logic for parsing VFP port state properties in `Get-SdnVfpPortState` to better handle properties that are output without explicit key/value pairs, and adds support for the `SriovEnabled` property in the `VfpPortState` class. The main changes focus on improving how enabled features are detected and mapped to the state object. **Enhancements to VFP Port State Parsing:** * Updated the parsing logic in `Get-SdnVfpPortState` to handle lines that only contain a property name (without a value), assuming these properties are enabled by default when present in the output. This ensures properties like "SR-IOV Enabled" and various offload features are correctly set to `$true` when detected. * Moved the mapping of several port state and offload properties (such as "DTLS Offload Enabled", "GFT Offload Enabled", and various NVGRE/VXLAN offload features) from the key/value parsing block to the new single-property-line parsing block, improving robustness and accuracy. [[1]](diffhunk://#diff-11217f20b55d3b4ea34c8c217794c81d65acc4852dff9bf4295e5cc4d6dfaeedL2231-L2250) [[2]](diffhunk://#diff-11217f20b55d3b4ea34c8c217794c81d65acc4852dff9bf4295e5cc4d6dfaeedL2265-R2280) **VfpPortState Class Update:** * Added a new `[boolean]$SriovEnabled` property to the `VfpPortState` class to track the SR-IOV enablement state. # Change type - [x] Bug fix (non-breaking change) - [ ] Code style update (formatting, local variables) - [ ] New Feature (non-breaking change that adds new functionality without impacting existing) - [ ] Breaking change (fix or feature that may cause functionality impact) - [ ] Other # Checklist: - [x] My code follows the style and contribution guidelines of this project. - [x] I have tested and validated my code changes.
1 parent 9a66e82 commit ee8e42a

File tree

1 file changed

+31
-19
lines changed

1 file changed

+31
-19
lines changed

src/modules/SdnDiag.Server.psm1

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ class VfpPortState {
163163
[boolean]$PreserveVlan
164164
[boolean]$IsVmContextSet
165165
[boolean]$VmqEnabled
166+
[boolean]$SriovEnabled
166167
$OffloadState = [OffLoadStateDetails]::new()
167168
[boolean]$QosHardwareReservationsEnabled
168169
[boolean]$QosHardwareCapsEnabled
@@ -2228,26 +2229,9 @@ function Get-SdnVfpPortState {
22282229
'Blocked' { $object.Blocked = $propertyValue }
22292230
'BlockedOnRestore' { $object.BlockOnRestore = $propertyValue }
22302231
'BlockedLayerCreation' { $object.BlockLayerCreation = $propertyValue }
2231-
'DTLS Offload Enabled' { $object.DtlsOffloadEnabled = $propertyValue }
2232-
'GFT Offload Enabled' { $object.GftOffloadEnabled = $propertyValue }
2233-
'QoS Hardware Transmit Cap Offload Enabled' { $object.QosHardwareCapsEnabled = $propertyValue }
2234-
'QoS Hardware Transmit Reservation Offload Enabled' { $object.QosHardwareReservationsEnabled = $propertyValue }
22352232
'Preserving Vlan' { $object.PreserveVlan = $propertyValue }
22362233
'VM Context Set' { $object.IsVmContextSet = $propertyValue }
22372234

2238-
# update the OffLoadStateDetails properties
2239-
'NVGRE LSO Offload Enabled' { $object.OffloadState.LsoV2Supported = $propertyValue}
2240-
'NVGRE RSS Enabled' { $object.OffloadState.RssSupported = $propertyValue }
2241-
'NVGRE Transmit Checksum Offload Enabled' { $object.OffloadState.TransmitChecksumOffloadSupported = $propertyValue }
2242-
'NVGRE Receive Checksum Offload Enabled' { $object.OffloadState.ReceiveChecksumOffloadSupported = $propertyValue }
2243-
'NVGRE VMQ Enabled' { $object.OffloadState.VmqSupported = $propertyValue }
2244-
'VXLAN LSO Offload Enabled' { $object.OffloadState.LsoV2SupportedVxlan = $propertyValue }
2245-
'VXLAN RSS Enabled' { $object.OffloadState.RssSupportedVxlan = $propertyValue }
2246-
'VXLAN Transmit Checksum Offload Enabled' { $object.OffloadState.TransmitChecksumOffloadSupportedVxlan = $propertyValue }
2247-
'VXLAN Receive Checksum Offload Enabled' { $object.OffloadState.ReceiveChecksumOffloadSupportedVxlan = $propertyValue }
2248-
'VXLAN VMQ Enabled' { $object.OffloadState.VmqSupportedVxlan = $propertyValue }
2249-
'Inner MAC VMQ Enabled' { $object.OffloadState.InnerMacVmqEnabled = $propertyValue }
2250-
22512235
default {
22522236
$propertyName = $propertyName.Replace(' ','').Trim()
22532237

@@ -2262,8 +2246,36 @@ function Get-SdnVfpPortState {
22622246
}
22632247
}
22642248
else {
2265-
# if the line does not have key/value pairs, then continue to next line
2266-
continue
2249+
# in this scenario, we do not have a key/value pair, so we will need to extract the property differently
2250+
# in most instances, if we see the property defined in the line, we can assume it is enabled since default is disabled and will not print
2251+
# with vfpctrl /get-port-state output
2252+
switch ($line.Trim()) {
2253+
# these will map to VfpPortState
2254+
"DTLS Offload Enabled" { $object.DtlsOffloadEnabled = $true }
2255+
"GFT Offload Enabled" { $object.GftOffloadEnabled = $true }
2256+
"VMQ Enabled" { $object.VmqEnabled = $true }
2257+
"QoS Hardware Transmit Cap Offload Enabled" { $object.QosHardwareCapsEnabled = $true }
2258+
"QoS Hardware Transmit Reservation Offload Enabled" { $object.QosHardwareReservationsEnabled = $true }
2259+
"SR-IOV Enabled" { $object.SriovEnabled = $true }
2260+
2261+
# these will map to the OffloadState property within VfpPortState
2262+
"NVGRE LSO Offload Enabled" { $object.OffloadState.LsoV2Supported = $true }
2263+
"NVGRE RSS Enabled" { $object.OffloadState.RssSupported = $true }
2264+
"NVGRE Transmit Checksum Offload Enabled" { $object.OffloadState.TransmitChecksumOffloadSupported = $true }
2265+
"NVGRE Receive Checksum Offload Enabled" { $object.OffloadState.ReceiveChecksumOffloadSupported = $true }
2266+
"NVGRE VMQ Enabled" { $object.OffloadState.VmqSupported = $true }
2267+
"VXLAN LSO Offload Enabled" { $object.OffloadState.LsoV2SupportedVxlan = $true }
2268+
"VXLAN RSS Enabled" { $object.OffloadState.RssSupportedVxlan = $true }
2269+
"VXLAN Transmit Checksum Offload Enabled" { $object.OffloadState.TransmitChecksumOffloadSupportedVxlan = $true }
2270+
"VXLAN Receive Checksum Offload Enabled" { $object.OffloadState.ReceiveChecksumOffloadSupportedVxlan = $true }
2271+
"VXLAN VMQ Enabled" { $object.OffloadState.VmqSupportedVxlan = $true }
2272+
"Inner MAC VMQ Enabled" { $object.OffloadState.InnerMacVmqEnabled = $true }
2273+
2274+
default {
2275+
# this may just be random lines that do not map to a property, so we will just skip them
2276+
continue
2277+
}
2278+
}
22672279
}
22682280
}
22692281

0 commit comments

Comments
 (0)