Browse Source

[efi] Include VLAN in SNP device path if applicable

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 8 years ago
parent
commit
8f0bec4346
1 changed files with 15 additions and 2 deletions
  1. 15
    2
      src/interface/efi/efi_snp.c

+ 15
- 2
src/interface/efi/efi_snp.c View File

25
 #include <assert.h>
25
 #include <assert.h>
26
 #include <byteswap.h>
26
 #include <byteswap.h>
27
 #include <ipxe/netdevice.h>
27
 #include <ipxe/netdevice.h>
28
+#include <ipxe/vlan.h>
28
 #include <ipxe/iobuf.h>
29
 #include <ipxe/iobuf.h>
29
 #include <ipxe/in.h>
30
 #include <ipxe/in.h>
30
 #include <ipxe/version.h>
31
 #include <ipxe/version.h>
1545
 	struct efi_snp_device *snpdev;
1546
 	struct efi_snp_device *snpdev;
1546
 	EFI_DEVICE_PATH_PROTOCOL *path_end;
1547
 	EFI_DEVICE_PATH_PROTOCOL *path_end;
1547
 	MAC_ADDR_DEVICE_PATH *macpath;
1548
 	MAC_ADDR_DEVICE_PATH *macpath;
1549
+	VLAN_DEVICE_PATH *vlanpath;
1548
 	size_t path_prefix_len = 0;
1550
 	size_t path_prefix_len = 0;
1549
 	unsigned int ifcnt;
1551
 	unsigned int ifcnt;
1552
+	unsigned int tag;
1550
 	void *interface;
1553
 	void *interface;
1551
 	EFI_STATUS efirc;
1554
 	EFI_STATUS efirc;
1552
 	int rc;
1555
 	int rc;
1634
 	/* Allocate the new device path */
1637
 	/* Allocate the new device path */
1635
 	path_prefix_len = efi_devpath_len ( efidev->path );
1638
 	path_prefix_len = efi_devpath_len ( efidev->path );
1636
 	snpdev->path = zalloc ( path_prefix_len + sizeof ( *macpath ) +
1639
 	snpdev->path = zalloc ( path_prefix_len + sizeof ( *macpath ) +
1637
-				sizeof ( *path_end ) );
1640
+				sizeof ( *vlanpath ) + sizeof ( *path_end ) );
1638
 	if ( ! snpdev->path ) {
1641
 	if ( ! snpdev->path ) {
1639
 		rc = -ENOMEM;
1642
 		rc = -ENOMEM;
1640
 		goto err_alloc_device_path;
1643
 		goto err_alloc_device_path;
1643
 	/* Populate the device path */
1646
 	/* Populate the device path */
1644
 	memcpy ( snpdev->path, efidev->path, path_prefix_len );
1647
 	memcpy ( snpdev->path, efidev->path, path_prefix_len );
1645
 	macpath = ( ( ( void * ) snpdev->path ) + path_prefix_len );
1648
 	macpath = ( ( ( void * ) snpdev->path ) + path_prefix_len );
1646
-	path_end = ( ( void * ) ( macpath + 1 ) );
1647
 	memset ( macpath, 0, sizeof ( *macpath ) );
1649
 	memset ( macpath, 0, sizeof ( *macpath ) );
1648
 	macpath->Header.Type = MESSAGING_DEVICE_PATH;
1650
 	macpath->Header.Type = MESSAGING_DEVICE_PATH;
1649
 	macpath->Header.SubType = MSG_MAC_ADDR_DP;
1651
 	macpath->Header.SubType = MSG_MAC_ADDR_DP;
1651
 	memcpy ( &macpath->MacAddress, netdev->ll_addr,
1653
 	memcpy ( &macpath->MacAddress, netdev->ll_addr,
1652
 		 sizeof ( macpath->MacAddress ) );
1654
 		 sizeof ( macpath->MacAddress ) );
1653
 	macpath->IfType = ntohs ( netdev->ll_protocol->ll_proto );
1655
 	macpath->IfType = ntohs ( netdev->ll_protocol->ll_proto );
1656
+	if ( ( tag = vlan_tag ( netdev ) ) ) {
1657
+		vlanpath = ( ( ( void * ) macpath ) + sizeof ( *macpath ) );
1658
+		memset ( vlanpath, 0, sizeof ( *vlanpath ) );
1659
+		vlanpath->Header.Type = MESSAGING_DEVICE_PATH;
1660
+		vlanpath->Header.SubType = MSG_VLAN_DP;
1661
+		vlanpath->Header.Length[0] = sizeof ( *vlanpath );
1662
+		vlanpath->VlanId = tag;
1663
+		path_end = ( ( ( void * ) vlanpath ) + sizeof ( *vlanpath ) );
1664
+	} else {
1665
+		path_end = ( ( ( void * ) macpath ) + sizeof ( *macpath ) );
1666
+	}
1654
 	memset ( path_end, 0, sizeof ( *path_end ) );
1667
 	memset ( path_end, 0, sizeof ( *path_end ) );
1655
 	path_end->Type = END_DEVICE_PATH_TYPE;
1668
 	path_end->Type = END_DEVICE_PATH_TYPE;
1656
 	path_end->SubType = END_ENTIRE_DEVICE_PATH_SUBTYPE;
1669
 	path_end->SubType = END_ENTIRE_DEVICE_PATH_SUBTYPE;

Loading…
Cancel
Save