tdl-xoa-driver 1.1.0__py3-none-any.whl → 1.3.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,12 +1,3 @@
1
- ################################################################
2
- #
3
- # HEADER BUILDER
4
- #
5
- # This script shows you how you can build your own header builder
6
- # that converts human readable values into hex strings
7
- #
8
- ################################################################
9
-
10
1
  from ipaddress import IPv4Address, IPv6Address
11
2
  from binascii import hexlify
12
3
  from xoa_driver.misc import Hex
@@ -146,7 +137,7 @@ class Ethernet:
146
137
  return f"{_dst_mac}{_src_mac}{_ethertype}".upper()
147
138
 
148
139
  ####################################
149
- # VLAN #
140
+ # VLAN #
150
141
  ####################################
151
142
 
152
143
  @dataclass
@@ -605,4 +596,314 @@ class MACControlPause:
605
596
  def __str__(self):
606
597
  _opcode: str = self.opcode
607
598
  _value = '{:04X}'.format(self.value)
608
- return f"{_opcode}{_value}".upper()
599
+ return f"{_opcode}{_value}".upper()
600
+
601
+
602
+ ####################################
603
+ # Infiniband Headers #
604
+ ####################################
605
+ class BTHOpcode(Enum):
606
+ # OpCodeValues
607
+ # Code Bits [7-5] Connection Type
608
+ # [4-0] Message Type
609
+
610
+ # Reliable Connection (RC)
611
+ # [7-5] = 000
612
+ RC_SEND_FIRST = 0 # /*0x00000000 */ "RC Send First "
613
+ RC_SEND_MIDDLE = 1 # /*0x00000001 */ "RC Send Middle "
614
+ RC_SEND_LAST = 2 # /*0x00000010 */ "RC Send Last "
615
+ RC_SEND_LAST_IMM = 3 # /*0x00000011 */ "RC Send Last Immediate "
616
+ RC_SEND_ONLY = 4 # /*0x00000100 */ "RC Send Only "
617
+ RC_SEND_ONLY_IMM = 5 # /*0x00000101 */ "RC Send Only Immediate "
618
+ RC_RDMA_WRITE_FIRST = 6 # /*0x00000110 */ "RC RDMA Write First "
619
+ RC_RDMA_WRITE_MIDDLE = 7 # /*0x00000111 */ "RC RDMA Write Middle "
620
+ RC_RDMA_WRITE_LAST = 8 # /*0x00001000 */ "RC RDMA Write Last "
621
+ RC_RDMA_WRITE_LAST_IMM = 9 # /*0x00001001 */ "RC RDMA Write Last Immediate "
622
+ RC_RDMA_WRITE_ONLY = 10 # /*0x00001010 */ "RC RDMA Write Only "
623
+ RC_RDMA_WRITE_ONLY_IMM = 11 # /*0x00001011 */ "RC RDMA Write Only Immediate "
624
+ RC_RDMA_READ_REQUEST = 12 # /*0x00001100 */ "RC RDMA Read Request "
625
+ RC_RDMA_READ_RESPONSE_FIRST = 13 # /*0x00001101 */ "RC RDMA Read Response First "
626
+ RC_RDMA_READ_RESPONSE_MIDDLE = 14 # /*0x00001110 */ "RC RDMA Read Response Middle "
627
+ RC_RDMA_READ_RESPONSE_LAST = 15 # /*0x00001111 */ "RC RDMA Read Response Last "
628
+ RC_RDMA_READ_RESPONSE_ONLY = 16 # /*0x00010000 */ "RC RDMA Read Response Only "
629
+ RC_ACKNOWLEDGE = 17 # /*0x00010001 */ "RC Acknowledge "
630
+ RC_ATOMIC_ACKNOWLEDGE = 18 # /*0x00010010 */ "RC Atomic Acknowledge "
631
+ RC_CMP_SWAP = 19 # /*0x00010011 */ "RC Compare Swap "
632
+ RC_FETCH_ADD = 20 # /*0x00010100 */ "RC Fetch Add "
633
+ RC_SEND_LAST_INVAL = 22 # /*0x00010110 */ "RC Send Last Invalidate "
634
+ RC_SEND_ONLY_INVAL = 23 # /*0x00010111 */ "RC Send Only Invalidate "
635
+
636
+ # Reliable Datagram (RD)
637
+ # [7-5] = 010
638
+ RD_SEND_FIRST = 64 # /*0x01000000 */ "RD Send First "
639
+ RD_SEND_MIDDLE = 65 # /*0x01000001 */ "RD Send Middle "
640
+ RD_SEND_LAST = 66 # /*0x01000010 */ "RD Send Last "
641
+ RD_SEND_LAST_IMM = 67 # /*0x01000011 */ "RD Send Last Immediate "
642
+ RD_SEND_ONLY = 68 # /*0x01000100 */ "RD Send Only "
643
+ RD_SEND_ONLY_IMM = 69 # /*0x01000101 */ "RD Send Only Immediate "
644
+ RD_RDMA_WRITE_FIRST = 70 # /*0x01000110 */ "RD RDMA Write First "
645
+ RD_RDMA_WRITE_MIDDLE = 71 # /*0x01000111 */ "RD RDMA Write Middle "
646
+ RD_RDMA_WRITE_LAST = 72 # /*0x01001000 */ "RD RDMA Write Last "
647
+ RD_RDMA_WRITE_LAST_IMM = 73 # /*0x01001001 */ "RD RDMA Write Last Immediate "
648
+ RD_RDMA_WRITE_ONLY = 74 # /*0x01001010 */ "RD RDMA Write Only "
649
+ RD_RDMA_WRITE_ONLY_IMM = 75 # /*0x01001011 */ "RD RDMA Write Only Immediate "
650
+ RD_RDMA_READ_REQUEST = 76 # /*0x01001100 */ "RD RDMA Read Request "
651
+ RD_RDMA_READ_RESPONSE_FIRST = 77 # /*0x01001101 */ "RD RDMA Read Response First "
652
+ RD_RDMA_READ_RESPONSE_MIDDLE = 78 # /*0x01001110 */ "RD RDMA Read Response Middle "
653
+ RD_RDMA_READ_RESPONSE_LAST = 79 # /*0x01001111 */ "RD RDMA Read Response Last "
654
+ RD_RDMA_READ_RESPONSE_ONLY = 80 # /*0x01010000 */ "RD RDMA Read Response Only "
655
+ RD_ACKNOWLEDGE = 81 # /*0x01010001 */ "RD Acknowledge "
656
+ RD_ATOMIC_ACKNOWLEDGE = 82 # /*0x01010010 */ "RD Atomic Acknowledge "
657
+ RD_CMP_SWAP = 83 # /*0x01010011 */ "RD Compare Swap "
658
+ RD_FETCH_ADD = 84 # /*0x01010100 */ "RD Fetch Add "
659
+ RD_RESYNC = 85 # /*0x01010101 */ "RD RESYNC "
660
+
661
+ # Unreliable Datagram (UD)
662
+ # [7-5] = 011
663
+ UD_SEND_ONLY = 100 # /*0x01100100 */ "UD Send Only "
664
+ UD_SEND_ONLY_IMM = 101 # /*0x01100101 */ "UD Send Only Immediate "
665
+
666
+ # Unreliable Connection (UC)
667
+ # [7-5] = 001
668
+ UC_SEND_FIRST = 32 # /*0x00100000 */ "UC Send First "
669
+ UC_SEND_MIDDLE = 33 # /*0x00100001 */ "UC Send Middle "
670
+ UC_SEND_LAST = 34 # /*0x00100010 */ "UC Send Last "
671
+ UC_SEND_LAST_IMM = 35 # /*0x00100011 */ "UC Send Last Immediate "
672
+ UC_SEND_ONLY = 36 # /*0x00100100 */ "UC Send Only "
673
+ UC_SEND_ONLY_IMM = 37 # /*0x00100101 */ "UC Send Only Immediate "
674
+ UC_RDMA_WRITE_FIRST = 38 # /*0x00100110 */ "UC RDMA Write First"
675
+ UC_RDMA_WRITE_MIDDLE = 39 # /*0x00100111 */ "UC RDMA Write Middle "
676
+ UC_RDMA_WRITE_LAST = 40 # /*0x00101000 */ "UC RDMA Write Last "
677
+ UC_RDMA_WRITE_LAST_IMM = 41 # /*0x00101001 */ "UC RDMA Write Last Immediate"
678
+ UC_RDMA_WRITE_ONLY = 42 # /*0x00101010 */ "UC RDMA Write Only "
679
+ UC_RDMA_WRITE_ONLY_IMM = 43 # /*0x00101011 */ "UC RDMA Write Only Immediate"
680
+
681
+ @dataclass
682
+ class BTH:
683
+ """BASE TRANSPORT HEADER (BTH) - 12 BYTES
684
+
685
+ Base Transport Header contains the fields for IBA transports.
686
+ """
687
+ opcode: BTHOpcode = BTHOpcode.RC_SEND_FIRST
688
+ """OpCode indicates the IBA packet type. It also
689
+ specifies which extension headers follow the BTH
690
+ """
691
+ se = 0
692
+ """Solicited Event, this bit indicates that an event
693
+ should be generated by the responder
694
+ """
695
+ migreq = 0
696
+ """This bit is used to communicate migration state
697
+ """
698
+ padcnt = 1
699
+ """Pad Count indicates how many extra bytes are added
700
+ to the payload to align to a 4 byte boundary
701
+ """
702
+ tver = 0
703
+ """Transport Header Version indicates the version of
704
+ the IBA Transport Headers
705
+ """
706
+ pkey = 65535
707
+ """Partition Key indicates which logical Partition is
708
+ associated with this packet
709
+ """
710
+ reserved = 7
711
+ """Reserved
712
+ """
713
+ destqp = 2
714
+ """Destination QP indicates the Work Queue Pair Number
715
+ (QP) at the destination
716
+ """
717
+ ackreq = 0
718
+ """Acknowledge Request, this bit is used to indicate
719
+ that an acknowledge (for this packet) should be
720
+ scheduled by the responder
721
+ """
722
+ reserved_7bits = 0
723
+ """Reserved
724
+ """
725
+ psn =0
726
+ """Packet Sequence Number is used to detect a missing
727
+ or duplicate Packet
728
+ """
729
+
730
+ def __str__(self):
731
+ _opcode = '{:02X}'.format(self.opcode.value)
732
+ _combo_1 = '{:02X}'.format((self.se<<7)+(self.migreq<<6)+(self.padcnt<<4)+self.tver)
733
+ _pk = '{:04X}'.format(self.pkey)
734
+ _reserved = '{:02X}'.format(self.reserved)
735
+ _qp = '{:06X}'.format(self.destqp)
736
+ _combo_2 = '{:02X}'.format((self.ackreq<<7)+self.reserved_7bits)
737
+ _ps = '{:06X}'.format(self.psn)
738
+ return f"{_opcode}{_combo_1}{_pk}{_reserved}{_qp}{_combo_2}{_ps}".upper()
739
+
740
+ @dataclass
741
+ class RETH:
742
+ """RDMA EXTENDED TRANSPORT HEADER (RETH) - 16 BYTES
743
+
744
+ RDMA Extended Transport Header contains the additional transport fields
745
+ for RDMA operations. The RETH is present in only the first (or only)
746
+ packet of an RDMA Request as indicated by the Base Transport Header
747
+ OpCode field.
748
+ """
749
+ va = 0
750
+ """Virtual Address of the RDMA operation
751
+ """
752
+ r_key = 0
753
+ """Remote Key that authorizes access for the RDMA operation
754
+ """
755
+ dma_len = 0
756
+ """DMA Length indicates the length (in Bytes) of the DMA operation.
757
+ """
758
+
759
+ def __str__(self):
760
+ _va = '{:016X}'.format(self.va)
761
+ _r_key = '{:08X}'.format(self.r_key)
762
+ _dma_len = '{:08X}'.format(self.dma_len)
763
+ return f"{_va}{_r_key}{_dma_len}".upper()
764
+
765
+ @dataclass
766
+ class AETH:
767
+ """ACK EXTENDED TRANSPORT HEADER (AETH) - 4 BYTES
768
+
769
+ ACK Extended Transport Header contains the additional transport fields
770
+ for ACK packets. The AETH is only in Acknowledge, RDMA READ Response
771
+ First, RDMA READ Response Last, and RDMA READ Response Only packets
772
+ as indicated by the Base Transport Header OpCode field.
773
+ """
774
+ syndrome = 0
775
+ """Syndrome indicates if this is an ACK or NAK
776
+ packet plus additional information about the
777
+ ACK or NAK
778
+ """
779
+ msn = 0
780
+ """Message Sequence Number indicates the sequence
781
+ number of the last message completed at the
782
+ responder
783
+ """
784
+
785
+ def __str__(self):
786
+ _syndrome = '{:02X}'.format(self.syndrome)
787
+ _msn = '{:06X}'.format(self.msn)
788
+ return f"{_syndrome}{_msn}".upper()
789
+
790
+ @dataclass
791
+ class RDETH:
792
+ """RELIABLE DATAGRAM EXTENDED TRANSPORT HEADER (RDETH) - 4 BYTES
793
+
794
+ Reliable Datagram Extended Transport Header contains the additional
795
+ transport fields for reliable datagram service. The RDETH is only
796
+ in Reliable Datagram packets as indicated by the Base Transport Header
797
+ OpCode field.
798
+ """
799
+
800
+ reserved = 0
801
+ """Reserved
802
+ """
803
+ ee_context = 0
804
+ """EE-Context indicates which End-to-End Context
805
+ should be used for this Reliable Datagram packet
806
+ """
807
+
808
+ def __str__(self):
809
+ _reserved = '{:02X}'.format(self.reserved)
810
+ _ee_context = '{:06X}'.format(self.ee_context)
811
+ return f"{_reserved}{_ee_context}".upper()
812
+
813
+ @dataclass
814
+ class DETH:
815
+ """DATAGRAM EXTENDED TRANSPORT HEADER (DETH) - 8 BYTES
816
+
817
+ Datagram Extended Transport Header contains the additional transport
818
+ fields for datagram service. The DETH is only in datagram packets if
819
+ indicated by the Base Transport Header OpCode field.
820
+ """
821
+ q_key = 0
822
+ """Queue Key is required to authorize access to the receive queue
823
+ """
824
+ reserved = 0
825
+ """Reserved
826
+ """
827
+ src_qp = 0
828
+ """Source QP indicates the Work Queue Pair Number (QP) at the source.
829
+ """
830
+
831
+ def __str__(self):
832
+ _q_key = '{:08X}'.format(self.q_key)
833
+ _reserved = '{:02X}'.format(self.reserved)
834
+ _src_qp = '{:06X}'.format(self.src_qp)
835
+ return f"{_q_key}{_reserved}{_src_qp}".upper()
836
+
837
+ @dataclass
838
+ class IB:
839
+ bth = BTH()
840
+ reth = RETH()
841
+ aeth = AETH()
842
+ rdeth = RDETH()
843
+ deth = DETH()
844
+
845
+ def __str__(self):
846
+ if self.bth.opcode == BTHOpcode.RC_SEND_FIRST or self.bth.opcode == BTHOpcode.RC_SEND_MIDDLE or self.bth.opcode == BTHOpcode.RC_SEND_LAST:
847
+ return str(self.bth)
848
+ if self.bth.opcode == BTHOpcode.RC_RDMA_WRITE_FIRST:
849
+ return str(self.bth)+str(self.reth)
850
+ if self.bth.opcode == BTHOpcode.RC_RDMA_WRITE_MIDDLE or self.bth.opcode == BTHOpcode.RC_RDMA_WRITE_LAST:
851
+ return str(self.bth)
852
+ if self.bth.opcode == BTHOpcode.RC_RDMA_READ_RESPONSE_FIRST or self.bth.opcode == BTHOpcode.RC_RDMA_READ_RESPONSE_LAST:
853
+ return str(self.bth)+str(self.aeth)
854
+ if self.bth.opcode == BTHOpcode.RC_RDMA_READ_RESPONSE_MIDDLE:
855
+ return str(self.bth)
856
+ if self.bth.opcode == BTHOpcode.RD_SEND_FIRST or self.bth.opcode == BTHOpcode.RD_SEND_MIDDLE or self.bth.opcode == BTHOpcode.RD_SEND_LAST:
857
+ return str(self.bth)+str(self.rdeth)+str(self.deth)
858
+ if self.bth.opcode == BTHOpcode.RD_RDMA_WRITE_FIRST:
859
+ return str(self.bth)+str(self.rdeth)+str(self.deth)+str(self.reth)
860
+ if self.bth.opcode == BTHOpcode.RD_RDMA_WRITE_MIDDLE or self.bth.opcode == BTHOpcode.RD_RDMA_WRITE_LAST:
861
+ return str(self.bth)+str(self.rdeth)+str(self.deth)
862
+ if self.bth.opcode == BTHOpcode.RD_RDMA_READ_RESPONSE_FIRST or self.bth.opcode == BTHOpcode.RD_RDMA_READ_RESPONSE_LAST:
863
+ return str(self.bth)+str(self.rdeth)+str(self.aeth)
864
+ if self.bth.opcode == BTHOpcode.RD_RDMA_READ_RESPONSE_MIDDLE:
865
+ return str(self.bth)+str(self.rdeth)
866
+ if self.bth.opcode == BTHOpcode.UD_SEND_ONLY:
867
+ return str(self.bth)+str(self.deth)
868
+
869
+
870
+ ######################
871
+ # MPLS #
872
+ ######################
873
+ @dataclass
874
+ class MPLS:
875
+ label: int = 0
876
+ exp: int = 0
877
+ s: int = 1
878
+ ttl: int = 0
879
+
880
+ def __str__(self):
881
+ _combo: str = '{:06X}'.format((self.label<<4)+(self.exp<<1)+(self.s))
882
+ _ttl: str = '{:02X}'.format(self.ttl)
883
+ return f"{_combo}{_ttl}".upper()
884
+
885
+
886
+ __all__ = (
887
+ "IPV4",
888
+ "IPV6",
889
+ "UDP",
890
+ "TCP",
891
+ "PTP",
892
+ "eCPRIGeneralDataTransfer",
893
+ "DHCPV4",
894
+ "DHCPOptionMessageType",
895
+ "DHCPOptionClientIdentifier",
896
+ "DHCPOptionRequestedIP",
897
+ "DHCPOptionParamRequestList",
898
+ "DHCPOptionPad",
899
+ "DHCPOptionEnd",
900
+ "MACControlPFC",
901
+ "MACControlPause",
902
+ "BTH",
903
+ "RETH",
904
+ "AETH",
905
+ "RDETH",
906
+ "DETH",
907
+ "IB",
908
+ "MPLS"
909
+ )