@@ -127,6 +127,23 @@ def make_parser(cls) -> ParserFn:
127127 )
128128
129129
130+ class ChecksumOffloadOptions (Flag ):
131+ """Flag representing checksum hardware offload layer options."""
132+
133+ #:
134+ ip = auto ()
135+ #:
136+ udp = auto ()
137+ #:
138+ tcp = auto ()
139+ #:
140+ sctp = auto ()
141+ #:
142+ outer_ip = auto ()
143+ #:
144+ outer_udp = auto ()
145+
146+
130147class RSSOffloadTypesFlag (Flag ):
131148 """Flag representing the RSS offload flow types supported by the NIC port."""
132149
@@ -1778,6 +1795,47 @@ def show_port_stats(self, port_id: int) -> TestPmdPortStats:
17781795
17791796 return TestPmdPortStats .parse (output )
17801797
1798+ @requires_stopped_ports
1799+ def csum_set_hw (
1800+ self , layers : ChecksumOffloadOptions , port_id : int , verify : bool = True
1801+ ) -> None :
1802+ """Enables hardware checksum offloading on the specified layer.
1803+
1804+ Args:
1805+ layers: The layer/layers that checksum offloading should be enabled on.
1806+ port_id: The port number to enable checksum offloading on, should be within 0-32.
1807+ verify: If :data:`True` the output of the command will be scanned in an attempt to
1808+ verify that checksum offloading was enabled on the port.
1809+
1810+ Raises:
1811+ InteractiveCommandExecutionError: If checksum offload is not enabled successfully.
1812+ """
1813+ for name , offload in ChecksumOffloadOptions .__members__ .items ():
1814+ if offload in layers :
1815+ name = name .replace ("_" , "-" )
1816+ csum_output = self .send_command (f"csum set { name } hw { port_id } " )
1817+ if verify :
1818+ if (
1819+ "Bad arguments" in csum_output
1820+ or f"Please stop port { port_id } first" in csum_output
1821+ or f"checksum offload is not supported by port { port_id } " in csum_output
1822+ ):
1823+ self ._logger .debug (f"Csum set hw error:\n { csum_output } " )
1824+ raise InteractiveCommandExecutionError (
1825+ f"Failed to set csum hw { name } mode on port { port_id } "
1826+ )
1827+ success = False
1828+ if f"{ name } checksum offload is hw" in csum_output .lower ():
1829+ success = True
1830+ if not success and verify :
1831+ self ._logger .debug (
1832+ f"Failed to set csum hw mode on port { port_id } :\n { csum_output } "
1833+ )
1834+ raise InteractiveCommandExecutionError (
1835+ f"""Failed to set csum hw mode on port
1836+ { port_id } :\n { csum_output } """
1837+ )
1838+
17811839 @requires_stopped_ports
17821840 def set_port_mtu (self , port_id : int , mtu : int , verify : bool = True ) -> None :
17831841 """Change the MTU of a port using testpmd.
0 commit comments