Editing Mellanox OFED II

Semidragon·2023년 7월 17일
0

While the first trial of Editing Mellanox OFED seemed to go right, it turned out that editing certain files such as en_main.c caused a problem when trying to install the package using dpkg -i.
To simply see the solution, move to 3.Solution

1. Understanding the Problem

On the README file, I found an answer that they suggest for 1.compilation 2.add a new feature/fix, and 3. add backport patches:

1.1 Simply Compilation

For simple Compilation, they tell us to:

HOWTO add a new feature/fix:
----------------------------
Compilation procedure:

# cd mlnx_rdma
# git checkout master

# ./configure <params>
E.g.: ./configure --with-core-mod --with-user_mad-mod --with-user_access-mod --with-addr_trans-mod --with-mlx4-mod --with-mlx4_en-mod --with-mlx5-mod --with-ipoib-mod --with-srp-mod --with-rds-mod --with-iser-mod

Note: If "backports_applied" file exist then backport patches will not be applied.

# make distclean
# make
# make install

1.2 Add a new feature/ fix

Then, when it comes to adding a new feature, or fixing it, which is what we want to do, it tells us to:

HOWTO add a new feature/fix:
----------------------------
Start with updated branch (equal to “master”).

Add the new code.
Check compilation on the latest kernel base.
# ./configure <params> --without-backport-patches

Note: Provide path to kernel sources if needed: --kernel-version <version> --kernel-sources <path to sources>

# make distclean
# make
# make install

Now, this seemed to solve the problem, yet when I tried to fix the en_main.c file and configure with the --without-backport-patches it showed the following error:

So, I needed to first understand what "Backporting" is, and what is happening.

2. What is Backporting?

The root cause of this problem was due "Backporting".

3. Trials to Solve the problem

3.1

4. Solution

So, from the investigation, we knew that:
1. All backport patches are being patched with the with-backport-patch option.
2. Thus with this option, we cannot cannot directly change the source code as patches need to be done later.
3. With without-backport-patch option, patches are not applied, yet because of that, dependency problem occurs between the files.
4. We cannot directly change the patch file due its change-Id value.

Thus with all this, I have come up with a solution of finding all the backport patches on the desired file (in our case, en_main.c), manually apply those patches on the source code, then fix the code.
Then, with the with-backport-patch option, it will patch all other files to cause no dependency problem too.

Here's How it works:

  1. find the backport.patch file that patches the desired file.
    ex) for en_main.c:
    0270-BACKPORT-drivers-net-ethernet-mellanox-mlx5-core-en_.patch, there may be various patches for a file)

  2. Apply Patches:

patch -p1 < /home/brian11hwang/SR-IOV/OFED_TEST/mlnx-ofed-kernel-5.8/backports/0270-BACKPORT-drivers-net-ethernet-mellanox-mlx5-core-en_.patch

Here, we can see that the file has change due patch applied.

  1. Remove patch file:
rm -f 0270-BACKPORT-drivers-net-ethernet-mellanox-mlx5-core-en_.patch
  1. Edit code:
  1. configure without the --without-backport-patch option:
./configure --with-core-mod --with-user_mad-mod --with-user_access-mod --with-addr_trans-mod --with-mlx4-mod --with-mlx4_en-mod --with-mlx5-mod --with-srp-mod --with-rds-mod --with-iser-mod --kernel-version 5.15.0-76-generic
  1. install & reload driver
make -j 16
sudo make install
sudo /etc/init.d/openibd restart
  1. Test

    We can see that the fix has successfully been applied.
profile
Semidragon's network [CS undergrad @ Sungkyunkwan University | Networks + System @ CSI]

1개의 댓글

comment-user-thumbnail
2023년 7월 17일

저도 개발자인데 같이 교류 많이 해봐요 ㅎㅎ! 서로 화이팅합시다!

답글 달기