Skip to content

Commit

Permalink
Merge pull request #37 from yerden/fix-prepare-to-v22.11
Browse files Browse the repository at this point in the history
adapt to DPDK v22.11
  • Loading branch information
yerden authored Nov 7, 2023
2 parents 5ead2ae + 13b971d commit b3e3c2b
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 89 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@ env:

jobs:
build:
strategy:
matrix:
env_image:
- nedrey/dpdk-rockylinux8:v21.11-go1.19-snf
- nedrey/dpdk-rockylinux8:v22.11.3-go1.21.3-snf
runs-on: ubuntu-latest
container: nedrey/dpdk-rockylinux8:v21.11-go1.19-snf
container: ${{ matrix.env_image }}
steps:
-
name: Checkout
Expand Down
1 change: 1 addition & 0 deletions eal/eal.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package eal

/*
#include <stdlib.h>
#include <rte_config.h>
#include <rte_eal.h>
#include <rte_lcore.h>
Expand Down
25 changes: 18 additions & 7 deletions ethdev/ethdev.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ package ethdev
#include <rte_ethdev.h>
#include <rte_version.h>
void set_split_hdr_size_compat(struct rte_eth_rxmode *m, uint16_t v)
{
#if RTE_VERSION < RTE_VERSION_NUM(22, 11, 0, 0)
m->split_hdr_size = v;
#else
printf("split_hdr_size removed from rte_eth_rxmode as of v22.11\n");
#endif
}
// The max_rx_pkt_len changes occurred in commit: 1bb4a528c41f4af4847bd3d58cc2b2b9f1ec9a27.
#if RTE_VERSION < RTE_VERSION_NUM(21, 11, 0, 0)
enum {
Expand Down Expand Up @@ -97,13 +106,13 @@ import (
// This enum indicates the flow control mode.
const (
// Disable flow control.
FcNone uint32 = C.RTE_FC_NONE
FcNone uint32 = C.RTE_ETH_FC_NONE
// RX pause frame, enable flowctrl on TX side.
FcRxPause uint32 = C.RTE_FC_RX_PAUSE
FcRxPause uint32 = C.RTE_ETH_FC_RX_PAUSE
// TX pause frame, enable flowctrl on RX side.
FcTxPause uint32 = C.RTE_FC_TX_PAUSE
FcTxPause uint32 = C.RTE_ETH_FC_TX_PAUSE
// Enable flow control on both side.
FcFull uint32 = C.RTE_FC_FULL
FcFull uint32 = C.RTE_ETH_FC_FULL
)

// Option represents device option which is then used by
Expand Down Expand Up @@ -376,9 +385,11 @@ func OptLinkSpeeds(speeds uint) Option {
func OptRxMode(conf RxMode) Option {
return Option{func(c *ethConf) {
c.conf.rxmode = C.struct_rte_eth_rxmode{
mq_mode: uint32(conf.MqMode),
split_hdr_size: C.ushort(conf.SplitHdrSize),
offloads: C.ulong(conf.Offloads),
mq_mode: uint32(conf.MqMode),
offloads: C.ulong(conf.Offloads),
}
if conf.SplitHdrSize != 0 {
C.set_split_hdr_size_compat(&c.conf.rxmode, C.ushort(conf.SplitHdrSize))
}
c.setRxPktLen(conf.MTU)
}}
Expand Down
18 changes: 17 additions & 1 deletion ethdev/ethdev_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package ethdev

import (
"bytes"
"errors"
"syscall"
"testing"

Expand Down Expand Up @@ -29,7 +30,7 @@ func TestRssHashConfGet(t *testing.T) {

c.Key = bytes.Repeat([]byte{0x6d, 0x5a}, 20)
err = pid.RssHashUpdate(&c)
assert(t, err == nil, err)
assert(t, err == nil || errors.Is(err, syscall.ENOTSUP))
}

func TestDevInfo(t *testing.T) {
Expand Down Expand Up @@ -60,3 +61,18 @@ func TestPortName(t *testing.T) {
_, err = GetPortByName("some_name")
assert(t, err == syscall.ENODEV)
}

func TestOptRxMode(t *testing.T) {
opt := OptRxMode(RxMode{
MqMode: 1,
MTU: 2,
SplitHdrSize: 3,
Offloads: 4,
})
cfg := &ethConf{}
opt.f(cfg)

assert(t, cfg.conf.rxmode.mq_mode == 1)
assert(t, cfg.conf.rxmode.mtu == 2)
assert(t, cfg.conf.rxmode.offloads == 4)
}
80 changes: 0 additions & 80 deletions ethdev/flow/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,36 +52,6 @@ const (
*/
ItemTypeAny ItemType = C.RTE_FLOW_ITEM_TYPE_ANY

/**
* [META]
*
* Matches traffic originating from (ingress) or going to (egress)
* the physical function of the current device.
*
* No associated specification structure.
*/
ItemTypePf ItemType = C.RTE_FLOW_ITEM_TYPE_PF

/**
* [META]
*
* Matches traffic originating from (ingress) or going to (egress) a
* given virtual function of the current device.
*
* See struct rte_flow_item_vf.
*/
ItemTypeVf ItemType = C.RTE_FLOW_ITEM_TYPE_VF

/**
* [META]
*
* Matches traffic originating from (ingress) or going to (egress) a
* physical port of the underlying device.
*
* See struct rte_flow_item_phy_port.
*/
ItemTypePhyPort ItemType = C.RTE_FLOW_ITEM_TYPE_PHY_PORT

/**
* [META]
*
Expand Down Expand Up @@ -426,14 +396,6 @@ const (
*/
ActionTypeVf ActionType = C.RTE_FLOW_ACTION_TYPE_VF

/**
* Directs packets to a given physical port index of the underlying
* device.
*
* See struct rte_flow_action_phy_port.
*/
ActionTypePhyPort ActionType = C.RTE_FLOW_ACTION_TYPE_PHY_PORT

/**
* Directs matching traffic to a given DPDK port ID.
*
Expand All @@ -457,30 +419,6 @@ const (
*/
ActionTypeSecurity ActionType = C.RTE_FLOW_ACTION_TYPE_SECURITY

/**
* Implements OFPAT_SET_MPLS_TTL ("MPLS TTL") as defined by the
* OpenFlow Switch Specification.
*
* See struct rte_flow_action_of_set_mpls_ttl.
*/
ActionTypeOfSetMplsTTL ActionType = C.RTE_FLOW_ACTION_TYPE_OF_SET_MPLS_TTL

/**
* Implements OFPAT_DEC_MPLS_TTL ("decrement MPLS TTL") as defined
* by the OpenFlow Switch Specification.
*
* No associated configuration structure.
*/
ActionTypeOfDecMplsTTL ActionType = C.RTE_FLOW_ACTION_TYPE_OF_DEC_MPLS_TTL

/**
* Implements OFPAT_SET_NW_TTL ("IP TTL") as defined by the OpenFlow
* Switch Specification.
*
* See struct rte_flow_action_of_set_nw_ttl.
*/
ActionTypeOfSetNwTTL ActionType = C.RTE_FLOW_ACTION_TYPE_OF_SET_NW_TTL

/**
* Implements OFPAT_DEC_NW_TTL ("decrement IP TTL") as defined by
* the OpenFlow Switch Specification.
Expand All @@ -489,24 +427,6 @@ const (
*/
ActionTypeOfDecNwTTL ActionType = C.RTE_FLOW_ACTION_TYPE_OF_DEC_NW_TTL

/**
* Implements OFPAT_COPY_TTL_OUT ("copy TTL "outwards" -- from
* next-to-outermost to outermost") as defined by the OpenFlow
* Switch Specification.
*
* No associated configuration structure.
*/
ActionTypeOfCopyTTLOut ActionType = C.RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_OUT

/**
* Implements OFPAT_COPY_TTL_IN ("copy TTL "inwards" -- from
* outermost to next-to-outermost") as defined by the OpenFlow
* Switch Specification.
*
* No associated configuration structure.
*/
ActionTypeOfCopyTTLIn ActionType = C.RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_IN

/**
* Implements OFPAT_POP_VLAN ("pop the outer VLAN tag") as defined
* by the OpenFlow Switch Specification.
Expand Down

0 comments on commit b3e3c2b

Please sign in to comment.