I support the tp-link t4u driver for linux

When I bought a wifi adapter, I thought it would work on my ubuntu 20.04, because linux was listed among the supported systems. It turned out not to work. I tried the solutions that are offered on the forums, but the adapter did not work. I had to deal with driver support yesterday and today.



I thought, maybe this is not difficult to do. And he got down to work. Compilation errors appeared. For example, there is no get_ds function. Well, yes, it was in version 4 of the kernel, but in version 5 this function is not. I sometimes think that developers do not want to support their drivers due to the fact that they constantly make changes in the kernel and some parts of the code need to be rewritten. In general, I looked at how get_ds is implemented in the old version of the kernel. It turns out it just returns KERNEL_DS. Well, I also replaced it. Then there was a problem with the time structure, which already has only a 64-bit version in the current kernel. This is fixed. There were also minor fixes, but I don't remember what I fixed. So the driver compiled but refused to register the adapter device. I found a patch link, which obliges manufacturers to specify the rules. I added to each entry in os_dep / linux / rtw_cfgvendor.c, this .policy = VENDOR_CMD_RAW_DATA,



Example:



        {
                {
                        .vendor_id = OUI_GOOGLE,
                        .subcmd = RTT_SUBCMD_SET_CONFIG
                },
                .policy = VENDOR_CMD_RAW_DATA,
                .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV,
                .doit = rtw_cfgvendor_rtt_set_config
        },
        {
                {
                        .vendor_id = OUI_GOOGLE,
                        .subcmd = RTT_SUBCMD_CANCEL_CONFIG
                },
                .policy = VENDOR_CMD_RAW_DATA,
                .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV,
                .doit = rtw_cfgvendor_rtt_cancel_config
        },
        {
                {
                        .vendor_id = OUI_GOOGLE,
                        .subcmd = RTT_SUBCMD_GETCAPABILITY
                },
                .policy = VENDOR_CMD_RAW_DATA,
                .flags = WIPHY_VENDOR_CMD_NEED_WDEV | WIPHY_VENDOR_CMD_NEED_NETDEV,
                .doit = rtw_cfgvendor_rtt_get_capability
        },


And compiled, copied and ran. and voila! I managed. ) Although I do not understand kernel development, I managed to make simple support. The link to the source code of the driver will be posted on the google disk for now. here's a link. link .



And it's also now on github .



I'm glad if it is useful to someone.



image



All Articles