I want to use DPI-C with package

When using the DPI-C function, can I call and use the function inside the package?

My example is
<dip_c.h>

##include <svdpi.h>

extern int reg_read(int addr, int data);

int my_seq(int addr, int data);

<dip_c.c>

int my_seq(int addr, int data){
    reg_read(addr,data);
}

<package_a.sv>

package A;
  import "DPI-C" context task my_seq(input int addr, input int data);
  export "DPI-C" task reg_read;

  my_agent   global_agent;

  task reg_read(input int addr, output int data);
    if(global_agent != null) begin
      global_agent.cpu_read32(addr,data);
    end 
    else begin
      $display("Error: global_agent is null");
    end
  endtask : reg_read

endpackage : A

<package_b.sv>

package B;
  import A::*;

`include "my_other_code.sv"
endpackage : B

Yes, you can use DPI within packages.

Are you having a specific issue, or is this just a general question?

I have just a general question. I wonder if my way is okay.

You code does not show who calls the DPI imported task my_seq. SystemVerilog distinguishes tasks from functions by allowing to consume simulated time. C has no concept of simulated time, but the DPI places the same restrictions that “functions” must not consume time. The only way a C-imported task consumes time is by calling a SV-exported task.

One of the complexities when a process consumes time is the possibility for some other process to disable or kill it. Thr DPI handles that using the return value of a C task. See section 35.9 Disabling DPI tasks and functions in the LRM. Your code may need to deal with that.