-
Notifications
You must be signed in to change notification settings - Fork 260
Mellanox priority vlan tag set script #1224
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
Merged
pjohnst5
merged 6 commits into
Azure:master
from
pjohnst5:mellanox-priority-vlan-tag-set-script
Feb 7, 2022
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
44294fc
Mellanox adapter priority vlan tag script
pjohnst5 5c019cf
Adapt to x-3 version
pjohnst5 df3927f
Restart network adapter afterwards
pjohnst5 8f45b77
Newline at end
pjohnst5 c805cea
Comment at the top
pjohnst5 8264961
Adapter comment
pjohnst5 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| # This script will set the PriorityVLANTag registry key on a multitenant windows VM | ||
| # This is needed for VLAN tagging to be honored so that SWIFT packets flow out properly to the Azure Host | ||
|
|
||
| function Set-NetAdapterPriorityVLanTag | ||
| { | ||
| New-Variable -Name PriorityVLANTagIdentifier -Value "*PriorityVLANTag" -Option ReadOnly | ||
| New-Variable -Name MellanoxSearchString -Value "*Mellanox*" -Option ReadOnly | ||
| New-Variable -Name RegistryKeyPrefix -Value "HKLM:\System\CurrentControlSet\Control\Class\" -Option ReadOnly | ||
|
|
||
| Write-Host "Searching for a network adapter with '$MellanoxSearchString' in description" | ||
| $ethernetName = Get-NetAdapter | Where-Object { $_.InterfaceDescription -like $MellanoxSearchString } | Select-Object -ExpandProperty Name | ||
|
|
||
| if ($ethernetName) | ||
| { | ||
| Write-Host "Network adapter found: '$ethernetName'" | ||
| $ethernetNameIfInProperty = Get-NetAdapterAdvancedProperty | Where-Object { $_.RegistryKeyword -like $PriorityVLANTagIdentifier -and $_.Name -eq $ethernetName } | Select-Object -ExpandProperty Name | ||
|
|
||
| Write-Host "Searching network adapter properties for '$PriorityVLANTagIdentifier'" | ||
| if ($ethernetNameIfInProperty) | ||
| { | ||
| Write-Host "Found '$PriorityVLANTagIdentifier' in adapter's advanced properties" | ||
| Set-NetAdapterAdvancedProperty -Name $ethernetName -RegistryKeyword $PriorityVLANTagIdentifier -RegistryValue 3 | ||
| Write-Host "Successfully set Mellanox Network Adapter: '$ethernetName' with '$PriorityVLANTagIdentifier' property value as 3" | ||
| return; | ||
| } | ||
|
|
||
| Write-Host "Could not find '$PriorityVLANTagIdentifier' in adapter's advanced properties" | ||
|
|
||
| Write-Host "Proceeding in a different way" | ||
| Write-Host "Searching through CIM instances for Network devices with '$MellanoxSearchString' in the name" | ||
| $deviceID = Get-CimInstance -Namespace root/cimv2 -ClassName Win32_PNPEntity | Where-Object PNPClass -EQ "Net" | Where-Object { $_.Name -like $MellanoxSearchString } | Select-Object -ExpandProperty DeviceID | ||
| if ($deviceID) | ||
| { | ||
| Write-Host "Device ID found: '$deviceID'" | ||
| Write-Host "Getting Pnp Device properites for '$deviceID'" | ||
| $registryKeySuffix = Get-PnpDeviceProperty -InstanceId $deviceID | Where-Object KeyName -EQ "DEVPKEY_Device_Driver" | Select-Object -ExpandProperty Data | ||
| Write-Host "Registry key suffix found: '$registryKeySuffix'" | ||
| $registryKeyFullPath = $RegistryKeyPrefix + $registryKeySuffix | ||
| Write-Host "Registry key full path: '$registryKeyFullPath'" | ||
| Write-Host "Updating '$PriorityVLANTagIdentifier' to be 3" | ||
| New-ItemProperty -Path $registryKeyFullPath -Name $PriorityVLANTagIdentifier -Value 3 -PropertyType String -Force | ||
| Write-Host "Updated successfully" | ||
|
|
||
| Write-Host "Restarting Mellanox network adapter for regkey change to take effect" | ||
| Restart-NetAdapter -Name $ethernetName | ||
| Write-Host "Successfully restarted Mellanox network adapter" | ||
| Write-Host "For Mellanox CX-3 adapters, if the problem persists please restart the VM" | ||
| return; | ||
| } | ||
|
|
||
| Write-Host "No network device found with '$MellanoxSearchString' in name, exiting." | ||
| return; | ||
| } | ||
|
|
||
| Write-Host "No Network adapter found with '$MellanoxSearchString' in description" | ||
| return; | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.